summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEvan Jones <evan.q.jones@gmail.com>2023-08-24 00:07:13 -0400
committerGitHub <noreply@github.com>2023-08-24 07:07:13 +0300
commit6e91a1b0706c2e0e52b9d9be7ee82d3c1e7a33c1 (patch)
tree0271883678675c12523c434d3030456ddcd416ca
parent44d5462b5cddc1c5cbcd7647646f7b55b175b01f (diff)
llama : fix grammar sometimes generating null char (#2756)
-rw-r--r--llama.cpp2
1 files changed, 1 insertions, 1 deletions
diff --git a/llama.cpp b/llama.cpp
index f2dc4da1..7cac8a1c 100644
--- 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));