]> git.djapps.eu Git - pkg/ggml/sources/llama.cpp/commitdiff
server : handle models with missing EOS token (#8997)
authorGeorgi Gerganov <redacted>
Mon, 12 Aug 2024 07:21:50 +0000 (10:21 +0300)
committerGitHub <redacted>
Mon, 12 Aug 2024 07:21:50 +0000 (10:21 +0300)
ggml-ci

examples/server/server.cpp

index 360f571e42867626b59a91021e987b53d207d8ad..1621c7c43961c1f4c7ec7b229065c0e8f5e04b61 100644 (file)
@@ -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
 
@@ -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;
     }
@@ -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;
             }