SamplingCategory

Struct SamplingCategory 

Source
pub struct SamplingCategory {
    pub temperature: f32,
    pub top_p: f32,
    pub top_k: u32,
    pub presence_penalty: f32,
    pub frequency_penalty: f32,
    pub repetition_penalty: f32,
    pub dry_multiplier: f32,
    pub dry_base: f32,
    pub dry_allowed_length: u32,
    pub lz_penalty: f32,
    pub min_p: Option<f32>,
    pub top_n_sigma: Option<f32>,
}
Expand description

Per-category sampling defaults from MODEL.toml.

Fields§

§temperature: f32§top_p: f32§top_k: u32§presence_penalty: f32§frequency_penalty: f32§repetition_penalty: f32

Multiplicative penalty on already-seen tokens (1.0 = disabled). Populated from MODEL.toml [sampling.*].repetition_penalty via build.rs.

§dry_multiplier: f32

DRY (Don’t-Repeat-Yourself) sampler parameters. Penalises tokens that extend repeated n-grams past dry_allowed_length with an exponential dry_multiplier * dry_base^(match_len - allowed) — the targeted fix for phrase-level attractors (e.g. the ```bash cd … cargo test ``` fence-narration loop observed in Qwen3.5-35B-A3B-FP8 opencode sessions at turn ≥ 8).

presence_penalty on its own is a FLAT per-unique-token hit (does not scale with repetition count), so it can’t break a phrase attractor where individual tokens already paid their penalty once. DRY scales with the repeat-length and is the published remedy (oobabooga/text-generation-webui#5677, used in llama.cpp / Aphrodite / TabbyAPI).

dry_multiplier = 0.0 disables DRY for this category (default for every preset unless MODEL.toml sets it explicitly).

§dry_base: f32§dry_allowed_length: u32§lz_penalty: f32

LZ penalty (arXiv:2504.20131). Per-extension n-gram penalty over a 256-token rolling window. Frequency-weighted and length- scaled, so it correctly distinguishes “phrase loop” from “legitimate vocabulary reuse” without the flat-per-token presence_penalty regression. 0.0 = disabled. SGLang reference strength = 0.2 (lossless on AIME/GPQA).

§min_p: Option<f32>

Model-declared min-p, or None when MODEL.toml is silent.

Option, not f32, because absence and 0.0 mean opposite things here. The server ships --default-min-p 0.08 and every request that does not name min_p takes it, so a model whose card specifies min_p = 0 had no way to say so: [behavior].min_p_floor only ever RAISES min_p (min_p.max(floor)), and the preset did not carry the value at all. A plain f32 defaulting to 0.0 would silently strip the 0.08 floor from every model that has a [sampling.*] table, which is the opposite regression.

Some(x) outranks the CLI default and is outranked by generation_config.json — the same precedence temperature/top_k/top_p already follow. None preserves the CLI-owned behaviour exactly.

§top_n_sigma: Option<f32>

Model-declared top-n-sigma, or None when MODEL.toml is silent.

Same absence-vs-zero problem as min_p: the server ships --default-top-n-sigma 1.0, so a model whose card asks for NO sigma filter had no way to say so. Some(0.0) disables it; None leaves the CLI default owning the field.

Trait Implementations§

Source§

impl Clone for SamplingCategory

Source§

fn clone(&self) -> SamplingCategory

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for SamplingCategory

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Copy for SamplingCategory

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.