Skip to content

Commit

Permalink
llama : Use token_to_id map find() method instead of iterating over a…
Browse files Browse the repository at this point in the history
…ll tokens.
  • Loading branch information
sszymczy committed Aug 4, 2024
1 parent 3878b39 commit 0b72113
Showing 1 changed file with 3 additions and 5 deletions.
8 changes: 3 additions & 5 deletions src/llama.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5647,11 +5647,9 @@ static void llm_load_vocab(
// TODO: convert scripts should provide this token through the KV metadata LLAMA_KV_TOKENIZER_EOM_ID
// for now, we apply this workaround to find the EOM token based on its text
if (vocab.special_eom_id == -1) {
for (const auto & t : vocab.token_to_id) {
if (t.first == "<|eom_id|>") {
vocab.special_eom_id = t.second;
break;
}
const auto & t = vocab.token_to_id.find("<|eom_id|>");
if (t != vocab.token_to_id.end()) {
vocab.special_eom_id = t->second;
}
}

Expand Down

0 comments on commit 0b72113

Please sign in to comment.