Why is it not possible to simply swap a pretrained LLM's tokenizer for one with a larger vocabulary?
Same topic, related formats. Practice these next.
Same topic, related formats. Practice these next.
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.
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.
What an interviewer would ask next. Try answering before peeking at the approach.
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.