pub struct KimiTokenizer { /* private fields */ }Implementations§
Source§impl KimiTokenizer
impl KimiTokenizer
pub fn new( encoder: HashMap<Vec<u8>, u32>, special_tokens: HashMap<String, u32>, ) -> Result<Self, KimiTokenizerError>
pub fn vocab_size(&self) -> usize
pub fn special_token_id(&self, name: &str) -> Option<u32>
Sourcepub fn encode(&self, text: &str, specials: SpecialTokens) -> Vec<u32>
pub fn encode(&self, text: &str, specials: SpecialTokens) -> Vec<u32>
Encodes text. SpecialTokens::AsText is the real
disallowed_special=() path tokenization_kimi.py uses for
untrusted/user text: a literal <|...|> substring is BPE-encoded
like any other text, never misread as a control token.
SpecialTokens::Parse is allowed_special="all": every name
in tokenizer_config.json is carved out as its id.
pub fn decode(&self, ids: &[u32]) -> String
Trait Implementations§
Source§impl TextTokenizer for KimiTokenizer
impl TextTokenizer for KimiTokenizer
Source§fn encode(&self, text: &str, specials: SpecialTokens) -> Vec<usize>
fn encode(&self, text: &str, specials: SpecialTokens) -> Vec<usize>
specials is llama.cpp’s parse_special: whether a literal
marker in text is the token it names or the characters it is
written with. See SpecialTokens for which callers want which.fn decode(&self, ids: &[usize]) -> String
Auto Trait Implementations§
impl Freeze for KimiTokenizer
impl RefUnwindSafe for KimiTokenizer
impl Send for KimiTokenizer
impl Sync for KimiTokenizer
impl Unpin for KimiTokenizer
impl UnsafeUnpin for KimiTokenizer
impl UnwindSafe for KimiTokenizer
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> 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