Lesson 01.05
What are tokens?
You will be able to explain why a token is not necessarily a word.
What you’ll do
- FamiliarStart with something familiar
- IdeaThe idea
- Try itTry it
- EngineeringWhy this matters in engineering
- Apply itApply it
- Check1 question, with feedback
Start with something familiar
Analogy
A delivery company packs goods into boxes. One box might hold an entire item; a large item might need several packages. Text is also divided into units before a model processes it.
The idea
A token is a unit used to represent text. It can correspond to a whole word, part of a word, punctuation or other text. A tokenizer converts text into token IDs that a model can process. Different models can use different tokenizers. The packaging analogy is only about division into units.
Try it
TokensSee text as pieces
Switch examples and count the displayed pieces.
- Piece 1: Hello
- Piece 2: “,”
- Piece 3: space, then world
- Piece 4: “!”
4 pieces displayedA · marks a space inside a piece.
IllustrativeIllustrative splits only; not measured token counts for a real model.
Why this matters in engineering
API limits and usage often depend on tokens, not simply the number of words. A long code snippet can consume many tokens.
Apply it
Exercise
Your turn
Explain why estimating API usage using only word count can be misleading.