sampling : add clarifying comment [no ci]
This commit is contained in:
parent
a5a11bfbc3
commit
e9e1c20c75
1 changed files with 5 additions and 0 deletions
|
@ -210,6 +210,11 @@ struct gpt_sampler * gpt_sampler_init(const struct llama_model * model, const st
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (params.n_probs > 0) {
|
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_top_k(params.n_probs));
|
||||||
llama_sampler_chain_add(result->chain, llama_sampler_init_softmax());
|
llama_sampler_chain_add(result->chain, llama_sampler_init_softmax());
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue