pub struct NBestDecoder {
pub n: usize,
pub eos_id: u32,
pub max_len: usize,
pub length_penalty: f32,
}Expand description
Decoder that expands hypotheses by one step and maintains an N-best list.
Fields§
§n: usizeMaximum number of hypotheses to track.
eos_id: u32Token ID that marks end-of-sequence.
max_len: usizeMaximum generation length (inclusive).
length_penalty: f32Length-penalty exponent α used for normalised scoring.
Implementations§
Source§impl NBestDecoder
impl NBestDecoder
Sourcepub fn with_length_penalty(self, alpha: f32) -> Self
pub fn with_length_penalty(self, alpha: f32) -> Self
Set the length-penalty exponent (builder pattern).
Sourcepub fn step(
&self,
hypotheses: &[Hypothesis],
logits_per_hyp: &[Vec<f32>],
top_k: usize,
) -> Vec<Hypothesis>
pub fn step( &self, hypotheses: &[Hypothesis], logits_per_hyp: &[Vec<f32>], top_k: usize, ) -> Vec<Hypothesis>
Expand a batch of hypotheses by one step.
logits_per_hyp[i] must be the logit vector for hypotheses[i].
Returns the flat list of expanded hypotheses (up to top_k per input).
Sourcepub fn partition(hyps: Vec<Hypothesis>) -> (Vec<Hypothesis>, Vec<Hypothesis>)
pub fn partition(hyps: Vec<Hypothesis>) -> (Vec<Hypothesis>, Vec<Hypothesis>)
Partition hypotheses into (active, complete).
Auto Trait Implementations§
impl Freeze for NBestDecoder
impl RefUnwindSafe for NBestDecoder
impl Send for NBestDecoder
impl Sync for NBestDecoder
impl Unpin for NBestDecoder
impl UnsafeUnpin for NBestDecoder
impl UnwindSafe for NBestDecoder
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