pub struct SamplerBuilder { /* private fields */ }Expand description
Builder for sampling parameters with validation.
§Example
use oxibonsai_runtime::builders::SamplerBuilder;
let sampler = SamplerBuilder::new()
.temperature(0.5)
.top_k(50)
.top_p(0.95)
.repetition_penalty(1.2)
.seed(123)
.build()
.expect("valid parameters");
let params = sampler.params();
assert!((params.temperature - 0.5).abs() < f32::EPSILON);
assert_eq!(params.top_k, 50);Implementations§
Source§impl SamplerBuilder
impl SamplerBuilder
Sourcepub fn temperature(self, t: f32) -> Self
pub fn temperature(self, t: f32) -> Self
Set the temperature for softmax scaling. Must be >= 0.
Sourcepub fn repetition_penalty(self, rp: f32) -> Self
pub fn repetition_penalty(self, rp: f32) -> Self
Set repetition penalty. Must be >= 1.0.
Sourcepub fn build(self) -> RuntimeResult<Sampler>
pub fn build(self) -> RuntimeResult<Sampler>
Validate parameters and build the Sampler.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for SamplerBuilder
impl RefUnwindSafe for SamplerBuilder
impl Send for SamplerBuilder
impl Sync for SamplerBuilder
impl Unpin for SamplerBuilder
impl UnsafeUnpin for SamplerBuilder
impl UnwindSafe for SamplerBuilder
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