C.W.K.
Stream
Lesson 06 of 12 · published

Vocabulary Size: 32K to 262K and the Tradeoffs

~12 min · vocabulary, scaling, multilingual

Level 0Token
0 XP0/94 lessons0/10 achievements
0/120 XP to next level120 XP to go0% complete

How big should your vocabulary be? The trend over the past five years has been clearly upward, and it's worth understanding why.

Tokenizer / vocabSizeUsed by
BERT WordPiece30,522BERT, DistilBERT
Llama 1/2 SentencePiece32,000Llama 1, Llama 2
tiktoken p50k_base50,256GPT-2, GPT-3
tiktoken cl100k_base100,256GPT-3.5, GPT-4
Llama 3 BPE128,000Llama 3, 3.1, 3.3
tiktoken o200k_base200,019GPT-4o
tiktoken o200k_harmony201,088GPT-5
Gemma 3 SentencePiece262,144Gemma 3 (140+ langs)

The economics

Bigger vocabulary → fewer tokens per sentence → cheaper inference per "useful" message. The cost is a larger embedding matrix (vocab × d_model parameters) and a larger output projection. For a 70B model with d_model=8192, going from 32K to 200K vocab adds ~1.4B parameters — under 2% of total. Trivial cost for several percent token-count savings on every query forever after.

The other reason vocabularies grew: multilingual coverage. A 32K English-centric vocab tokenizes Korean or Chinese 3-4× less efficiently than English. Gemma 3's 262K vocab targeting 140+ languages closes most of that gap.

Code

Embedding matrix cost vs vocab size·python
def embedding_params(vocab_size, d_model):
    return vocab_size * d_model

# Llama 3 8B: d_model=4096
for v in [32_000, 100_000, 128_000, 200_000, 262_144]:
    p = embedding_params(v, 4096)
    print(f"vocab {v:>7,}  embedding {p/1e6:>6.0f}M params")

# Llama 3 70B: d_model=8192 — twice the cost per vocab entry
for v in [32_000, 128_000, 262_144]:
    p = embedding_params(v, 8192)
    print(f"70B vocab {v:>7,}  embedding {p/1e9:>5.2f}B params")

External links

Exercise

Compute tokens-per-1000-English-words and tokens-per-1000-Korean-syllables for: BPE-50K (gpt-3.5), BPE-100K (cl100k_base), BPE-128K (llama-3), BPE-200K (gpt-4o). Use the same source paragraphs across all measurements. Plot the results.

Progress

Progress is local-only — sign in to sync across devices.
Spotted a bug or have feedback on this page?Report an Issue

Comments 0

🔔 Reply notifications (sign in)
Sign inPlease sign in to comment.

No comments yet — be the first.