pub struct StopSequenceDecoder { /* private fields */ }Expand description
A Sequence for decoding a stream of token ids into text and detecting stop sequences.
A stop sequence is either a matching token_id or a sequence of texts/strings which match.
Matches happen first at the token-level, then at the sequence-level. Hidden takes precedence
over visible. For example, if you put the same token_id in both stop_token_ids_visible and
stop_token_ids_hidden, the token_id will be treated as hidden.
Implementations§
Source§impl StopSequenceDecoder
impl StopSequenceDecoder
Sourcepub fn builder(tokenizer: Tokenizer) -> StopSequenceDecoderBuilder
pub fn builder(tokenizer: Tokenizer) -> StopSequenceDecoderBuilder
Builder object for configurating a StopSequenceDecoder
Sourcepub fn append_token_id(
&mut self,
token_id: TokenIdType,
) -> Result<SequenceDecoderOutput>
pub fn append_token_id( &mut self, token_id: TokenIdType, ) -> Result<SequenceDecoderOutput>
Add a token_id to the sequence and return the SequenceDecoderOutput
pub fn is_empty(&self) -> bool
pub fn len(&self) -> usize
pub fn is_complete(&self) -> bool
pub fn close(&mut self)
Trait Implementations§
Auto Trait Implementations§
impl !RefUnwindSafe for StopSequenceDecoder
impl !UnwindSafe for StopSequenceDecoder
impl Freeze for StopSequenceDecoder
impl Send for StopSequenceDecoder
impl Sync for StopSequenceDecoder
impl Unpin for StopSequenceDecoder
impl UnsafeUnpin 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