Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

server : handle models with missing EOS token #8997

Merged
merged 1 commit into from
Aug 12, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading