BPE and WordPiece both merge subwords. What is the one thing they disagree on?
BPE picks the next merge by raw pair frequency; WordPiece picks the merge that maximally increases corpus likelihood, scored as freq(AB) over freq(A) times freq(B).
Picture a kid stacking blocks. Both kids start with a pile of letter blocks and a rule: each turn, glue two blocks together to make a bigger block, and add the new shape to your toolbox. The first kid (BPE) glues whichever two blocks happen to sit next to each other most often. Simple counting. The second kid (WordPiece) is fussier. It only glues two blocks together if the pair shows up much more often than you would expect from how often each block shows up on its own. That ratio rewards merges that are genuinely surprising. After many turns, both kids have a toolbox of bigger blocks they can use to build any word. They tend to pick similar blocks for common words but diverge on rarer combinations, which is why a text tokenized with BPE and the same text tokenized with WordPiece end up looking subtly different.
Detailed answer & concept explanation~6 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.
4 min: state the shared training skeleton, name BPE's frequency criterion, name WordPiece's likelihood criterion with the freq(AB) over freq(A) times freq(B) ratio, explain why the ratio rewards surprising merges, and place both algorithms in the 2026 production landscape with one or two model examples each.
Real products, models, and research that use this idea.
- GPT-5.5 and o3 use BPE via tiktoken's o200k_base encoding with a 200K vocabulary; no WordPiece anywhere in the OpenAI stack in 2026.
- Llama 3 and Llama 4 use BPE with a 128K vocabulary, having switched away from the SentencePiece tokenizer used in Llama 2.
- BERT, DistilBERT, and the legacy encoder family still ship with WordPiece tokenizers; this is the main place WordPiece appears in 2026 production code.
- The HuggingFace tokenizers library exposes both BPE and WordPiece as first-class training algorithms, which is how the two stay accessible side by side.
What an interviewer would ask next. Try answering before peeking at the approach.
QWhere does the freq(AB) over freq(A) times freq(B) formula come from?
QWhy have most generative LLMs converged on BPE rather than WordPiece?
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.
Saying BPE and WordPiece differ in how they segment at inference time. They differ in how they pick merges during training; both apply learned merges greedily at encoding time.
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.