pub struct BundleTokenizer { /* private fields */ }Implementations§
Source§impl BundleTokenizer
impl BundleTokenizer
Sourcepub fn try_load(dir: &Path) -> Result<Option<Self>, EngineError>
pub fn try_load(dir: &Path) -> Result<Option<Self>, EngineError>
Load from a bundle directory. Returns Ok(None) if no tokenizer.json.
pub fn from_tokenizer_json(raw: &str) -> Result<Self, EngineError>
Sourcepub fn encode(&self, text: &str) -> Result<Vec<u32>, EngineError>
pub fn encode(&self, text: &str) -> Result<Vec<u32>, EngineError>
Encode text → token ids (no extra specials; chat template is already in text).
Sourcepub fn decode(&self, ids: &[u32]) -> String
pub fn decode(&self, ids: &[u32]) -> String
Decode ids → UTF-8, skipping special tokens by default.
pub fn decode_opts(&self, ids: &[u32], skip_special: bool) -> String
pub fn is_stop(&self, id: u32) -> bool
pub fn stop_ids(&self) -> &[u32]
pub fn has_token(&self, token: &str) -> bool
Sourcepub fn chat_family_hint(&self) -> Option<&'static str>
pub fn chat_family_hint(&self) -> Option<&'static str>
Prefer tokenizer specials over a possibly-wrong Session family (serve used to hardcode gemma even for Qwen bundles).
Trait Implementations§
Source§impl Clone for BundleTokenizer
impl Clone for BundleTokenizer
Source§fn clone(&self) -> BundleTokenizer
fn clone(&self) -> BundleTokenizer
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreAuto Trait Implementations§
impl Freeze for BundleTokenizer
impl RefUnwindSafe for BundleTokenizer
impl Send for BundleTokenizer
impl Sync for BundleTokenizer
impl Unpin for BundleTokenizer
impl UnsafeUnpin for BundleTokenizer
impl UnwindSafe for BundleTokenizer
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
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