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.
This commit is contained in:
x1250 2026-03-05 03:10:51 -03:00
parent 7a99dc85e2
commit 630a7d456f
1 changed files with 3 additions and 1 deletions

View File

@ -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;