Skip to content

Commit

Permalink
feat(milestone): 支持 ceval 测试
Browse files Browse the repository at this point in the history
Signed-off-by: YdrMaster <[email protected]>
  • Loading branch information
YdrMaster committed Jan 15, 2025
1 parent 72fa93b commit 99d583d
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 0 deletions.
1 change: 1 addition & 0 deletions test-utils/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,4 @@ gguf.workspace = true
tensor.workspace = true
env_logger.workspace = true
cli-table = "0.4.9"
serde_json = "1.0"
28 changes: 28 additions & 0 deletions test-utils/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,34 @@ pub fn test_infer(
}};
}

let maybe_file = Path::new(prompt);
if maybe_file.is_file() {
let file = std::fs::read_to_string(maybe_file).unwrap();
for line in file.lines() {
let line = serde_json::from_str::<String>(line).unwrap();
let prompt = format!("<s>{line}\n");

// print_now!("{prompt}");

let mut tokens = tokenizer.encode(&prompt);
let mut pos = 0;
for _ in 0..max_steps {
let next = lm(&tokens, pos);

pos += tokens.len();
if next == eos {
break;
}

let piece = tokenizer.decode(next);
print_now!("{piece}");
tokens = vec![next];
}
println!()
}
return;
}

print_now!("{prompt}");

let mut tokens = tokenizer.encode(prompt);
Expand Down

0 comments on commit 99d583d

Please sign in to comment.