Struct TokEnvWithTrie

Source
pub struct TokEnvWithTrie { /* private fields */ }

Implementations§

Source§

impl TokEnvWithTrie

Source

pub fn new(base_env: TokEnv, tok_trie: TokTrie) -> Self

Trait Implementations§

Source§

impl TokenizerEnv for TokEnvWithTrie

Source§

fn tok_trie(&self) -> &TokTrie

Associated trie.
Source§

fn tokenize_bytes(&self, s: &[u8]) -> Vec<TokenId>

Tokenize a given byte sequence. It may or may not interpret <|special_tokens|> as special.
Source§

fn tokenize_bytes_marker(&self, s: &[u8]) -> (Vec<TokenId>, usize)

Tokenize a given byte sequence. It will interpret text starting with SPECIAL_TOKEN_MARKER as special tokens. Returns tokens, and number of tokens are should never be re-tokenized (because they were specified using the special token marker).
Source§

fn tokenize(&self, s: &str) -> Vec<TokenId>

Tokenize a string coming from user. It may or may not interpret <|special_tokens|> as special.
Source§

fn tokenize_special(&self, s: &str) -> Vec<TokenId>

Tokenize a string. It will interpret <|special_tokens|> as special.
Source§

fn eos_token(&self) -> TokenId

End of sentence token
Source§

fn tokenize_is_canonical(&self) -> bool

If this returns true, this tokenizer always returns canonical tokenizations and can be used for forcing tokens. Non-canonical tokenizers will typically just use TokTrie::greedy_tokenize().

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.