pub struct SamplingConfig {
pub temperature: f32,
pub top_k: Option<usize>,
pub top_p: Option<f32>,
pub min_p: Option<f32>,
pub repeat_penalty: f32,
pub repeat_last_n: usize,
pub seed: u64,
}Expand description
Configuration for StochasticSampler’s logit-transform pipeline.
Every threshold is Option-or-plain depending on whether “disabled” is
a meaningful state: top_k/top_p/min_p default to None (that
stage of the pipeline is skipped entirely), while temperature and
repeat_penalty always run (a temperature of 1.0 and a repeat
penalty of 1.0 are each that stage’s identity value, so leaving them
at their defaults is equivalent to skipping them, without needing a
second Option layer).
Fields§
§temperature: f32Divides every logit before the final softmax. 1.0 (the default)
leaves the distribution’s shape unchanged; values below 1.0
sharpen it toward the top-scoring tokens, values above 1.0
flatten it toward uniform. <= 0.0 is treated as “skip stochastic
sampling entirely and fall back to greedy_argmax” — see
StochasticSampler::sample’s docs for why that is an exact
equivalence, not an approximation.
top_k: Option<usize>Keep only the k highest-scoring tokens before sampling. None
(the default) skips this stage.
top_p: Option<f32>Nucleus sampling: keep the smallest prefix of tokens (sorted by
probability, descending) whose cumulative probability is the first
to exceed p. None (the default) skips this stage.
min_p: Option<f32>Keep only tokens whose probability is at least min_p times the
single most likely token’s probability. None (the default) skips
this stage.
repeat_penalty: f32Divides a previously-generated token’s logit by this value if it
was positive, or multiplies it if negative — the standard
(Keskar et al., 2019, CTRL) repetition penalty. 1.0 (the default)
is the identity: no penalty.
repeat_last_n: usizeHow many of the most recently generated tokens
StochasticSampler remembers for Self::repeat_penalty’s
history window.
seed: u64Seeds StochasticSampler’s internal PRNG — see this module’s
docs for why this is mandatory rather than defaulting to system
entropy.
Trait Implementations§
Source§impl Clone for SamplingConfig
impl Clone for SamplingConfig
Source§fn clone(&self) -> SamplingConfig
fn clone(&self) -> SamplingConfig
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more