#[non_exhaustive]pub enum TokenizerError {
UnknownToken(String),
InvalidVocab(String),
EncodeFailed(String),
DecodeFailed(String),
InvalidJson(String),
HfFormat(String),
IncompleteUtf8,
TemplateRender(String),
Io(String),
}Expand description
All errors that can occur during tokenization operations.
This enum is marked #[non_exhaustive] so that new variants can be added
in future minor releases without a breaking semver change. Consumers must
always include a catch-all arm when matching on TokenizerError.
Variants (Non-exhaustive)§
This enum is marked as non-exhaustive
UnknownToken(String)
A token string was not found in the vocabulary.
InvalidVocab(String)
The vocabulary data is malformed or inconsistent.
EncodeFailed(String)
Encoding of input text failed.
DecodeFailed(String)
Decoding of token IDs failed.
InvalidJson(String)
JSON deserialization failed.
HfFormat(String)
A HuggingFace tokenizer.json file could not be parsed or interpreted.
Includes missing required fields (model, vocab, merges), unsupported
BPE types, and malformed merge entries.
IncompleteUtf8
A streaming decoder received token IDs that together do not form a complete UTF-8 sequence and further bytes are required to finish.
This variant is primarily returned by crate::streaming::StreamingDecoder::finish
when the stream ends mid-character.
TemplateRender(String)
Rendering a chat-template failed (missing variable, bad syntax, …).
Io(String)
An underlying I/O operation (file read, etc.) failed.
We wrap the io::Error as a String so that TokenizerError can
continue to derive Clone, PartialEq, Eq — std::io::Error itself
does not implement those traits.
Trait Implementations§
Source§impl Clone for TokenizerError
impl Clone for TokenizerError
Source§fn clone(&self) -> TokenizerError
fn clone(&self) -> TokenizerError
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for TokenizerError
impl Debug for TokenizerError
Source§impl Display for TokenizerError
impl Display for TokenizerError
Source§impl Error for TokenizerError
impl Error for TokenizerError
1.30.0 · Source§fn source(&self) -> Option<&(dyn Error + 'static)>
fn source(&self) -> Option<&(dyn Error + 'static)>
1.0.0 · Source§fn description(&self) -> &str
fn description(&self) -> &str
use the Display impl or to_string()
Source§impl From<Error> for TokenizerError
impl From<Error> for TokenizerError
Source§impl PartialEq for TokenizerError
impl PartialEq for TokenizerError
Source§fn eq(&self, other: &TokenizerError) -> bool
fn eq(&self, other: &TokenizerError) -> bool
self and other values to be equal, and is used by ==.