File tree Expand file tree Collapse file tree 1 file changed +8
-2
lines changed Expand file tree Collapse file tree 1 file changed +8
-2
lines changed Original file line number Diff line number Diff line change @@ -3366,9 +3366,15 @@ struct llm_tokenizer_bpe {
3366
3366
std::string byte_str (1 , *j);
3367
3367
auto token_multibyte = vocab.token_to_id .find (byte_str);
3368
3368
if (token_multibyte == vocab.token_to_id .end ()) {
3369
- fprintf (stderr," ERROR: byte not found in vocab: '%s'\n " , byte_str.c_str ());
3369
+ try {
3370
+ llama_token token_byte = llama_byte_to_token (vocab, *j);
3371
+ output.push_back (token_byte);
3372
+ } catch (const std::out_of_range & err) {
3373
+ fprintf (stderr," ERROR: byte not found in vocab: '%s'\n " , byte_str.c_str ());
3374
+ }
3375
+ } else {
3376
+ output.push_back ((*token_multibyte).second );
3370
3377
}
3371
- output.push_back ((*token_multibyte).second );
3372
3378
}
3373
3379
} else {
3374
3380
output.push_back ((*token).second );
You can’t perform that action at this time.
0 commit comments