pub struct SamplerChain { /* private fields */ }Expand description
A composable pipeline of SamplerStages followed by a final selection step.
Implementations§
Source§impl SamplerChain
impl SamplerChain
Sourcepub fn push(self, stage: impl SamplerStage + 'static) -> Self
pub fn push(self, stage: impl SamplerStage + 'static) -> Self
Append a stage to the pipeline. Returns self for chaining.
Sourcepub fn sample(&self, logits: &[f32], recent_tokens: &[u32]) -> u32
pub fn sample(&self, logits: &[f32], recent_tokens: &[u32]) -> u32
Run all stages on a copy of the logits and select a token.
The original logit slice is not modified.
Sourcepub fn stage_names(&self) -> Vec<&'static str>
pub fn stage_names(&self) -> Vec<&'static str>
List the names of all stages in order.
Sourcepub fn from_config(config: &SamplerConfig) -> Self
pub fn from_config(config: &SamplerConfig) -> Self
Build a chain from a SamplerConfig, replicating the standard pipeline.
Pipeline order: logit-bias → repetition penalty → DRY → XTC → TypicalP → TopA → Eta → temperature → top-K → min-P → top-P.
Logit-bias must come first so that bans and boosts are visible to all downstream filtering stages. The five advanced stages are inserted after repetition penalty (they work on logit-scale values) but before temperature scaling (so they see the pre-temperature distribution shape).
Trait Implementations§
Auto Trait Implementations§
impl Freeze for SamplerChain
impl !RefUnwindSafe for SamplerChain
impl Send for SamplerChain
impl Sync for SamplerChain
impl Unpin for SamplerChain
impl UnsafeUnpin for SamplerChain
impl !UnwindSafe for SamplerChain
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
Mutably borrows from an owned value. Read more
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
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>
Converts
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>
Converts
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