LLM & Transformer Fundamentals·Question 22 of 109Intermediate

What are the tradeoffs in choosing vocabulary size?

Type it the way you would explain it to an interviewer. A few sentences is enough; you can't break anything.

Model answer: the part to lead with

Vocab size trades sequence-length compression against parameter cost and tail-token quality. The industry trend tells the story: GPT-2 used 50,257; Llama 2 used 32k; Llama 3 moved to ~128k; GPT-4o's tokenizer is ~200k.

Full worked answer

Vocab size trades sequence-length compression against parameter cost and tail-token quality. The industry trend tells the story: GPT-2 used 50,257; Llama 2 used 32k; Llama 3 moved to ~128k; GPT-4o's tokenizer is ~200k.

Larger vocabulary - benefits:

  • Fewer tokens per text: more strings become single tokens, so the same document costs fewer tokens - directly cheaper inference, lower latency, and more content fits in the context window. Gains are largest for non-English languages and code, which small English-centric vocabs fragment badly. This is a major reason Llama 3 quadrupled Llama 2's vocab.
  • Fewer autoregressive steps for the same output → faster generation.

Larger vocabulary - costs:

  • Embedding + LM-head parameters scale as 2 × vocab × d_model (unless weight-tied). At d_model = 4096, a 128k vocab means ~525M embedding params and the same again for the output head - for small models this is a huge fraction of the budget (a 1B model can spend >30% of params on vocab), while for a 70B model it's noise. This is why small models almost always tie the embedding and LM head and are far more sensitive to vocab size, while large models can afford huge vocabularies.
  • Softmax compute over the vocab at every position (mostly matters for small models, and for training throughput).
  • Under-trained tail tokens: with more tokens, each rare token gets fewer training occurrences. Pathological case: "glitch tokens" (the SolidGoldMagikarp story - tokens present in the vocab but nearly absent from training data, whose embeddings are essentially uninitialized, producing bizarre behaviour when triggered).
  • Larger multilingual vocabs make each token cover more text, which slightly reduces per-token granularity the model can exploit.

Rule of thumb: vocab size should scale with model size and with the breadth of languages/domains served. There's published work on compute-optimal vocab scaling showing frontier models had been under-sizing vocabularies.

What a good answer covers

  • Vocab size trades sequence-length compression against parameter cost and tail-token quality
  • The industry trend tells the story
  • Gains are largest for non-English languages and code, which small English-centric vocabs fragment badly
  • This is a major reason Llama 3 quadrupled Llama 2's vocab
  • At d_model = 4096, a 128k vocab means ~525M embedding params and the same again for the output head -…

Key terms: Larger vocabulary - benefits · Fewer tokens per text · Larger vocabulary - costs · Embedding + LM-head parameters · Softmax compute · Under-trained tail tokens

Interviewer follow-ups to expect

  1. What are glitch tokens and what causes them?

  2. Why does weight-tying the embedding and LM head matter more for small models?

  3. How would you evaluate whether a tokenizer serves your target languages well?

Worked answer from AI-Engineer-Interview-Questions by Om (MIT), reformatted for LLM Prep · answer text last updated 6 November 2026 · scoring and review schedule by LLM Prep