pub struct LayaTokenizer { /* private fields */ }Expand description
A loaded checkpoint tokenizer.
Implementations§
Source§impl LayaTokenizer
impl LayaTokenizer
Sourcepub fn from_file<P: AsRef<Path>>(path: P) -> Result<Self>
pub fn from_file<P: AsRef<Path>>(path: P) -> Result<Self>
Load a tokenizer from a tokenizer.json file.
Examples found in repository?
examples/tok_debug.rs (line 7)
5fn main() -> Result<(), Box<dyn std::error::Error>> {
6 let path = std::env::var("LAYA_TOK").expect("set LAYA_TOK=/path/to/tokenizer.json");
7 let tok = LayaTokenizer::from_file(&path)?;
8 println!(
9 "cls={} sep={} mask={} pad={} mask_token={:?}",
10 tok.cls_id(),
11 tok.sep_id(),
12 tok.mask_id(),
13 tok.pad_id(),
14 tok.mask_token()
15 );
16 for s in [
17 "choice question: What is this?",
18 " refund: money returned",
19 "私は二重に請求されました",
20 ] {
21 println!("{s:?} -> {:?}", tok.encode(s));
22 }
23 Ok(())
24}Trait Implementations§
Auto Trait Implementations§
impl !Freeze for LayaTokenizer
impl RefUnwindSafe for LayaTokenizer
impl Send for LayaTokenizer
impl Sync for LayaTokenizer
impl Unpin for LayaTokenizer
impl UnsafeUnpin for LayaTokenizer
impl UnwindSafe for LayaTokenizer
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
impl<T> ErasedDestructor for Twhere
T: 'static,
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