pub struct SimpleTokenizerV1 { /* private fields */ }
Expand description
[Listing 2.3] Implementing a simple text tokenizer
Implementations§
Source§impl SimpleTokenizerV1
impl SimpleTokenizerV1
Sourcepub fn from_vocab(vocab: HashMap<&str, i32>) -> Self
pub fn from_vocab(vocab: HashMap<&str, i32>) -> Self
Creates a new SimpleTokenizerV1
from a vocab.
use llms_from_scratch_rs::listings::ch02::SimpleTokenizerV1;
use std::collections::HashMap;
let vocab: HashMap<&str, i32> = HashMap::from([
("this", 1_i32),
("is", 2_i32),
("a", 3_i32),
("test", 4_i32)
]);
let tokenizer = SimpleTokenizerV1::from_vocab(vocab);
Trait Implementations§
Source§impl Debug for SimpleTokenizerV1
impl Debug for SimpleTokenizerV1
Source§impl Default for SimpleTokenizerV1
impl Default for SimpleTokenizerV1
Source§fn default() -> SimpleTokenizerV1
fn default() -> SimpleTokenizerV1
Returns the “default value” for a type. Read more
Auto Trait Implementations§
impl Freeze for SimpleTokenizerV1
impl RefUnwindSafe for SimpleTokenizerV1
impl Send for SimpleTokenizerV1
impl Sync for SimpleTokenizerV1
impl Unpin for SimpleTokenizerV1
impl UnwindSafe for SimpleTokenizerV1
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> 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