From 630a7d456ff68b2bc1b8976a69a4fe1554319b97 Mon Sep 17 00:00:00 2001 From: x1250 Date: Thu, 5 Mar 2026 03:10:51 -0300 Subject: [PATCH] server: preserve --logit-bias as default for API requests The --logit-bias CLI flag was being unconditionally cleared on every API request, making it ineffective when used as a server-level default. Other sampling defaults (e.g. ignore_eos) correctly fall back to params_base when the client omits them. This patch applies the same pattern to logit_bias: the server-level value is used as the default, and a client-provided logit_bias in the request body still overrides it. --- tools/server/server-task.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/tools/server/server-task.cpp b/tools/server/server-task.cpp index d3aba18489..9003f09dee 100644 --- a/tools/server/server-task.cpp +++ b/tools/server/server-task.cpp @@ -405,10 +405,11 @@ task_params server_task::params_from_json_cmpl( } { - params.sampling.logit_bias.clear(); + params.sampling.logit_bias = params_base.sampling.logit_bias; const auto & logit_bias = data.find("logit_bias"); if (logit_bias != data.end() && logit_bias->is_array()) { + params.sampling.logit_bias.clear(); const int n_vocab = llama_vocab_n_tokens(vocab); for (const auto & el : *logit_bias) { // TODO: we may want to throw errors here, in case "el" is incorrect @@ -436,6 +437,7 @@ task_params server_task::params_from_json_cmpl( } } } else if (logit_bias != data.end() && logit_bias->is_object()) { + params.sampling.logit_bias.clear(); const int n_vocab = llama_vocab_n_tokens(vocab); for (const auto & el : logit_bias->items()) { float bias;