Skip to content

Commit

Permalink
server : handle models with missing EOS token (#8997)
Browse files Browse the repository at this point in the history
ggml-ci
  • Loading branch information
ggerganov authored Aug 12, 2024
1 parent 4134999 commit 5ef07e2
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions examples/server/server.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -631,6 +631,7 @@ struct server_context {

bool clean_kv_cache = true;
bool add_bos_token = true;
bool has_eos_token = false;

int32_t n_ctx; // total context for all clients / slots

Expand Down Expand Up @@ -693,7 +694,7 @@ struct server_context {
n_ctx = llama_n_ctx(ctx);

add_bos_token = llama_should_add_bos_token(model);
GGML_ASSERT(llama_add_eos_token(model) != 1);
has_eos_token = llama_add_eos_token(model) != 1;

return true;
}
Expand Down Expand Up @@ -1031,7 +1032,7 @@ struct server_context {
{
slot.sparams.logit_bias.clear();

if (json_value(data, "ignore_eos", false)) {
if (json_value(data, "ignore_eos", false) && has_eos_token) {
slot.sparams.logit_bias[llama_token_eos(model)] = -INFINITY;
}

Expand Down

0 comments on commit 5ef07e2

Please sign in to comment.