llama : add option for greedy sampling with probs

This commit is contained in:
Georgi Gerganov 2023-10-27 16:12:01 +03:00
parent 34b2a5e1ee
commit 4aa1fb0d38
No known key found for this signature in database
GPG key ID: 449E073F9DC10735
2 changed files with 7 additions and 3 deletions

View file

@ -167,9 +167,13 @@ llama_token llama_sampling_sample(
llama_sample_grammar(ctx_main, &cur_p, ctx_sampling->grammar);
}
if (temp <= 0) {
// greedy sampling
if (temp < 0.0) {
// greedy sampling, no probs
id = llama_sample_token_greedy(ctx_main, &cur_p);
} else if (temp == 0.0) {
// greedy sampling, with probs
llama_sample_softmax(ctx_main, &cur_p);
id = cur_p.data[0].id;
} else {
if (mirostat == 1) {
const int mirostat_m = 100;