pub struct StopSequenceDecoder { /* private fields */ }Expand description
Decoder that handles stop sequences
Implementations§
Source§impl StopSequenceDecoder
impl StopSequenceDecoder
Sourcepub fn new(
tokenizer: Arc<dyn Tokenizer>,
config: StopSequenceConfig,
skip_special_tokens: bool,
) -> Self
pub fn new( tokenizer: Arc<dyn Tokenizer>, config: StopSequenceConfig, skip_special_tokens: bool, ) -> Self
Create a new stop sequence decoder
Sourcepub fn process_token(
&mut self,
token_id: TokenIdType,
) -> Result<SequenceDecoderOutput>
pub fn process_token( &mut self, token_id: TokenIdType, ) -> Result<SequenceDecoderOutput>
Process a single token
Sourcepub fn process_tokens(
&mut self,
token_ids: &[TokenIdType],
) -> Result<Vec<SequenceDecoderOutput>>
pub fn process_tokens( &mut self, token_ids: &[TokenIdType], ) -> Result<Vec<SequenceDecoderOutput>>
Process multiple tokens.
Early-exits after a Stopped result — remaining tokens are not processed.
Sourcepub fn flush(&mut self) -> SequenceDecoderOutput
pub fn flush(&mut self) -> SequenceDecoderOutput
Flush any held text. Returns Held if the buffer is empty.
Sourcepub fn is_stopped(&self) -> bool
pub fn is_stopped(&self) -> bool
Check if decoding has stopped
Auto Trait Implementations§
impl Freeze for StopSequenceDecoder
impl !RefUnwindSafe for StopSequenceDecoder
impl Send for StopSequenceDecoder
impl Sync for StopSequenceDecoder
impl Unpin for StopSequenceDecoder
impl UnsafeUnpin for StopSequenceDecoder
impl !UnwindSafe for StopSequenceDecoder
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