From 1ff9296253ffc83dfe786dad32dd043cb05e3613 Mon Sep 17 00:00:00 2001 From: Georgi Gerganov Date: Thu, 12 Dec 2024 22:50:34 +0200 Subject: [PATCH] common : ignore all EOG tokens Co-authored-by: Diego Devesa --- common/common.cpp | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/common/common.cpp b/common/common.cpp index 2846a2de3..c0c98232e 100644 --- a/common/common.cpp +++ b/common/common.cpp @@ -941,8 +941,12 @@ struct common_init_result common_init_from_params(common_params & params) { } if (params.sampling.ignore_eos) { - LOG_INF("%s: added EOS logit bias = %f\n", __func__, -INFINITY); - params.sampling.logit_bias.push_back({llama_token_eos(model), -INFINITY}); + for (llama_token i = 0; i < llama_n_vocab(model); i++) { + if (llama_token_is_eog(model, i)) { + LOG_INF("%s: added %s logit bias = %f\n", __func__, common_token_to_piece(lctx, i).c_str(), -INFINITY); + params.sampling.logit_bias.push_back({i, -INFINITY}); + } + } } if (params.sampling.penalty_last_n == -1) {