sampling : add clarifying comment [no ci]

This commit is contained in:
Georgi Gerganov 2024-09-24 09:02:54 +03:00
parent a5a11bfbc3
commit e9e1c20c75
No known key found for this signature in database
GPG key ID: BF970631944C16B7

View file

@ -210,6 +210,11 @@ struct gpt_sampler * gpt_sampler_init(const struct llama_model * model, const st
}
} else {
if (params.n_probs > 0) {
// some use cases require to sample greedily, but still obtain the probabilities of the top tokens
// ref: https://github.com/ggerganov/llama.cpp/pull/9605
//
// the following will not produce exactly the same probs as applyging softmax to the full vocabulary, but
// it is much faster, since we avoid sorting all tokens and should give a good approximation
llama_sampler_chain_add(result->chain, llama_sampler_init_top_k(params.n_probs));
llama_sampler_chain_add(result->chain, llama_sampler_init_softmax());
}