pub struct TokenizerRegistry { /* private fields */ }Expand description
Registry of tokenizers, keyed by a registry-internal identifier.
Shared via Arc<CoreBPE> so clones are cheap and concurrent callers
never block each other during tokenization.
Implementations§
Source§impl TokenizerRegistry
impl TokenizerRegistry
Sourcepub fn with_defaults() -> Result<Self, TokenizerError>
pub fn with_defaults() -> Result<Self, TokenizerError>
Pre-register cl100k and o200k, and map every Model variant whose
tokenizer is empirically known to this registry per F-Gram findings.
§Errors
Returns TokenizerError::Library if tiktoken-rs fails to load a
tokenizer (should only happen on packaging error).
Sourcepub fn register(&mut self, model_key: &str, id: TokenizerId)
pub fn register(&mut self, model_key: &str, id: TokenizerId)
Register an additional Model-to-tokenizer mapping.
Trait Implementations§
Source§impl Clone for TokenizerRegistry
impl Clone for TokenizerRegistry
Source§fn clone(&self) -> TokenizerRegistry
fn clone(&self) -> TokenizerRegistry
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Default for TokenizerRegistry
impl Default for TokenizerRegistry
Source§fn default() -> TokenizerRegistry
fn default() -> TokenizerRegistry
Returns the “default value” for a type. Read more
Auto Trait Implementations§
impl Freeze for TokenizerRegistry
impl RefUnwindSafe for TokenizerRegistry
impl Send for TokenizerRegistry
impl Sync for TokenizerRegistry
impl Unpin for TokenizerRegistry
impl UnsafeUnpin for TokenizerRegistry
impl UnwindSafe for TokenizerRegistry
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> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
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