huggingface/tokenizersのQuicktour
https://huggingface.co/docs/tokenizers/quicktour
wikitext-103 (516MBのテキスト) を使う
wikitext-103-raw-v1.zip
Raw / character level (from The WikiText Long Term Dependency Language Modeling Dataset)
Training the tokenizer
In this tour, we will build and train a Byte-Pair Encoding (BPE) tokenizer.
違う種類のトークナイザについては Summary of the tokenizers 参照
Here, training the tokenizer means it will learn merge rules by:
トークナイザの訓練とは、トークナイザがマージのルールを学習すること
BPEのアルゴリズムを紹介している
QuicktourのTraining the tokenizerのコード
以下は流し読み
Using the tokenizer
encodeメソッド
QuicktourのPost-processing
TemplateProcessing
"[CLS] $A [SEP]" where $A represents our sentence.
Encoding multiple sentences in a batch
encode_batchメソッド
padding
Using a pretrained tokenizer