Skip to content

Commit

Permalink
implemented staircase approach for TrainingsData
Browse files Browse the repository at this point in the history
  • Loading branch information
JakubSchwenkbeck committed Dec 21, 2024
1 parent 8599517 commit 041966f
Showing 1 changed file with 26 additions and 5 deletions.
31 changes: 26 additions & 5 deletions src/data/generation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -70,10 +70,31 @@ pub fn example_gen() {
println!("Input: {:?}\nTarget: {:?}\n", input, target);
}
for (input, target) in pairs {
println!(
"Input: {:?}\nTarget: {:?}\n",
tokenizer.detokenize(input),
tokenizer.detokenize(target)
);


let staircase_pairs = generate_staircase_pairs(&input, &target);

for (staircase_input, staircase_target) in staircase_pairs {
println!(
"Input: {:?}\nTarget: {:?}\n",
tokenizer.detokenize(staircase_input),
tokenizer.detokenize(staircase_target)
);
}
}
}
fn generate_staircase_pairs(input: &Vec<usize>, target: &Vec<usize>) -> Vec<(Vec<usize>, Vec<usize>)> {
let mut staircase_pairs = Vec::new();

// The number of steps will be the length of the target sequence
for i in 1..=target.len() {
// Slice input and target incrementally
let staircase_input = input.iter().take(i).cloned().collect::<Vec<usize>>();
let staircase_target = target.iter().take(i).cloned().collect::<Vec<usize>>();

// Add this pair to the staircase pairs vector
staircase_pairs.push((staircase_input, staircase_target));
}

staircase_pairs
}

0 comments on commit 041966f

Please sign in to comment.