pub struct TokenByteTable { /* private fields */ }Expand description
Maps every token id in a vocabulary to the raw bytes it contributes to the decoded output. Special/control tokens map to empty (they contribute no output bytes).
Implementations§
Source§impl TokenByteTable
impl TokenByteTable
Sourcepub fn from_tokenizer_json(tokenizer_json: &[u8]) -> Result<Self>
pub fn from_tokenizer_json(tokenizer_json: &[u8]) -> Result<Self>
Build from a tokenizer.json, choosing the byte-level path when possible and the SPM
fallback otherwise; refuses loudly if neither applies.
Sourcepub fn from_vocab_blob(blob: &[u8]) -> Result<Self>
pub fn from_vocab_blob(blob: &[u8]) -> Result<Self>
Parse the engine’s id→bytes vocab blob (u32 count, then per id u32 len + bytes) into a
byte table. This is the byte-level BPE path.
Sourcepub fn bytes(&self, id: u32) -> Option<&[u8]>
pub fn bytes(&self, id: u32) -> Option<&[u8]>
The raw bytes for a token id, or None if the id is out of range.
pub fn is_empty(&self) -> bool
Trait Implementations§
Source§impl Clone for TokenByteTable
impl Clone for TokenByteTable
Source§fn clone(&self) -> TokenByteTable
fn clone(&self) -> TokenByteTable
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 TokenByteTable
impl RefUnwindSafe for TokenByteTable
impl Send for TokenByteTable
impl Sync for TokenByteTable
impl Unpin for TokenByteTable
impl UnsafeUnpin for TokenByteTable
impl UnwindSafe for TokenByteTable
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