Skip to content

Commit fbb7fcf

Browse files
authored
llama : set attrs of mislabelled EOT/EOM tokens (#9348)
1 parent a5b5d9a commit fbb7fcf

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

src/llama.cpp

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6399,6 +6399,11 @@ static void llm_load_vocab(
63996399
)
64006400
) {
64016401
vocab.special_eot_id = t.second;
6402+
if ((vocab.id_to_token[t.second].attr & LLAMA_TOKEN_ATTR_CONTROL) == 0) {
6403+
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",
6404+
__func__, t.first.c_str());
6405+
vocab.id_to_token[t.second].attr = LLAMA_TOKEN_ATTR_CONTROL;
6406+
}
64026407
break;
64036408
}
64046409
}
@@ -6412,6 +6417,11 @@ static void llm_load_vocab(
64126417
const auto & t = vocab.token_to_id.find("<|eom_id|>");
64136418
if (t != vocab.token_to_id.end()) {
64146419
vocab.special_eom_id = t->second;
6420+
if ((vocab.id_to_token[t->second].attr & LLAMA_TOKEN_ATTR_CONTROL) == 0) {
6421+
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",
6422+
__func__, t->first.c_str());
6423+
vocab.id_to_token[t->second].attr = LLAMA_TOKEN_ATTR_CONTROL;
6424+
}
64156425
}
64166426
}
64176427
}

0 commit comments

Comments
 (0)