Skip to main content

TokenizerFactory

Trait TokenizerFactory 

Source
pub trait TokenizerFactory: Send + Sync {
    // Required methods
    fn load_from_file<'life0, 'life1, 'async_trait>(
        &'life0 self,
        path: &'life1 str,
    ) -> Pin<Box<dyn Future<Output = Result<Box<dyn Tokenizer>>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait;
    fn load_from_bytes<'life0, 'life1, 'async_trait>(
        &'life0 self,
        data: &'life1 [u8],
    ) -> Pin<Box<dyn Future<Output = Result<Box<dyn Tokenizer>>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait;
    fn load_from_hub<'life0, 'life1, 'life2, 'async_trait>(
        &'life0 self,
        repo_id: &'life1 str,
        revision: Option<&'life2 str>,
    ) -> Pin<Box<dyn Future<Output = Result<Box<dyn Tokenizer>>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait,
             'life2: 'async_trait;
    fn create_from_config<'life0, 'life1, 'async_trait>(
        &'life0 self,
        config: &'life1 TokenizerConfig,
    ) -> Pin<Box<dyn Future<Output = Result<Box<dyn Tokenizer>>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait;
    fn supported_types(&self) -> Vec<TokenizerType>;
}
Expand description

Tokenizer factory for creating tokenizer instances

Required Methods§

Source

fn load_from_file<'life0, 'life1, 'async_trait>( &'life0 self, path: &'life1 str, ) -> Pin<Box<dyn Future<Output = Result<Box<dyn Tokenizer>>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Load tokenizer from file path

Source

fn load_from_bytes<'life0, 'life1, 'async_trait>( &'life0 self, data: &'life1 [u8], ) -> Pin<Box<dyn Future<Output = Result<Box<dyn Tokenizer>>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Load tokenizer from bytes

Source

fn load_from_hub<'life0, 'life1, 'life2, 'async_trait>( &'life0 self, repo_id: &'life1 str, revision: Option<&'life2 str>, ) -> Pin<Box<dyn Future<Output = Result<Box<dyn Tokenizer>>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait,

Load tokenizer from Hugging Face Hub

Source

fn create_from_config<'life0, 'life1, 'async_trait>( &'life0 self, config: &'life1 TokenizerConfig, ) -> Pin<Box<dyn Future<Output = Result<Box<dyn Tokenizer>>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Create tokenizer from configuration

Source

fn supported_types(&self) -> Vec<TokenizerType>

Get supported tokenizer types

Implementors§