Skip to content

Commit 6e91a1b

Browse files
authored
llama : fix grammar sometimes generating null char (#2756)
1 parent 44d5462 commit 6e91a1b

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

llama.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4074,7 +4074,7 @@ void llama_sample_grammar(struct llama_context * ctx, llama_token_data_array * c
40744074
if (!allow_eos) {
40754075
candidates->data[i].logit = -INFINITY;
40764076
}
4077-
} else if (text.empty()) {
4077+
} else if (text.empty() || text[0] == 0) {
40784078
candidates->data[i].logit = -INFINITY;
40794079
} else {
40804080
candidates_decoded.push_back(decode_utf8(text.c_str(), grammar->partial_utf8));

0 commit comments

Comments
 (0)