[][src]Struct rust_tokenizers::vocab::BertVocab

pub struct BertVocab {
    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>,
}

BERT Vocab

Vocabulary for BERT tokenizer. Contains the following special values:

  • CLS token
  • SEP token
  • PAD token
  • MASK token

Expects a flat text 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 BertVocab[src]

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

Returns the PAD token for BERT ([PAD])

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

Returns the SEP token for BERT ([SEP])

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

Returns the CLS token for BERT ([CLS])

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

Returns the MASK token for BERT ([MASK])

Trait Implementations

impl Clone for BertVocab[src]

impl Debug for BertVocab[src]

impl MultiThreadedTokenizer<BertVocab> for BertTokenizer[src]

impl Tokenizer<BertVocab> for BertTokenizer[src]

impl Vocab for BertVocab[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.