[][src]Struct rust_tokenizers::tokenizer::OpenAiGptTokenizer

pub struct OpenAiGptTokenizer { /* fields omitted */ }

GPT tokenizer

GPT tokenizer performing:

  • BaseTokenizer tokenization (see BaseTokenizer for more details)
  • BPE tokenization

Implementations

impl OpenAiGptTokenizer[src]

pub fn from_file(
    vocab_path: &str,
    merges_path: &str,
    lower_case: bool
) -> Result<OpenAiGptTokenizer, TokenizerError>
[src]

Create a new instance of a OpenAiGptTokenizer Expects a vocabulary flat file and merges file as an input.

Parameters

  • vocab_path (&str): path to the vocabulary file
  • merges_path (&str): path to the merges file (use as part of the BPE encoding process)
  • lower_case (bool): flag indicating if the text should be lower-cased as part of the tokenization

Example

use rust_tokenizers::tokenizer::{OpenAiGptTokenizer, Tokenizer};
let lower_case = false;
let tokenizer =
    OpenAiGptTokenizer::from_file("path/to/vocab/file", "path/to/merges/file", lower_case)
        .unwrap();

pub fn from_existing_vocab_and_merges(
    vocab: OpenAiGptVocab,
    merges: BpePairVocab,
    lower_case: bool
) -> OpenAiGptTokenizer
[src]

Create a new instance of a OpenAiGptTokenizer from an existing vocabulary and merges

Parameters

  • vocab (Gpt2Vocab): GPT-like vocabulary
  • merges (BpePairVocab): BPE pairs vocabulary
  • lower_case (bool): flag indicating if the text should be lower-cased as part of the tokenization

Example

use rust_tokenizers::tokenizer::{OpenAiGptTokenizer, Tokenizer};
use rust_tokenizers::vocab::{BpePairVocab, OpenAiGptVocab, Vocab};
let lower_case = false;
let vocab = OpenAiGptVocab::from_file("path/to/vocab/file").unwrap();
let merges = BpePairVocab::from_file("path/to/merges/file").unwrap();

let tokenizer = OpenAiGptTokenizer::from_existing_vocab_and_merges(vocab, merges, lower_case);

Trait Implementations

impl MultiThreadedTokenizer<OpenAiGptVocab> for OpenAiGptTokenizer[src]

impl Tokenizer<OpenAiGptVocab> for OpenAiGptTokenizer[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> Pointable for T

type Init = T

The type for initializers.

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.