How does WordPiece decide which pair to merge, compared to BPE?
Same topic, related formats. Practice these next.
Same topic, related formats. Practice these next.
BPE merges the most frequent pair; WordPiece merges the pair with the highest likelihood gain, freq(AB) / (freq(A)·freq(B)), favoring statistical dependence over raw count.
Imagine you run a sandwich shop and want a one-tap button for the pairs people actually order together. One way is to count every time two items show up in the same order and pick the biggest count. But bread is in almost everything, so 'bread plus anything' wins by sheer volume even when nobody pairs them on purpose. WordPiece picks differently. It asks: when these two items appear together, is that more often than you'd expect if people chose them independently? Peanut butter and jelly score high because they truly travel as a pair, even if each alone is less common than bread. WordPiece prints buttons for the genuine pairings, not the items that are simply everywhere.
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: BPE raw count vs WordPiece likelihood gain + the normalized score + PMI intuition + BERT as the consumer + unknown-token risk vs byte-level BPE.
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 WordPiece 'BPE on subwords.' Both grow a vocabulary by merging, but BPE merges by raw count while WordPiece merges by a likelihood ratio that divides out how common each piece is.
The night-before-the-interview bullets. Scan these on the way to the call.
Primary sources. Skim if you want the original framing.