Skip to main content

Module sampling

Module sampling 

Source
Expand description

Sampling strategies for next-token selection.

Supports greedy, top-k, top-p (nucleus), min-p, temperature scaling, repetition penalty, Mirostat v2, and GBNF grammar-constrained sampling.

Modules§

advanced
Advanced sampler stages: DRY, XTC, TypicalP, TopA, and Eta.
chain
Composable sampler chain — trait-based pipeline for token selection.
grammar
GBNF grammar-constrained sampling.

Structs§

Sampler
Stateful sampler that maintains PRNG state across calls.
SamplerConfig
Configuration for the sampling strategy.

Functions§

sample
Sample a token ID from logits using the given configuration.