pub struct BeamState {
pub nodes: Vec<Vec<u32>>,
pub scores: Vec<Vec<f64>>,
pub tokens: Vec<Vec<Vec<u32>>>,
}Expand description
Live decoding state for a single batch of beam searches.
Shapes:
nodes:[batch_size][beam_width]— current trie node per beamscores:[batch_size][beam_width]— accumulated log-probabilitytokens:[batch_size][beam_width][step]— partial SID decoded so far
Fields§
§nodes: Vec<Vec<u32>>§scores: Vec<Vec<f64>>§tokens: Vec<Vec<Vec<u32>>>Implementations§
Source§impl BeamState
impl BeamState
Sourcepub fn new(batch_size: usize, beam_width: usize) -> Self
pub fn new(batch_size: usize, beam_width: usize) -> Self
Creates a blank state for batch_size queries, each with beam_width
beams, all starting at the trie root (node 0) with log-prob 0.0.
pub fn batch_size(&self) -> usize
pub fn beam_width(&self) -> usize
Sourcepub fn step(&self) -> usize
pub fn step(&self) -> usize
Returns the current decoding step (number of tokens emitted so far). Assumes all beams in batch 0 are at the same step.
Sourcepub fn flat_nodes(&self) -> Vec<u32>
pub fn flat_nodes(&self) -> Vec<u32>
Flattens nodes into a single Vec<u32> of length
batch_size * beam_width for bulk VNTK calls.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for BeamState
impl RefUnwindSafe for BeamState
impl Send for BeamState
impl Sync for BeamState
impl Unpin for BeamState
impl UnsafeUnpin for BeamState
impl UnwindSafe for BeamState
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> 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