Skip to main content

Sampler

Trait Sampler 

Source
pub trait Sampler:
    Debug
    + Send
    + Sync {
    // Required method
    fn apply(
        &self,
        logits: Logits<'_>,
        history: &[u32],
        state: &mut SamplerState,
        rng: &mut Philox4x32,
    );

    // Provided method
    fn name(&self) -> &'static str { ... }
}
Expand description

A logit transform + sample step. Samplers mutate the logits row in place; sample is called at the end of the chain.

Required Methods§

Source

fn apply( &self, logits: Logits<'_>, history: &[u32], state: &mut SamplerState, rng: &mut Philox4x32, )

Apply this sampler’s transformation to logits. history is the already-emitted token sequence (newest last). Some samplers (DRY, repetition penalty) need it; pure logit transforms ignore it.

Provided Methods§

Source

fn name(&self) -> &'static str

Optional name for tracing.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§