BPE grows the vocabulary by adding merges. Unigram does the opposite. Explain the difference.
Same topic, related formats. Practice these next.
Same topic, related formats. Practice these next.
BPE grows the vocabulary by merging the most frequent pair (additive, deterministic). Unigram LM shrinks a large candidate vocabulary by pruning the least useful tokens (subtractive, probabilistic, supports sampling).
Imagine two ways to build a Lego set. The first way starts with single bricks. You glue together the two bricks you use together most often, then repeat, until you have a small collection of useful chunks. That is BPE. Each turn adds one new piece. The second way works the other direction. You start with every Lego shape that exists, even strange ones, and you keep throwing out the shape you would miss least when building things. After enough rounds you are left with a smaller box of shapes that still let you build almost anything. That is Unigram LM. One adds, the other prunes. There is another difference. BPE always builds a thing one way. Unigram LM remembers how often each shape gets used, so it can offer alternative builds of the same thing, which is handy when you want to train a model on slightly varied versions of the same input.
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.
4 min: name the direction split (additive merging versus subtractive pruning), the optimization objective for each, the default and sampled segmentation behavior, the subword regularization story, and place each algorithm in the 2026 model landscape.
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.
Calling Unigram LM 'just a different scoring function for greedy merges'. It is the opposite direction: Unigram LM starts large and prunes, while BPE starts small and grows. The training procedure and the output behavior both differ.
The night-before-the-interview bullets. Scan these on the way to the call.
Primary sources. Skim if you want the original framing.