/ module 03 · Foundations
Vocabulary
A model's vocabulary is the fixed set of tokens it knows. Building it well is a balancing act between sequence length, memory and coverage. Bigger vocab = shorter sequences but a larger embedding table.
By the end you can
- Define vocabulary size, coverage and out-of-vocabulary words
- Explain the trade-off between a small and a large vocabulary
- Say why subword vocabularies rarely hit unknown words
Try this first: Move the vocab size slider down and watch coverage fall.
about 8 min hover ? for help
concept
How vocabularies are built
The simplest approach: count every word in a corpus, keep the top N most frequent. Modern tokenizers (BPE, WordPiece, Unigram) instead learn subword merges so rare words still decompose into known pieces. GPT-4 uses ~100k tokens; Llama 3 uses 128k.
vocab size
Count of unique tokens the model recognizes.
OOV
Out-of-vocabulary, meaning a word the tokenizer can't represent.
coverage
% of corpus words representable by the vocab.
Live lab · Vocabulary Builder
top 20 tokens
- #1the6
- #2a3
- #3sat2
- #4on2
- #5dog2
- #6of2
- #7tokens2
- #8cat1
- #9mat1
- #10log1
- #11quick1
- #12brown1
- #13fox1
- #14jumps1
- #15over1
- #16lazy1
- #17language1
- #18models1
- #19learn1
- #20from1
Unique words
38
Total words
50
Coverage
64.0%
Shrink the vocab to feel the trade-off: rare words drop out first.
Check yourself
Tick each one you could explain to a friend. If you can't yet, scroll back up and replay the lab.
Finished exploring?
Progress is saved only in this browser.