From 6e91a1b0706c2e0e52b9d9be7ee82d3c1e7a33c1 Mon Sep 17 00:00:00 2001 From: Evan Jones Date: Thu, 24 Aug 2023 00:07:13 -0400 Subject: [PATCH] llama : fix grammar sometimes generating null char (#2756) --- llama.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/llama.cpp b/llama.cpp index f2dc4da1d..7cac8a1ce 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));