Skip to content

Commit

Permalink
llama : set attrs of mislabelled EOT/EOM tokens (ggerganov#9348)
Browse files Browse the repository at this point in the history
  • Loading branch information
bakkot authored and dsx1986 committed Oct 29, 2024
1 parent 5b07015 commit 66898d7
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions src/llama.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6399,6 +6399,11 @@ static void llm_load_vocab(
)
) {
vocab.special_eot_id = t.second;
if ((vocab.id_to_token[t.second].attr & LLAMA_TOKEN_ATTR_CONTROL) == 0) {
LLAMA_LOG_WARN("%s: control-looking token: '%s' was not control-type; this is probably a bug in the model. its type will be overridden\n",
__func__, t.first.c_str());
vocab.id_to_token[t.second].attr = LLAMA_TOKEN_ATTR_CONTROL;
}
break;
}
}
Expand All @@ -6412,6 +6417,11 @@ static void llm_load_vocab(
const auto & t = vocab.token_to_id.find("<|eom_id|>");
if (t != vocab.token_to_id.end()) {
vocab.special_eom_id = t->second;
if ((vocab.id_to_token[t->second].attr & LLAMA_TOKEN_ATTR_CONTROL) == 0) {
LLAMA_LOG_WARN("%s: control-looking token: '%s' was not control-type; this is probably a bug in the model. its type will be overridden\n",
__func__, t->first.c_str());
vocab.id_to_token[t->second].attr = LLAMA_TOKEN_ATTR_CONTROL;
}
}
}
}
Expand Down

0 comments on commit 66898d7

Please sign in to comment.