vocab : keep </s> NORMAL in PLaMo-2 and PLaMo-3 (#29580)

* vocab : keep </s> NORMAL in PLaMo-2 and PLaMo-3

The PLaMo-2 and PLaMo-3 vocabularies mark </s> as NORMAL. Current
EOG token heuristic matched it by text and added its attribute
to CONTROL.

Skip this heuristic for the PLAMO2 vocab type so </s> stays NORMAL
and is not treated as EOG.

* use <|plamo:eos|> for detection
This commit is contained in:
Toki Nasin
2026-09-29 20:30:40 +03:00
committed by GitHub
parent 284153e069
commit a3f84faf49
+6 -6
View File
@@ -2996,9 +2996,9 @@ void llama_vocab::impl::load(llama_model_loader & ml, const LLM_KV & kv) {
}
}
// workaround for gemma4 and paddleocr: do not include </s> as an eog token
// gemma4 and plamo have a normal </s> token, unlike paddleocr
{
bool has_tool_response = false;
bool has_normal_s_marker = false;
bool has_s = false;
llama_token s_id = LLAMA_TOKEN_NULL;
@@ -3008,21 +3008,21 @@ void llama_vocab::impl::load(llama_model_loader & ml, const LLM_KV & kv) {
continue;
}
const auto & text = id_to_token[tid].text;
if (text == "<|tool_response>") {
has_tool_response = true;
if (text == "<|tool_response>" || text == "<|plamo:eos|>") {
has_normal_s_marker = true;
} else if (text == "</s>") {
has_s = true;
s_id = tid;
}
}
if (has_tool_response && has_s) {
if (has_normal_s_marker && has_s) {
special_eog_ids.erase(s_id);
auto & attr = id_to_token[s_id].attr;
attr = LLAMA_TOKEN_ATTR_NORMAL;
LLAMA_LOG_WARN("%s: special_eog_ids contains '<|tool_response>', removing '</s>' token from EOG list\n", __func__);
LLAMA_LOG_WARN("%s: '</s>' is a normal token here, removing it from EOG list\n", __func__);
}
}
}