Skip to main content

SamplingParams

Struct SamplingParams 

Source
pub struct SamplingParams {
Show 29 fields pub max_new_tokens: Option<i64>, pub stop: Option<StrOrList>, pub stop_token_ids: Option<Vec<i64>>, pub temperature: f64, pub top_p: f64, pub top_k: i64, pub min_p: f64, pub frequency_penalty: f64, pub presence_penalty: f64, pub repetition_penalty: f64, pub min_new_tokens: i64, pub json_schema: Option<String>, pub regex: Option<String>, pub ebnf: Option<String>, pub structural_tag: Option<String>, pub ignore_eos: bool, pub skip_special_tokens: bool, pub spaces_between_special_tokens: bool, pub no_stop_trim: bool, pub thinking_budget: Option<i64>, pub custom_params: Option<Dict<String, Value>>, pub stream_interval: Option<i64>, pub logit_bias: Option<Dict<String, f64>>, pub seed: Option<i64>, pub logprobs: Option<i64>, pub n: i64, pub stop_strs: Option<StrOrList>, pub stop_str_max_len: i64, pub is_normalized: bool,
}
Expand description

SamplingParams, an untagged array-layout struct nested in a request.

This is the data only. The Python class also normalizes on construction and decode (__post_init__: greedy for a near-zero temperature, stop copied to stop_strs, …) unless is_normalized is set; decoding here applies none of that.

Fields§

§max_new_tokens: Option<i64>

Generation length limit; None leaves it to the engine.

§stop: Option<StrOrList>

API input for stop strings; normalization copies it to stop_strs.

§stop_token_ids: Option<Vec<i64>>

Token ids that end generation (a Python set).

§temperature: f64

Sampling temperature.

§top_p: f64

Nucleus sampling mass.

§top_k: i64

Top-k cutoff; -1 disables it before normalization.

§min_p: f64

Minimum probability relative to the most likely token.

§frequency_penalty: f64

Frequency penalty.

§presence_penalty: f64

Presence penalty.

§repetition_penalty: f64

Repetition penalty.

§min_new_tokens: i64

Tokens generated before stop conditions apply.

§json_schema: Option<String>

JSON schema constraint.

§regex: Option<String>

Regex constraint.

§ebnf: Option<String>

EBNF grammar constraint.

§structural_tag: Option<String>

Structural tag constraint.

§ignore_eos: bool

Keep generating past end-of-sequence tokens.

§skip_special_tokens: bool

Detokenization option, carried for the frontend.

§spaces_between_special_tokens: bool

Detokenization option, carried for the frontend.

§no_stop_trim: bool

Keep the matched stop string in the output.

§thinking_budget: Option<i64>

Reasoning-token budget.

§custom_params: Option<Dict<String, Value>>

Free-form parameters for custom logit processors.

§stream_interval: Option<i64>

Streaming chunk interval in tokens.

§logit_bias: Option<Dict<String, f64>>

Per-token logit offsets, keyed by token id as a string.

§seed: Option<i64>

Sampling seed.

§logprobs: Option<i64>

Output logprobs: None off, 0 the sampled token’s logprob.

§n: i64

OpenAI n; the engine accepts only 1.

§stop_strs: Option<StrOrList>

Stop strings after normalization.

§stop_str_max_len: i64

Longest stop string, set by normalization.

§is_normalized: bool

Whether normalization already ran on the sender.

Trait Implementations§

Source§

impl Clone for SamplingParams

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · 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
Source§

impl Default for SamplingParams

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl PartialEq for SamplingParams

Source§

fn eq(&self, other: &Self) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for SamplingParams

Source§

impl Wire for SamplingParams

Source§

fn encode(&self, encoder: &mut Encoder)

Append this value to a message.
Source§

fn decode(decoder: &mut Decoder<'_>) -> Result<Self>

Read one value of this type.

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 = !

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

fn try_from(value: U) -> Result<T, !>

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.