Re-exports§
pub use cache::CacheTokenUsage;pub use cache::CacheTokenUsageFn;pub use cache::CachedTokenizer;pub use cache::L1CacheStats;pub use fastokens::FastTokenizer;pub use hf::HuggingFaceTokenizer;pub use tiktoken::TikTokenTokenizer;pub use traits::DecodeResult;
Modules§
- cache
- Tokenizer caching layer (L1: prefix matching at special-token boundaries).
- fastokens
- Fastokens backend using the
fastokenscrate for high-performance BPE encoding. - hf
- tiktoken
- traits
Structs§
- Decode
Stream - DecodeStream will keep the state necessary to produce individual chunks of strings given an input stream of token_ids.
- Error
- The
Errortype, a wrapper around a dynamic error type. - Sequence
- Maintains state for an ongoing sequence of tokens and their decoded text
- Stop
Sequence Decoder - A Sequence for decoding a stream of token ids into text and detecting stop sequences.
A stop sequence is either a matching token_id or a sequence of texts/strings which match.
Matches happen first at the token-level, then at the sequence-level. Hidden takes precedence
over visible. For example, if you put the same token_id in both
stop_token_ids_visibleandstop_token_ids_hidden, the token_id will be treated as hidden. - Stop
Sequence Decoder Builder - Tokenizer
- Main tokenizer wrapper that provides a unified interface for different tokenizer implementations
- Tokenizer
Options - Construction options for
Tokenizer::from_file_with_options/create_tokenizer_from_file, applied to concrete tokenizers viatraits::Tokenizer::with_options.
Enums§
- Encoding
- Contains the results of tokenizing text: token IDs, string tokens, and their spans
- Sequence
Decoder Output - The output conditions/values of a SequenceDecoder::add_token_id operation. Result of decoding a token, indicating whether text was produced or a stop condition was met
- Tokenizer
Type - Represents the type of tokenizer being used
Functions§
- create_
tokenizer_ from_ file - Create a tokenizer from a file path to a tokenizer file. The file extension is used to determine the tokenizer type. Supported file types are:
- create_
tokenizer_ from_ file_ with_ options - Create a tokenizer from a file path to a tokenizer file with additional tokenizer option. The file extension is used to determine the tokenizer type. Supported file types are:
- file_
json_ field - log_
json_ err
Type Aliases§
- Offsets
- character offsets in the original text
- Result
Result<T, Error>- Token
IdType