pub struct RejectionSampler { /* private fields */ }Expand description
Rejection sampler that rejects samples violating constraints
Implementations§
Source§impl RejectionSampler
impl RejectionSampler
Sourcepub fn new(config: SamplingConfig) -> Self
pub fn new(config: SamplingConfig) -> Self
Create a new rejection sampler
Sourcepub fn add_constraint(self, constraint: ConstraintFn) -> Self
pub fn add_constraint(self, constraint: ConstraintFn) -> Self
Add a constraint function
Sourcepub fn max_attempts(self, attempts: usize) -> Self
pub fn max_attempts(self, attempts: usize) -> Self
Set maximum number of rejection attempts
Sourcepub fn fallback_strategy(self, strategy: FallbackStrategy) -> Self
pub fn fallback_strategy(self, strategy: FallbackStrategy) -> Self
Set fallback strategy
Sourcepub fn sample_with_rejection(
&mut self,
logits: &Array1<f32>,
context: &[f32],
) -> InferenceResult<f32>
pub fn sample_with_rejection( &mut self, logits: &Array1<f32>, context: &[f32], ) -> InferenceResult<f32>
Sourcepub fn base_sampler(&self) -> &Sampler
pub fn base_sampler(&self) -> &Sampler
Get the base sampler
Sourcepub fn base_sampler_mut(&mut self) -> &mut Sampler
pub fn base_sampler_mut(&mut self) -> &mut Sampler
Get mutable base sampler
Sourcepub fn num_constraints(&self) -> usize
pub fn num_constraints(&self) -> usize
Get number of constraints
Auto Trait Implementations§
impl Freeze for RejectionSampler
impl !RefUnwindSafe for RejectionSampler
impl Send for RejectionSampler
impl Sync for RejectionSampler
impl Unpin for RejectionSampler
impl !UnwindSafe for RejectionSampler
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