Skip to main content

IncrementalTokenizer

Trait IncrementalTokenizer 

Source
pub trait IncrementalTokenizer: Tokenizer {
    type State: Send + Sync;

    // Required methods
    fn create_state(&self) -> Self::State;
    fn decode_incremental_with_state(
        &self,
        state: &mut Self::State,
        token: TokenId,
    ) -> Result<String, FerrumError>;
    fn reset_state(&self, state: &mut Self::State);
    fn get_decoded_text(&self, state: &Self::State) -> String;
}
Expand description

Incremental tokenizer state for streaming

Required Associated Types§

Source

type State: Send + Sync

Tokenizer state for incremental operations

Required Methods§

Source

fn create_state(&self) -> Self::State

Create initial state for incremental decoding

Source

fn decode_incremental_with_state( &self, state: &mut Self::State, token: TokenId, ) -> Result<String, FerrumError>

Add token to state and get incremental text

Source

fn reset_state(&self, state: &mut Self::State)

Reset state to initial condition

Source

fn get_decoded_text(&self, state: &Self::State) -> String

Get all decoded text from current state

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementations on Foreign Types§

Source§

impl IncrementalTokenizer for HuggingFaceTokenizer

Implementors§