pub struct SampleOpts {Show 23 fields
pub temperature: f32,
pub top_p: f32,
pub top_k: Option<u32>,
pub repetition_penalty: f32,
pub dynamic_temp: Option<(f32, f32)>,
pub dynamic_temp_exponent: f32,
pub typical_p: f32,
pub top_n_sigma: f32,
pub xtc_threshold: f32,
pub xtc_prob: f32,
pub dry_multiplier: f32,
pub dry_base: f32,
pub dry_allowed_length: usize,
pub dry_max_ngram: usize,
pub dry_sequence_breakers: Vec<u32>,
pub mirostat: MirostatMode,
pub mirostat_tau: f32,
pub mirostat_eta: f32,
pub mirostat_m: usize,
pub frequency_penalty: f32,
pub presence_penalty: f32,
pub repetition_window: usize,
pub min_keep: usize,
}Expand description
Sampling parameters. Greedy when temperature == 0 and no advanced
sampler is enabled. All “advanced” knobs default to off / no-op so
legacy callers see classic top-k/top-p/temperature behaviour.
into_chain() turns these flat fields into a SamplerChain that
downstream backends can execute. Ordering follows llama.cpp’s
canonical chain (penalties → temperature → top-k → typical → top-p
→ top-n-σ → xtc → mirostat).
Fields§
§temperature: f32§top_p: f32§top_k: Option<u32>§repetition_penalty: f32§dynamic_temp: Option<(f32, f32)>Dynamic temperature [min, max] gated by softmax entropy.
None ⇒ flat temperature only.
dynamic_temp_exponent: f32Exponent used by crate::samplers::DynamicTemperature.
typical_p: f32Locally-typical sampling (Meister et al. 2022). 1.0 ⇒ off.
top_n_sigma: f32Top-n-σ cutoff (Hewitt et al. 2024). 0 ⇒ off.
xtc_threshold: f32XTC: probability of dropping high-confidence top tokens.
xtc_prob: f32§dry_multiplier: f32DRY repetition penalty knobs.
dry_base: f32§dry_allowed_length: usize§dry_max_ngram: usize§dry_sequence_breakers: Vec<u32>§mirostat: MirostatModeMirostat mode + parameters.
mirostat_tau: f32§mirostat_eta: f32§mirostat_m: usize§frequency_penalty: f32Frequency / presence penalties (OpenAI-style).
presence_penalty: f32§repetition_window: usize§min_keep: usizeMinimum tokens kept by top-p / typical (avoid one-token nucleus).
Implementations§
Source§impl SampleOpts
impl SampleOpts
pub fn greedy() -> Self
pub fn nucleus(temperature: f32, top_p: f32) -> Self
pub fn is_greedy(&self) -> bool
Sourcepub fn is_classic(&self) -> bool
pub fn is_classic(&self) -> bool
True when only classic top-k/top-p/temperature are configured;
backends can take a cheap fast path in this case (e.g. the
existing sample_row CPU kernel) instead of building a chain.
Sourcepub fn into_chain(&self) -> SamplerChain
pub fn into_chain(&self) -> SamplerChain
Build the SamplerChain corresponding to these options. The
returned chain is ready to drive SamplerChain::sample against
a logits row + history. Greedy decoding produces a chain with
one Temperature{t:1e-6} step (which collapses to argmax after
softmax) — callers that want true greedy can short-circuit via
is_greedy() before building the chain.
Trait Implementations§
Source§impl Clone for SampleOpts
impl Clone for SampleOpts
Source§fn clone(&self) -> SampleOpts
fn clone(&self) -> SampleOpts
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for SampleOpts
impl Debug for SampleOpts
Auto Trait Implementations§
impl Freeze for SampleOpts
impl RefUnwindSafe for SampleOpts
impl Send for SampleOpts
impl Sync for SampleOpts
impl Unpin for SampleOpts
impl UnsafeUnpin for SampleOpts
impl UnwindSafe for SampleOpts
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more