From 672df48ed14c3e190050e6a83ccd0a9ccce40f5e Mon Sep 17 00:00:00 2001 From: firecoperana <18252262+firecoperana@users.noreply.github.com> Date: Tue, 13 Jan 2026 10:08:09 -0600 Subject: [PATCH] server: keep logit bias unchanged when client does not set it (#1144) Co-authored-by: firecoperana --- examples/server/server-context.cpp | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/examples/server/server-context.cpp b/examples/server/server-context.cpp index e00ee384..90129cf7 100644 --- a/examples/server/server-context.cpp +++ b/examples/server/server-context.cpp @@ -1059,15 +1059,10 @@ bool server_context::launch_slot_with_task(server_slot& slot, server_task& task) } } - { - slot.sparams.logit_bias.clear(); - - if (json_value(data, "ignore_eos", false) && has_eos_token) { - slot.sparams.logit_bias[llama_token_eos(model)] = -INFINITY; - } - + { // apply logit bias const auto& logit_bias = data.find("logit_bias"); if (logit_bias != data.end() && logit_bias->is_array()) { + slot.sparams.logit_bias.clear(); // only clear if user sets it const int n_vocab = llama_n_vocab(model); for (const auto& el : *logit_bias) { // TODO: we may want to throw errors here, in case "el" is incorrect @@ -1098,13 +1093,16 @@ bool server_context::launch_slot_with_task(server_slot& slot, server_task& task) } } } + if (json_value(data, "ignore_eos", false) && has_eos_token) { + slot.sparams.logit_bias[llama_token_eos(model)] = -INFINITY; + } + } { - slot.params.antiprompt.clear(); - const auto& stop = data.find("stop"); if (stop != data.end() && stop->is_array()) { + slot.params.antiprompt.clear(); for (const auto& word : *stop) { if (!word.empty()) { slot.params.antiprompt.push_back(word);