SamplingParams

Struct SamplingParams 

Source
pub struct SamplingParams {
Show 18 fields pub temperature: f32, pub top_k: u32, pub top_p: f32, pub top_n_sigma: f32, pub min_p: f32, pub logit_bias: Vec<(u32, f32)>, pub repetition_penalty: f32, pub repetition_penalty_window: u32, pub presence_penalty: f32, pub frequency_penalty: f32, pub lz_penalty: f32, pub dry_multiplier: f32, pub dry_base: f32, pub dry_allowed_length: u32, pub dry_sequence_breakers: Vec<u32>, pub max_tokens: usize, pub stop_token_ids: Vec<u32>, pub seed: Option<u64>,
}
Expand description

2026-09-25: Sampling parameters for a request.

Fields§

§temperature: f32

2026-09-25: Temperature. 0.0 is greedy (is_greedy).

§top_k: u32

2026-09-25: Top-k: keep only the k highest-probability tokens. 0 disables it.

§top_p: f32

2026-09-25: Top-p (nucleus): keep the smallest set of tokens whose cumulative probability reaches p. 1.0 or more disables it.

§top_n_sigma: f32

2026-09-25: Top-n-sigma: before temperature scaling, drop tokens whose logit is below mean - n*sigma. 0.0 disables it.

§min_p: f32

2026-09-25: Min-p: keep tokens with prob >= min_p * max_prob (post-softmax). 0.0 disables it.

§logit_bias: Vec<(u32, f32)>

2026-09-25: Per-token logit bias as (token_id, bias) pairs, added after the penalties and before any filter.

§repetition_penalty: f32

2026-09-25: Repetition penalty: for every occurrence of a token in the window, a positive logit is divided by it and a non-positive one multiplied. 1.0 and values <= 0.0 disable it.

§repetition_penalty_window: u32

2026-09-25: Window, in tokens, for the repetition, presence and frequency penalties. 0 uses the whole history.

§presence_penalty: f32

2026-09-25: Presence penalty: subtracted once from the logit of each token that appears in the window. 0.0 disables it.

§frequency_penalty: f32

2026-09-25: Frequency penalty: subtracted from a token’s logit once per occurrence in the window. 0.0 disables it.

§lz_penalty: f32

2026-09-25: Strength of apply_lz_penalty. Values <= 0.0 disable it.

§dry_multiplier: f32

2026-09-25: Multiplier of the DRY (“don’t repeat yourself”) penalty, apply_dry_penalty. Values <= 0.0 disable it.

§dry_base: f32

2026-09-25: DRY base: penalty = multiplier * base^(match_len - allowed_len).

§dry_allowed_length: u32

2026-09-25: DRY allowed length: only matches longer than this are penalised.

§dry_sequence_breakers: Vec<u32>

2026-09-25: DRY sequence breakers: token ids at which a match stops.

§max_tokens: usize

2026-09-25: Maximum tokens to generate.

§stop_token_ids: Vec<u32>

2026-09-25: Stop token ids.

§seed: Option<u64>

2026-09-25: RNG seed. Some seeds a StdRng for each draw; None uses the thread RNG.

Implementations§

Source§

impl SamplingParams

Source

pub fn greedy(max_tokens: usize) -> Self

2026-09-25: Greedy sampling with every filter and penalty neutral.

Source

pub fn is_greedy(&self) -> bool

Trait Implementations§

Source§

impl Clone for SamplingParams

Source§

fn clone(&self) -> SamplingParams

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 SamplingParams

Source§

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

Formats the value using the given formatter. Read more

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.

§

impl<T> Instrument for T

§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided [Span], returning an Instrumented wrapper. Read more
§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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.
§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

§

fn vzip(self) -> V

§

impl<T> WithSubscriber for T

§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,