pub enum Encoding {
Hf(Box<Encoding>),
Sp(Vec<TokenIdType>),
Tiktoken(Vec<TokenIdType>),
}Expand description
Contains the results of tokenizing text: token IDs, string tokens, and their spans
Variants§
Hf(Box<Encoding>)
Hugging Face
Sp(Vec<TokenIdType>)
Sentence Piece
Tiktoken(Vec<TokenIdType>)
Tiktoken (for GPT models) - now uses u32 in tiktoken-rs 0.7.0
Implementations§
Source§impl Encoding
impl Encoding
Sourcepub fn token_ids(&self) -> &[TokenIdType] ⓘ
pub fn token_ids(&self) -> &[TokenIdType] ⓘ
Returns a reference to token IDs - zero-copy operation
Sourcepub fn token_ids_ref(&self) -> &[TokenIdType] ⓘ
👎Deprecated since 0.1.0: Use token_ids() instead
pub fn token_ids_ref(&self) -> &[TokenIdType] ⓘ
Deprecated: Use token_ids() instead (kept for compatibility)
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Encoding
impl RefUnwindSafe for Encoding
impl Send for Encoding
impl Sync for Encoding
impl Unpin for Encoding
impl UnwindSafe for Encoding
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> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
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