How big should the vocabulary be?

A bigger vocabulary packs more text into each token, so sequences get shorter and every language gets cheaper. But each extra token adds a row to the embedding table and a score the model must compute at every step, and rare tokens get too little training. Models moved from 32k–50k tokens to 128k–262k as they grew.

Key idea
Vocabulary V costs V × d parameters for embeddings (twice if untied) and V × d multiply-adds per token for the output; it buys fewer tokens per text, with diminishing returns
Real world
A phrasebook. A thin one has only common words, so you spell out everything else letter by letter. A thick one has whole phrases, so you say more with each lookup, but it is heavier to carry and many pages are never used.
In an LLM
Llama 2 had 32,000 tokens, Llama 3 has 128,256. The same English text takes about 12% fewer tokens and Hindi less than half as many, but Llama 3 8B spends 1.05 billion parameters, 13% of the model, on its two vocabulary-sized matrices.

Two ends of a dial

The first tokenization page set out the extremes: bytes give a tiny vocabulary and very long sequences, whole words give short sequences and a vocabulary that never ends. lets you pick any size in between by choosing when to stop merging. This page is about where to stop.

The size VV appears in exactly two places in a transformer:

  • The embedding table at the input: one row of dd numbers per token, so V×dV \times d parameters (the embeddings page shows how it is used).
  • The output layer (the unembedding): one score per token at every position, computed by multiplying the final vector by another V×dV \times d matrix. Some models reuse the embedding table here (), most large ones don’t.

Everything else in the model (attention, MLPs, norms) does not depend on VV at all.

What a bigger vocabulary costs

model width d = 768
embedding table V × d38.6M
+ output (shared)0
memory in bf160.08 GB
output multiply-adds per token38.6M
share of GPT-2 small31.0%
Loading GPT-2 data…
bytes per token on held-out text (left axis)median times each token appears in training (right axis, log)
At 50,257 tokens the embedding table alone holds 38.6M numbers. Every generated token also pays 38.6M multiply-adds just to score the whole vocabulary. Our tiny training corpus can’t support a vocabulary this big; real tokenizers are trained on far more text.
Slide the vocabulary size, or pick a real model. The numbers above the chart are exact for the chosen shape. The chart is a real experiment: byte-level BPE tokenizers of each size trained on 5.6 MB of public-domain novels and tested on a held-out book.

Four costs grow with VV:

  1. Parameters. V×dV \times d for the input table, the same again for an untied output layer. For a small model this dominates: in Gemma 3 1B the 262,144 × 1,152 table is 302 million parameters, 30% of the model. In Llama 3 70B the two 128,256 × 8,192 matrices are 2.1 billion, only 3%.
  2. Compute at the output. Every position computes VV scores, each a dot product of length dd: about V×dV \times d multiply-adds per token, then a softmax over VV entries. During training the full T×VT \times V matrix of logits also has to be stored, which for long sequences is gigabytes; training code splits it into chunks.
  3. Rare tokens get little training. Each token’s embedding is only updated when that token appears. Split the same text among more tokens and each one is seen less. In the chart, our 5.6 MB tokenizer experiment shows the typical token appearing about 300 times at a 2,000-token vocabulary but only once at 50,000. Real models train on trillions of tokens, which is why they can afford big vocabularies, but the rarest entries can still end up as glitch tokens.
  4. The tokenizer itself. A bigger vocabulary needs more merges learned from more text, and its rare tokens reflect whatever happened to be in that text.

What it buys

The benefit is compression: more bytes of text per token. Shorter sequences mean:

  • more text fits in the context window,
  • attention, whose cost grows with the square of the length, gets cheaper,
  • generation takes fewer steps for the same answer,
  • and each prediction covers more meaning, so the model has fewer, more informative steps to learn.

The blue curve shows the catch: compression improves quickly at first, then flattens. In our experiment going from 1,000 to 4,000 tokens raises bytes per token from 2.7 to 3.5, while going from 16,000 to 50,000 only adds 0.1. English is mostly covered by the first few tens of thousands of tokens. The extra tokens in modern vocabularies are mostly for other languages and for code.

Vocabulary sizes over time

Llama 3 · Apr 2024 · 128,256 tokens · cl100k + 28k more
From 2019 to 2023 most English-first models used 32k to 50k tokens. Since 2024 almost every new model uses 128k to 262k, mainly to cover more languages and code with fewer tokens. BLOOM and Gemma were early: both were built to be multilingual.
Rows in each model’s embedding matrix, read from its published config or tokenizer (some models pad the table to a round number). Hover or tap a dot.

Two things drove the jump around 2024:

  • Models got bigger. In a 70B model the vocabulary matrices are a few per cent of the parameters, so a bigger vocabulary is cheap. Scaling studies found that the best vocabulary grows with model size, and that most models had been using vocabularies smaller than optimal (Tao et al., 2024).
  • Many languages. A model trained on dozens of languages and lots of code needs tokens for all of them, or those users pay several times more for the same text.

