Skip to main content

Module sampler

Module sampler 

Source
Expand description

Token sampling — temperature, top-p, top-k, min-p, repetition penalty.

Randomness comes from an explicit SplitMix64 PRNG carried by the caller: reproducible with a seed, unbiased across the whole CDF (the v1 subsec_nanos source could never pick past ~23% of it).

Structs§

SamplerConfig
Sampling configuration.
SplitMix64
SplitMix64 — tiny, fast, statistically solid for sampling.

Functions§

argmax
Greedy: index of the maximum value.
sample
Sample next token from logits. Chain order is fixed: rep-penalty → temperature → softmax → min-p → top-k → top-p → sample.