Fix top-p sampling to match the standard definition (smallest set that has probability mass at least p, not largest set with probability mass less than p)
This commit is contained in:
parent
049aa16b8c
commit
1e7755cfcb
1 changed files with 2 additions and 2 deletions
|
@ -2006,8 +2006,8 @@ void llama_sample_top_p(struct llama_context * ctx, llama_token_data_array * can
|
|||
cum_sum += candidates->data[i].p;
|
||||
|
||||
// Check if the running sum is greater than p or if we have kept at least min_keep tokens
|
||||
if (cum_sum > p && i >= min_keep) {
|
||||
last_idx = i;
|
||||
if (cum_sum > p && i + 1 >= min_keep) {
|
||||
last_idx = i + 1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue