Skip to main content

SamplingParams

Struct SamplingParams 

Source
pub struct SamplingParams { /* private fields */ }
Expand description

Owned sampling configuration for one generation request.

Implementations§

Source§

impl SamplingParams

Source

pub fn greedy() -> Self

Returns deterministic argmax sampling with native defaults otherwise.

Source

pub fn temperature(self, value: f32) -> Self

Source

pub fn top_p(self, value: f32) -> Self

Source

pub fn top_k(self, value: i32) -> Self

Source

pub fn min_p(self, value: f32) -> Self

Source

pub fn max_tokens(self, value: u32) -> Self

Sets a finite generation limit.

Zero is invalid; use unbounded to request native unbounded generation explicitly.

Source

pub fn unbounded(self) -> Self

Removes the generation limit.

Source

pub fn seed(self, value: u64) -> Self

Source

pub fn clear_seed(self) -> Self

Source

pub fn presence_penalty(self, value: f32) -> Self

Source

pub fn frequency_penalty(self, value: f32) -> Self

Source

pub fn repetition_penalty(self, value: f32) -> Self

Source

pub fn min_tokens(self, value: u32) -> Self

Source

pub fn ignore_eos(self, value: bool) -> Self

Source

pub fn stop(self, value: impl Into<String>) -> Self

Source

pub fn stop_all<I, S>(self, values: I) -> Self
where I: IntoIterator<Item = S>, S: Into<String>,

Source

pub fn structured_output(self, value: StructuredOutput) -> Self

Source

pub fn logits_processor<F>(self, processor: F) -> Self
where F: Fn(&[i32], &mut [f32]) + Send + Sync + 'static,

Installs a host-side processor that can inspect generated token IDs and mutate one request’s logits before each sampling step.

The processor may run concurrently for different requests, so it must be Send + Sync. Cloned parameters share the processor. A panic is contained before the C boundary and reported as Error::LogitsProcessorPanicked after the bounded generation call or from crate::Request::wait. The callback state remains registered through the call or request lifetime; stale native invocations after cleanup become no-ops.

Source

pub fn clear_logits_processor(self) -> Self

Removes a previously configured custom logits processor.

Trait Implementations§

Source§

impl Clone for SamplingParams

Source§

fn clone(&self) -> SamplingParams

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: &SamplingParams) -> 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

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<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

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

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> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

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.
Source§

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

Source§

fn vzip(self) -> V