sampling : min-p should always return at least one token

ggml-ci
This commit is contained in:
Georgi Gerganov
2025-05-27 11:24:40 +03:00
parent 4f81b33e32
commit fe12a5d47e
2 changed files with 3 additions and 2 deletions

View File

@@ -798,7 +798,7 @@ static void llama_sampler_min_p_apply(struct llama_sampler * smpl, llama_token_d
}
// if we have enough values the operation was a success
if (filtered_tokens.size() >= ctx->min_keep) {
if (!filtered_tokens.empty() && filtered_tokens.size() >= ctx->min_keep) {
memcpy(cur_p->data, filtered_tokens.data(), filtered_tokens.size()*sizeof(llama_token_data));
cur_p->size = filtered_tokens.size();
min_p_applied = true;