pub struct TikTokenTokenizer { /* private fields */ }Implementations§
Source§impl TikTokenTokenizer
impl TikTokenTokenizer
Sourcepub fn from_file(
path: &str,
pattern: &str,
special_tokens: FxHashMap<String, u32>,
) -> Result<Self>
pub fn from_file( path: &str, pattern: &str, special_tokens: FxHashMap<String, u32>, ) -> Result<Self>
Create a TikTokenTokenizer from a tiktoken model file.
§Arguments
path- Path to the.modelor.tiktokenfile (base64 rank-per-line format)pattern- BPE regex pattern stringspecial_tokens- Map of special token strings to their IDs
Sourcepub fn from_file_auto(path: &str) -> Result<Self>
pub fn from_file_auto(path: &str) -> Result<Self>
Create a TikTokenTokenizer from a tiktoken model file, auto-detecting
the BPE pattern from config.json and special tokens from tokenizer_config.json.
The tiktoken file and config files must be in the same directory.
Sourcepub fn special_tokens(&self) -> &[String]
pub fn special_tokens(&self) -> &[String]
Atomic special-token strings registered with the underlying TikToken BPE.
CoreBPE::encode_with_special_tokens recognizes these strings outside ordinary
BPE. For non-overlapping token spellings, splitting immediately after a match
preserves tokenization.
Trait Implementations§
Source§impl Decoder for TikTokenTokenizer
impl Decoder for TikTokenTokenizer
fn decode( &self, token_ids: &[TokenIdType], skip_special_tokens: bool, ) -> Result<DecodeResult>
Source§impl Encoder for TikTokenTokenizer
impl Encoder for TikTokenTokenizer
Source§impl Tokenizer for TikTokenTokenizer
impl Tokenizer for TikTokenTokenizer
Source§fn with_options(self, options: TokenizerOptions) -> Selfwhere
Self: Sized,
fn with_options(self, options: TokenizerOptions) -> Selfwhere
Self: Sized,
Apply construction-time
TokenizerOptions. Read moreAuto Trait Implementations§
impl Freeze for TikTokenTokenizer
impl RefUnwindSafe for TikTokenTokenizer
impl Send for TikTokenTokenizer
impl Sync for TikTokenTokenizer
impl Unpin for TikTokenTokenizer
impl UnsafeUnpin for TikTokenTokenizer
impl UnwindSafe for TikTokenTokenizer
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> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
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