Why is it not possible to simply swap a pretrained LLM's tokenizer for one with a larger vocabulary?
A pretrained tokenizer is frozen because the embedding matrix and lm_head are indexed by token ID; changing the vocabulary remaps IDs and points every learned weight at the wrong token.
Imagine a library where every book has a numbered shelf, and the librarian has memorized exactly which book sits at each number. Now someone renumbers all the shelves overnight. The librarian still walks to the same numbers, but every shelf now holds a different book, so every request comes back wrong. The model's tokenizer is that numbering scheme. The learned embeddings are the librarian's memory of what lives at each number. Swap the tokenizer and you renumber the shelves, but the model keeps reaching for the old numbers, so it pulls the wrong meaning every single time.
Detailed answer & concept explanation~4 min readEverything you need to truly understand this topic: intuition, mechanics, step by step explanation, code, formulas, and worked example. Click to expand.
Everything you need to truly understand this topic: intuition, mechanics, step by step explanation, code, formulas, and worked example. Click to expand.
Everything you need to truly understand this topic: intuition, mechanics, step by step explanation, code, formulas, and worked example.
Everything important, quickly.
3 min: vocab_size lives in two tensors + token IDs are addresses + remap breaks lookups + new rows untrained + expansion vs adaptation vs retrain + why it is sticky.
Real products, models, and research that use this idea.
- OpenAI shipped o200k_base as a new tokenizer for GPT-5.5 rather than retrofitting cl100k_base into older checkpoints, because the embedding and head weights are tied to the original ID layout.
- Meta's Llama 4 line uses an expanded multilingual vocabulary chosen before pretraining, since the tokenizer cannot be changed once the Llama embedding matrix is trained.
- Teams adapting an English Llama checkpoint to a new language commonly use embedding initialization by averaging plus continued pretraining instead of swapping tokenizers outright.
What an interviewer would ask next. Try answering before peeking at the approach.
QSuppose you only want to add 5,000 new tokens for a new domain without disturbing existing behavior. How do you do it?
QHow would you initialize the embeddings for brand-new tokens so continued training converges faster?
Don't say thisRed flags and common mistakes that signal junior thinking. Click to expand.
Red flags and common mistakes that signal junior thinking. Click to expand.
Thinking the blocker is memory or licensing, when the real issue is that token IDs remap and the learned embedding rows no longer line up with the tokens they were trained on.
The night-before-the-interview bullets. Scan these on the way to the call.
Primary sources. Skim if you want the original framing.
Same topic, related formats. Practice these next.