Skip to main content

Module sampling

Module sampling 

Source
Expand description

Sampling — a chain-object LlamaSampler matching llama-cpp-2’s API, emulated over ik_llama.cpp’s legacy llama_sample_* array functions.

ik has no llama_sampler_chain_* and only grammar/dry sampler-init functions, so this reconstructs the anchor’s chain model in Rust: each constructor builds a one-stage sampler, LlamaSampler::chain_simple concatenates them, and apply runs the stages over a LlamaTokenDataArray in order. The legacy transforms accept a null llama_context (ik guards it internally), so no context is needed until the final draw; the dist selector draws in Rust from a seeded RNG.

Re-exports§

pub use crate::token::data_array::LlamaTokenDataArray;

Structs§

LlamaSampler
A sampler: an ordered chain of transform stages ending in a selector, matching llama-cpp-2’s LlamaSampler.