Skip to content

Commit 81086cd

Browse files
authored
vocab : mark EOT token for Granite models (ggml-org#16499)
* vocab : mark EOT token for Granite models * sampling : fallback to EOS when EOT is not found
1 parent 68ee98a commit 81086cd

File tree

2 files changed

+6
-0
lines changed

2 files changed

+6
-0
lines changed

src/llama-sampling.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2541,8 +2541,13 @@ static void llama_sampler_infill_apply(struct llama_sampler * smpl, llama_token_
25412541
if (n_non_eog == 0) {
25422542
cur_p->size = 1;
25432543
cur_p->data[0].id = ctx->vocab->token_eot();
2544+
if (cur_p->data[0].id == LLAMA_TOKEN_NULL) {
2545+
cur_p->data[0].id = ctx->vocab->token_eos();
2546+
}
25442547
cur_p->data[0].logit = 1.0f;
25452548

2549+
GGML_ASSERT(cur_p->data[0].id != LLAMA_TOKEN_NULL);
2550+
25462551
return;
25472552
}
25482553

src/llama-vocab.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2171,6 +2171,7 @@ void llama_vocab::impl::load(llama_model_loader & ml, const LLM_KV & kv) {
21712171
|| t.first == "<|end|>"
21722172
|| t.first == "<end_of_turn>"
21732173
|| t.first == "<|endoftext|>"
2174+
|| t.first == "<|end_of_text|>" // granite
21742175
|| t.first == "<EOT>"
21752176
|| t.first == "_<EOT>"
21762177
|| t.first == "<|end▁of▁sentence|>" // DeepSeek

0 commit comments

Comments
 (0)