Log inStart free
LESSON 8.C1 · 6 STAGES · 3 CONTROLS · 3 CHECKSPRO · PREVIEW

Four tokenizers on the same text

The same text, cut by four tokenizers, and what each token count costs.


Pro lesson. Stage 1 is free to watch. Pro opens all 6 stages, 3 controls and 3 checks, in this lesson and every other.

Go Pro · $8.25/mo
EXPLAINER · 8.C1 · TOKENIZER BAYENGLISH · 16 CHARACTERS · 16 BYTES
01
Stage 1 of 6 · The same text
The English text goes into four tokenizers. BPE, WordPiece and Unigram learn from one training text.
Explain it simply

On top you see the text, one box per character. Each box is as wide as the bytes the character takes in UTF-8, the common way to store text. Here every character takes one byte. The four empty lanes wait for four tokenizers.

The English text has 16 characters and 16 bytes. Four empty lanes wait under it.

text and tokensvocabularytoken counts[UNK]empty lane or fallback byte
S1h1e1␣1d1r1i1n1k1s1␣1m1i1l1k1.1Bytes · 8.01vocabulary 256BPE · 8.02vocabulary 286WordPiece · 8.03vocabulary 66Unigram · 8.04vocabulary 311the same text, four tokenizersEnglish text16 characters16 characters → 16 UTF-8 bytesS1h1e1␣1d1r1i1n1k1s1␣1m1i1l1k1.1Bytes · 8.01vocabulary 256BPE · 8.02vocabulary 286WordPiece · 8.03vocabulary 66Unigram · 8.04vocabulary 311the same text, four tokenizersEnglish text16 characters16 characters → 16 UTF-8 bytes
Toy: 8.01's texts and training text, k learned tokens
STAGE 1 / 6
MATH · STAGE 1HOVER A SYMBOL OR A SHAPE
nbyte=∑c∣UTF-8(c)∣\sy{b}{data}{n_{\text{byte}}} = \sum_{c} \lvert \text{UTF-8}(c) \rvert
nbyte=16⋅1=16n_{\text{byte}} = 16 \cdot 1 = 16

The byte count adds the UTF-8 bytes of each character.

Common mix-ups

MYTHFewer tokens always means a better tokenizer.

The fix, and 1 more mix-up with the diagram to show them, come with Pro.

Predict, then reveal
3 CHECKS · PRO
Q01If Hindi and code join the training text, does BPE need fewer tokens for the Hindi text?

Make your guess, then test it in the diagram. All 3 checks come with Pro.

PRO LESSON · YOU WATCHED STAGE 1 OF 6
Unlock the full explainer
  • 5 more stages and 3 live controls
  • 2 mix-up cards and 3 predict-then-reveal checks
  • Watch it as a narrated video, in three voices
  • Every Pro lesson and capstone · 656 in total

$99 a year, or $15 a month. Cancel any time.