llama: various bug fixes (#26051)

This commit is contained in:
Xuan-Son Nguyen
2026-07-24 18:56:42 +02:00
committed by GitHub
parent fa72aeccb2
commit 298219f985
7 changed files with 46 additions and 3 deletions
+16 -1
View File
@@ -1331,6 +1331,9 @@ struct llm_tokenizer_rwkv_session {
token_id = node->value;
token_length = position + 1;
}
if (position + 1 >= text.size()) {
break;
}
node = node->traverse(text[++position]);
}
@@ -2865,6 +2868,11 @@ void llama_vocab::impl::load(llama_model_loader & ml, const LLM_KV & kv) {
LLAMA_LOG_INFO("%s: printing all EOG tokens:\n", __func__);
for (auto tid : special_eog_ids) {
if (tid < 0 || tid >= (llama_token) id_to_token.size()) {
LLAMA_LOG_WARN("%s: EOG token id %d is out of range (vocab size %zu), skipping\n",
__func__, tid, id_to_token.size());
continue;
}
auto & text = id_to_token[tid].text;
LLAMA_LOG_INFO("%s: - %d ('%s')\n", __func__, tid, text.c_str());
@@ -2899,6 +2907,9 @@ void llama_vocab::impl::load(llama_model_loader & ml, const LLM_KV & kv) {
llama_token s_id = LLAMA_TOKEN_NULL;
for (auto tid : special_eog_ids) {
if (tid < 0 || tid >= (llama_token) id_to_token.size()) {
continue;
}
const auto & text = id_to_token[tid].text;
if (text == "<|tool_response>") {
has_tool_response = true;
@@ -4028,7 +4039,11 @@ int llama_vocab::find_bpe_rank(const std::string & token_left, const std::string
}
std::vector<std::string> llama_vocab::get_bpe_merges() const {
std::vector<std::string> result(pimpl->bpe_ranks.size());
int max_rank = -1;
for (const auto & pair : pimpl->bpe_ranks) {
max_rank = std::max(max_rank, pair.second);
}
std::vector<std::string> result(max_rank + 1);
for (const auto & pair : pimpl->bpe_ranks) {
result[pair.second] = pair.first.first + " " + pair.first.second;