]> git.djapps.eu Git - pkg/ggml/sources/llama.cpp/commitdiff
llama : fix grammar sometimes generating null char (#2756)
authorEvan Jones <redacted>
Thu, 24 Aug 2023 04:07:13 +0000 (00:07 -0400)
committerGitHub <redacted>
Thu, 24 Aug 2023 04:07:13 +0000 (07:07 +0300)
llama.cpp

index f2dc4da1db344221ad10749535128ac84d650a0d..7cac8a1ce4b282b09d9dacfe90127d80fe34af6f 100644 (file)
--- a/llama.cpp
+++ b/llama.cpp
@@ -4074,7 +4074,7 @@ void llama_sample_grammar(struct llama_context * ctx, llama_token_data_array * c
             if (!allow_eos) {
                 candidates->data[i].logit = -INFINITY;
             }
-        } else if (text.empty()) {
+        } else if (text.empty() || text[0] == 0) {
             candidates->data[i].logit = -INFINITY;
         } else {
             candidates_decoded.push_back(decode_utf8(text.c_str(), grammar->partial_utf8));