pub struct Tokenizer {
pub cls_token: String,
pub sep_token: String,
pub pad_token: String,
pub mask_token: String,
pub cls_token_id: u32,
pub sep_token_id: u32,
pub pad_token_id: u32,
pub mask_token_id: u32,
/* private fields */
}Expand description
A loaded tokenizer plus the four special tokens upstream requires.
Fields§
§cls_token: String§sep_token: String§pad_token: String§mask_token: String§cls_token_id: u32§sep_token_id: u32§pad_token_id: u32§mask_token_id: u32Implementations§
Source§impl Tokenizer
impl Tokenizer
Sourcepub fn from_dir(dir: impl AsRef<Path>) -> Result<Tokenizer, Error>
pub fn from_dir(dir: impl AsRef<Path>) -> Result<Tokenizer, Error>
Load tokenizer.json and tokenizer_config.json from a directory.
Sourcepub fn encode(&self, text: &str) -> Result<Vec<u32>, Error>
pub fn encode(&self, text: &str) -> Result<Vec<u32>, Error>
Encode without special tokens, as every upstream call site does.
pub fn vocab_size(&self) -> usize
Trait Implementations§
Auto Trait Implementations§
impl !Freeze for Tokenizer
impl RefUnwindSafe for Tokenizer
impl Send for Tokenizer
impl Sync for Tokenizer
impl Unpin for Tokenizer
impl UnsafeUnpin for Tokenizer
impl UnwindSafe for Tokenizer
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> DropFlavorWrapper<T> for T
impl<T> DropFlavorWrapper<T> for T
impl<T> ErasedDestructor for Twhere
T: 'static,
Source§impl<T, W> HasTypeWitness<W> for Twhere
W: MakeTypeWitness<Arg = T>,
T: ?Sized,
impl<T, W> HasTypeWitness<W> for Twhere
W: MakeTypeWitness<Arg = T>,
T: ?Sized,
Source§impl<T> Identity for Twhere
T: ?Sized,
impl<T> Identity for Twhere
T: ?Sized,
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