pub struct TokenId(/* private fields */);Expand description
Represents a unique identifier for a token.
Token IDs 0-255 are reserved for single-byte tokens (raw bytes). IDs 256 and above are used for merged tokens created during BPE training.
Implementations§
Source§impl TokenId
impl TokenId
Sourcepub fn new(value: u32) -> Self
pub fn new(value: u32) -> Self
Creates a new TokenId with the given value.
§Arguments
value- The raw numeric value for this token ID.
Sourcepub fn for_new_token(value: u32) -> Self
pub fn for_new_token(value: u32) -> Self
Creates a TokenId for a newly merged token.
This offsets the value by 256 to avoid colliding with the reserved single-byte token IDs (0-255).
§Arguments
value- The merge index (0-based), which will be offset by 256.
Trait Implementations§
Source§impl Ord for TokenId
impl Ord for TokenId
Source§impl PartialOrd for TokenId
impl PartialOrd for TokenId
impl Copy for TokenId
impl Eq for TokenId
impl StructuralPartialEq for TokenId
Auto Trait Implementations§
impl Freeze for TokenId
impl RefUnwindSafe for TokenId
impl Send for TokenId
impl Sync for TokenId
impl Unpin for TokenId
impl UnwindSafe for TokenId
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> 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