[][src]Struct rust_tokenizers::vocab::Gpt2Vocab

pub struct Gpt2Vocab {
    pub values: HashMap<String, i64>,
    pub indices: HashMap<i64, String>,
    pub unknown_value: &'static str,
    pub special_values: HashMap<String, i64>,
    pub special_indices: HashMap<i64, String>,
}

GPT2 Vocab

Vocabulary for GPT2 tokenizer. Contains the following special values:

  • BOS token
  • EOS token

Expects a JSON-format vocabulary when created from file.

Fields

values: HashMap<String, i64>

A mapping of tokens as string to indices (i.e. the encoder base)

indices: HashMap<i64, String>

A mapping of token ids to strings (i.e. the decoder base)

unknown_value: &'static str

The string to use for unknown (out of vocabulary) tokens

special_values: HashMap<String, i64>

A mapping of special value tokens as strings to IDs (i.e. the encoder base for special values), special values typically include things like BOS/EOS markers, class markers, mask markers and padding markers

special_indices: HashMap<i64, String>

A mapping of special value tokens as IDs to strings (i.e. the decoder base for special values)

Implementations

impl Gpt2Vocab[src]

pub fn bos_value() -> &'static str[src]

Returns the BOS token for GPT2 (<|endoftext|>)

pub fn eos_value() -> &'static str[src]

Returns the EOS token for GPT2 (<|endoftext|>)

Trait Implementations

impl Clone for Gpt2Vocab[src]

impl Debug for Gpt2Vocab[src]

impl MultiThreadedTokenizer<Gpt2Vocab> for Gpt2Tokenizer[src]

impl Tokenizer<Gpt2Vocab> for Gpt2Tokenizer[src]

impl Vocab for Gpt2Vocab[src]

Auto Trait Implementations

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.