Log inStart free
LESSON 8.01 · 6 STAGES · 2 CONTROLS · 3 CHECKSPRO · PREVIEW

Character, byte and word tokenization

Watch one text become characters, bytes and words, each with its own IDs.


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

Go Pro · $8.25/mo
EXPLAINER · 8.01 · TOKENIZER BAYENGLISH · 16 CHARACTERS
01
Stage 1 of 6 · The text
A model reads numbers, not letters. A tokenizer splits the text into tokens and gives each an ID.
Explain it simply

At the top you see an English sentence. A model can't read letters, it only works with numbers. So the first job is to cut the text into pieces called tokens. Each piece gets a number, its ID. The next three stages show three ways to cut it.

The text "She drinks milk." has 16 characters.

text and tokenstoken IDsvocabulary sizeUNK, ID 0
the texttextShe drinks milk.English: 16 characters, 16 bytesthe texttextShe drinks milk.English: 16 characters, 16 bytes
Toy: 3 short texts; vocabularies from 6 or 12 training lines
STAGE 1 / 6
MATH · STAGE 1HOVER A SYMBOL OR A SHAPE
text→[id1,…,idn]\sy{t}{data}{\text{text}} \to [\sy{id}{out}{\text{id}_1}, \dots, \sy{id}{out}{\text{id}_n}]
English: 16 characters\text{English: } 16\ \text{characters}

A tokenizer maps the text to a list of IDs.

Common mix-ups

MYTHA character tokenizer never needs UNK.

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

Predict, then reveal
3 CHECKS · PRO
Q01The Hindi sentence has 15 characters. How many bytes does UTF-8 need for it?

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 2 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.