pub struct SamplerChain { /* private fields */ }Expand description
Composable sampling pipeline.
Steps are applied sequentially to the logit vector. The first Greedy or
Mirostat2 step that yields a token terminates the pipeline. All other steps
modify the logit/probability vector in place.
§Example
use oxibonsai_runtime::sampling_advanced::{SamplerChain, SamplerStep};
let mut chain = SamplerChain::default_chat(42);
let mut logits = vec![1.0_f32, 5.0, 2.0, 3.0];
let token = chain.sample(&mut logits);
assert!(token < 4);Implementations§
Source§impl SamplerChain
impl SamplerChain
Sourcepub fn add(self, step: SamplerStep) -> Self
pub fn add(self, step: SamplerStep) -> Self
Append a step to the chain (builder pattern).
Sourcepub fn sample(&mut self, logits: &mut Vec<f32>) -> usize
pub fn sample(&mut self, logits: &mut Vec<f32>) -> usize
Sample from the given logits, applying all steps in order.
logits is consumed/mutated during processing.
Sourcepub fn default_chat(seed: u64) -> Self
pub fn default_chat(seed: u64) -> Self
Default chat preset: temperature(0.7) → top_p(0.9) → min_p(0.05).
Trait Implementations§
Source§impl Clone for SamplerChain
impl Clone for SamplerChain
Source§fn clone(&self) -> SamplerChain
fn clone(&self) -> SamplerChain
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreAuto 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> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
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