Skip to content

Commit 84e1fe7

Browse files
authored
Merge pull request #250 from rachiki/fix/handle_unk_tokens_emb
Fix/handle unk tokens emb
2 parents 6eb896d + 7a11e3f commit 84e1fe7

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

embeddings/src/main.rs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,14 @@ fn main() -> Result<()> {
137137
for (i, token_line) in tokens_lines_list.iter().enumerate() {
138138
eprintln!("Prompt {i}");
139139
for token in token_line {
140-
eprintln!(" {} --> {}", token, model.token_to_str(*token)?);
140+
// Attempt to convert token to string and print it; if it fails, print the token instead
141+
match model.token_to_str(*token) {
142+
Ok(token_str) => eprintln!(" {} --> {}", token, token_str),
143+
Err(e) => {
144+
eprintln!("Failed to convert token to string, error: {}", e);
145+
eprintln!("Token value: {}", token);
146+
}
147+
}
141148
}
142149
eprintln!();
143150
}

0 commit comments

Comments
 (0)