pub struct RuleGuidedBeamSearch { /* private fields */ }Expand description
High-level composition of a beam-search decoder, a logical constraint and a masking strategy.
Implementations§
Source§impl RuleGuidedBeamSearch
impl RuleGuidedBeamSearch
Sourcepub fn new(
config: BeamSearchConfig,
constraint: RuleConstraint,
masker: Arc<dyn LogitMasker>,
) -> Self
pub fn new( config: BeamSearchConfig, constraint: RuleConstraint, masker: Arc<dyn LogitMasker>, ) -> Self
Construct a decoder with an explicit beam-search configuration.
Sourcepub fn config(&self) -> &BeamSearchConfig
pub fn config(&self) -> &BeamSearchConfig
Read-only access to the underlying beam-search configuration.
Sourcepub fn constraint(&self) -> &RuleConstraint
pub fn constraint(&self) -> &RuleConstraint
Read-only access to the compiled constraint.
Sourcepub fn masker_name(&self) -> &'static str
pub fn masker_name(&self) -> &'static str
Return the masker’s name ("HardMask" / "SoftPenaltyMask" / …).
Sourcepub fn decode<F>(
&self,
bos_token_id: usize,
score_fn: F,
) -> RuleGuidedResult<BeamSearchResult>
pub fn decode<F>( &self, bos_token_id: usize, score_fn: F, ) -> RuleGuidedResult<BeamSearchResult>
Run the decoder.
score_fn is the same “raw logits” closure accepted by
BeamSearchDecoder::decode. The engine wraps it so that every
row of the returned [num_beams][vocab_size] logit matrix is filtered
through the configured LogitMasker before being passed on.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for RuleGuidedBeamSearch
impl !RefUnwindSafe for RuleGuidedBeamSearch
impl Send for RuleGuidedBeamSearch
impl Sync for RuleGuidedBeamSearch
impl Unpin for RuleGuidedBeamSearch
impl UnsafeUnpin for RuleGuidedBeamSearch
impl !UnwindSafe for RuleGuidedBeamSearch
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> 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