mirror of
https://github.com/ikawrakow/ik_llama.cpp.git
synced 2026-03-02 01:50:01 +00:00
Adaptive p: bugfix + optimization + refactor (#1155)
* adaptive-p sampler: fix zeroed orig_probs bug and refactor - Fix bug where original probabilities were captured as zero by calculating them from logits in llama_prep_adaptive_p (new). - Replace vector with unordered_map to track candidate probabilities, filtering for relevance via logit delta (16.6f). - Standardize API naming: llama_<action/verb>_<focus/name/topic>_<extra/info> - Update function signatures to follow most other samplers. * resolve merge bug * adaptive-p: revert reordering function definitions
This commit is contained in:
@@ -1384,16 +1384,20 @@ LLAMA_API struct llama_grammar* llama_sampler_init_grammar_lazy_patterns(
|
||||
/// @details Adaptive p sampler initializer
|
||||
/// @param target Select tokens near this probability (valid range 0.0 to 1.0; <0 = disabled)
|
||||
/// @param decay Decay rate for target adaptation over time. lower values -> faster but less stable adaptation. (valid range 0.0 to 1.0; ≤0 = no adaptation)
|
||||
LLAMA_API struct llama_sampler_adaptive_p * llama_sampler_init_adaptive_p(
|
||||
LLAMA_API struct llama_sampler_adaptive_p * llama_init_adaptive_p(
|
||||
const float target,
|
||||
const float decay,
|
||||
const uint32_t seed);
|
||||
|
||||
void llama_prep_adaptive_p(
|
||||
llama_token_data_array * candidates,
|
||||
struct llama_sampler_adaptive_p * adapt_p_ctx);
|
||||
|
||||
/// @details Adaptive p sampler described in https://github.com/MrJackSpade/adaptive-p-docs/blob/main/README.md
|
||||
void llama_sample_adaptive_p(
|
||||
struct llama_context * ctx,
|
||||
struct llama_sampler_adaptive_p * adapt_p_ctx,
|
||||
llama_token_data_array * candidates);
|
||||
struct llama_context * ctx,
|
||||
llama_token_data_array * candidates,
|
||||
struct llama_sampler_adaptive_p * adapt_p_ctx);
|
||||
|
||||
|
||||
/// @details Mirostat 1.0 algorithm described in the paper https://arxiv.org/abs/2007.14966. Uses tokens instead of words.
|
||||
@@ -1437,8 +1441,7 @@ LLAMA_API struct llama_grammar* llama_sampler_init_grammar_lazy_patterns(
|
||||
llama_token llama_sample_token_adaptive_p(
|
||||
struct llama_context * ctx,
|
||||
llama_token_data_array * candidates,
|
||||
struct llama_sampler_adaptive_p * adapt_p_ctx,
|
||||
float * orig_probs);
|
||||
struct llama_sampler_adaptive_p * adapt_p_ctx);
|
||||
|
||||
//
|
||||
// Model split
|
||||
|
||||
Reference in New Issue
Block a user