pub struct SapientTokenizer {
pub bos_id: Option<u32>,
pub eos_id: Option<u32>,
pub eos_ids: Vec<u32>,
pub pad_id: Option<u32>,
/* private fields */
}Fields§
§bos_id: Option<u32>§eos_id: Option<u32>§eos_ids: Vec<u32>Every EOS/turn-end token id present in this tokenizer’s vocab.
pad_id: Option<u32>Implementations§
Source§impl SapientTokenizer
impl SapientTokenizer
Sourcepub fn from_file(path: &Path, opts: TokenizerOptions) -> Result<Self>
pub fn from_file(path: &Path, opts: TokenizerOptions) -> Result<Self>
Load from a tokenizer.json file.
Sourcepub fn from_pretrained(model_id: &str) -> Result<Self>
pub fn from_pretrained(model_id: &str) -> Result<Self>
Load from a HuggingFace model ID string (uses the HF Hub cache).
Sourcepub fn decode(&self, ids: &[u32], skip_special: bool) -> Result<String>
pub fn decode(&self, ids: &[u32], skip_special: bool) -> Result<String>
Decode token IDs back to a string.
Sourcepub fn decode_token(&self, id: u32) -> Result<String>
pub fn decode_token(&self, id: u32) -> Result<String>
Decode a single token ID to a string (for streaming).
Sourcepub fn vocab_size(&self) -> usize
pub fn vocab_size(&self) -> usize
Vocabulary size.
Auto Trait Implementations§
impl !Freeze for SapientTokenizer
impl RefUnwindSafe for SapientTokenizer
impl Send for SapientTokenizer
impl Sync for SapientTokenizer
impl Unpin for SapientTokenizer
impl UnsafeUnpin for SapientTokenizer
impl UnwindSafe for SapientTokenizer
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