fix bug in llama_sample_token_mirostat_v2

when all candidates are filtered out through mu threshold, the following soft_max operation will fail.
so keep at least one.
This commit is contained in:
xaedes 2023-05-21 21:12:10 +02:00
parent ec1783c3e0
commit 2afd218479
No known key found for this signature in database
GPG key ID: 30030EDD817EA2B1

View file

@ -1882,6 +1882,10 @@ llama_token llama_sample_token_mirostat_v2(struct llama_context * ctx, llama_tok
return -log2f(candidate.p) > *mu;
}));
if (candidates->size == 0) {
candidates->size = 1;
}
// Normalize the probabilities of the remaining words
llama_sample_softmax(ctx, candidates);