pub struct MockTokenizer { /* private fields */ }Expand description
Mock tokenizer: splits on whitespace, assigns sequential token IDs. EOS token is vocab_size - 1.
Implementations§
Trait Implementations§
Source§impl Tokenizer for MockTokenizer
impl Tokenizer for MockTokenizer
Source§fn encode(&self, text: &str, add_special: bool) -> Result<Vec<TokenId>>
fn encode(&self, text: &str, add_special: bool) -> Result<Vec<TokenId>>
Encode text to token IDs
Source§fn decode(&self, tokens: &[TokenId], _skip_special: bool) -> Result<String>
fn decode(&self, tokens: &[TokenId], _skip_special: bool) -> Result<String>
Decode token IDs to text
Source§fn decode_incremental(&self, _prev: &[TokenId], next: TokenId) -> Result<String>
fn decode_incremental(&self, _prev: &[TokenId], next: TokenId) -> Result<String>
Incremental decode: given previous tokens and new token, return only the new text
This is crucial for streaming applications to avoid re-decoding all tokens
Source§fn vocab_size(&self) -> usize
fn vocab_size(&self) -> usize
Get vocabulary size
Source§fn special_tokens(&self) -> &SpecialTokens
fn special_tokens(&self) -> &SpecialTokens
Get special tokens configuration
Source§fn token_id(&self, _text: &str) -> Option<TokenId>
fn token_id(&self, _text: &str) -> Option<TokenId>
Get token ID for a specific text (if exists in vocabulary)
Source§fn info(&self) -> TokenizerInfo
fn info(&self) -> TokenizerInfo
Get tokenizer information
Source§fn is_special_token(&self, token_id: TokenId) -> bool
fn is_special_token(&self, token_id: TokenId) -> bool
Check if token is a special token
Source§fn apply_chat_template(
&self,
messages: &[ChatMessage],
) -> Result<String, FerrumError>
fn apply_chat_template( &self, messages: &[ChatMessage], ) -> Result<String, FerrumError>
Apply chat template if supported
Auto Trait Implementations§
impl Freeze for MockTokenizer
impl RefUnwindSafe for MockTokenizer
impl Send for MockTokenizer
impl Sync for MockTokenizer
impl Unpin for MockTokenizer
impl UnsafeUnpin for MockTokenizer
impl UnwindSafe for MockTokenizer
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