Expand description
Token sampling from a decoder’s output logits: temperature, top-k,
top-p (nucleus), and repetition penalty, on top of the greedy argmax
ferrox previously always used unconditionally (see
crate::speculative, which still uses plain greedy argmax directly
since its quality-neutrality proof depends on exactly matching
greedy decode – sampling is a deliberately separate, opt-in path).
No external rand dependency: a small xorshift64* generator (the
same algorithm Decoder::new_random_small’s test-only Lcg already
uses in decoder.rs) is enough for sampling and keeps the
dependency tree the same minimal, pure-Rust shape as the rest of
this crate.
Structs§
- Sampler
- A small, seedable xorshift64* generator. Not cryptographically secure – sampling doesn’t need that – but reproducible given a seed, which greedy argmax already was for free.
- Sampling
Params - Sampling parameters for one generation request.
temperature <= 0.0means “sample nothing, take the greedy argmax” – the same deterministic behavior ferrox always had before this module existed.
Type Aliases§
- Logit
Mask - Zeroes out logits a caller wants to forbid, in place, before the sampler looks at them. Used by JSON-object mode to keep generation inside the grammar.