The cost of a language

Tokens are what users pay for, what fills the context window, and what each generation step produces. If a tokenizer was built mostly from English, other languages fall apart into small pieces. Here is the same sentence, the first article of the Universal Declaration of Human Rights, in twelve languages:

Loading GPT-2 data…

With GPT-2’s tokenizer the Hindi sentence takes 294 tokens against 33 for English, almost 9 times as many. Hindi speakers would get a ninth of the text into the same context, pay nine times as much per sentence, and wait nine times as long for an answer. GPT-4o’s and Gemma 3’s much larger, multilingual vocabularies bring the same sentence down to 54 and 45 tokens. The gap has shrunk a lot but not closed: in the newest tokenizers Greek still costs about twice as much as English, and Hindi and Japanese between 1.3 and 2.8 times, depending on the tokenizer.

The number of tokens per word is sometimes called a tokenizer’s fertility. Petrov et al. (2023) measured it across languages and found differences of up to 15 times for the same content in early tokenizers.

example · a mobile phone plan

Imagine a phone plan that charges per syllable. English speakers pay a little; a language with long words written in a script the network barely supports pays several times more for the same message. Nobody set out to charge them more; the price list was simply written for English.

example · the same prompt in Hindi

A Hindi-speaking user sends GPT-2 the sentence above. It costs 294 tokens, so a 1,024-token context holds three such sentences; in English it would hold 31. With GPT-4o’s tokenizer the Hindi sentence is 54 tokens, and the context holds far more. A bigger, more multilingual vocabulary directly made the model cheaper and more capable in that language.

Choosing a size today

There is no single right answer, but the pattern in 2025–2026 models is clear:

Model sizeTypical vocabularyWhy
Small, English-first (GPT-2, Llama 2)32k–50kEmbeddings are a large share of a small model
Large, multilingual (Llama 3, DeepSeek-V3, Qwen3)128k–152kCheap relative to the model, much better compression
Very multilingual (Gemma 3 and 4, Qwen3.5)248k–262kMany scripts; often tied embeddings to save memory

Small models in families with huge vocabularies, such as Gemma 3 1B, pay a large share of their parameters for it, and tie their input and output embeddings to halve the cost.

going deeper

The cost in formulas

With vocabulary VV, model width dd and sequence length TT:

paramsvocab=Vd  (tied)or2Vd  (untied),FLOPsoutput≈2 TVd\text{params}_{\text{vocab}} = V d \;(\text{tied}) \quad\text{or}\quad 2 V d \;(\text{untied}), \qquad \text{FLOPs}_{\text{output}} \approx 2\, T V d

The output layer’s FLOPs compare with roughly 24 Td224\, T d^2 for the rest of one transformer layer (attention projections plus a 4× MLP), so the vocabulary is like adding V/(12d)V / (12 d) extra layers of compute. For GPT-2 small that is 50257/9216≈5.550257 / 9216 \approx 5.5 layers on top of 12; for Llama 3 70B (whose layers are a little different) it works out at about 1.2 layers on top of 80.

Bytes per token bb sets the number of tokens for a text of NN bytes, T=N/bT = N / b, so attention’s T2T^2 term shrinks with 1/b21/b^2.

Our experiment

The chart uses byte-level BPE tokenizers trained with Hugging Face tokenizers on eight public-domain novels from Project Gutenberg (5.6 MB), tested on two held-out books (Alice in Wonderland and The Yellow Wallpaper). It is far smaller than real tokenizer training, so the curve flattens and the token counts drop earlier than they would for a production tokenizer, but the shape is the same.

In papers

Related

  • why-tokens - A model needs a fixed list of units to read and write. Characters make the text very long; whole words need a huge list and still meet words they have never seen. Subword tokens sit in between, and every modern LLM uses them.
  • bpe - BPE builds a vocabulary by starting from single characters and repeatedly merging the most frequent adjacent pair into a new token. The ordered list of merges is the tokenizer. To encode new text, cut it into chunks with a regular expression, then replay the merges inside each chunk.
  • tokenizer-quirks - A model never sees letters or digits, only token IDs. That one fact explains a surprising list of failures: shaky arithmetic, miscounted letters, words that change meaning with a space or a capital letter, and “glitch tokens” that made GPT-3 behave strangely. Here are real examples from seven tokenizers.
  • embeddings - A token ID is just a name. The model turns it into a vector by looking up one row of a big learned table, the embedding matrix. Training places tokens that are used alike near each other, so the table ends up holding a map of meaning. Here is the lookup step by step, and GPT-2’s real table.
  • unembedding - At the top of the stack, the last token’s vector is normalised and multiplied by one big matrix that gives a score to every token in the vocabulary. Softmax turns the scores into probabilities. Applying the same read-out to the middle layers, the logit lens, shows the prediction taking shape.