Adding top-n-sigma sampler

This commit is contained in:
Iwan Kawrakow
2025-06-03 12:23:32 +03:00
parent ccb265c016
commit 1ce02ebc01
7 changed files with 93 additions and 8 deletions

View File

@@ -1216,6 +1216,13 @@ extern "C" {
float threshold,
size_t min_keep);
/// @details Top n sigma sampling as described in academic paper "Top-nσ: Not All Logits Are You Need" https://arxiv.org/pdf/2411.07641
LLAMA_API void llama_sample_top_n_sigma(
struct llama_context * ctx,
llama_token_data_array * candidates_p,
float top_n_sigma);
/// @details Mirostat 1.0 algorithm described in the paper https://arxiv.org/abs/2007.14966. Uses tokens instead of words.
/// @param candidates A vector of `llama_token_data` containing the candidate tokens, their probabilities (p), and log-odds (logit) for the current position in the generated text.
/// @param tau The target cross-entropy (or surprise) value you want to achieve for the generated text. A higher value corresponds to more surprising or less predictable text, while a lower value corresponds to less surprising or more predictable text.