A corpus has the words low (×5), lower (×2), newest (×6) and widest (×3), each split into characters. BPE merges the most frequent adjacent pair. WordPiece merges the pair with the highest score c(ab)c(a) c(b). Which pair does each choose first, and why do they differ?

Sequence models and transformers, Tokenisation
Level L3 Intermediate. Length Long. Nature Mat Mathematical.

What's being asked

Whether you can count symbol and pair frequencies and see that WordPiece scores a pair by how much more often it occurs than chance.

Key idea

BPE picks arg⁡max⁡c(ab). WordPiece picks arg⁡max⁡c(ab)c(a)c(b), a pointwise-mutual-information-like score that favours pairs whose parts rarely occur apart.

Steps

  1. Symbol counts (weighted by word frequency): l=7, o=7, w=16, e=17, r=2, n=6, s=9, t=9, i=3, d=3.
  2. Pair counts: (e,s)=9, (s,t)=9, (w,e)=8, (l,o)=7, (o,w)=7, (n,e)=6, (e,w)=6, (w,i)=3, (i,d)=3, (d,e)=3, (e,r)=2.
  3. BPE: the largest count is 9, a tie between (e,s) and (s,t). It merges one of them.
  4. WordPiece scores: (s,t)=99⋅9=0.111, (e,s)=917⋅9=0.059, (l,o)=77⋅7=0.143, (i,d)=33⋅3=0.333, (w,e)=816⋅17=0.029.
  5. WordPiece merges (i,d) first, with the highest score 0.333. Both symbols occur only together, so this pair is the most "tied" even though it is not frequent.
  6. So BPE favours raw frequency (it will build common pieces like "es" or "st"), while WordPiece favours pairs that are informative and does not let very frequent letters like e and w dominate.

Common mistakes

How long your answer should be

Half a page; 5 minutes.

Last checked on 4 December 2026.

Read this

Previous in Sequence models and transformers: Assume GPT-2 small has 12 layers, d=768, feed-forward width 3072, vocabulary 50,257 and context length 1024 with learned positional embeddings, and output weights tied to the token embedding, where each projection has a bias and each layer has two layer norms. How many parameters does it have?
Next in Sequence models and transformers: LoRA computes h=W0x+αrBAx, where B∈Rd×r is initialised to zero and A∈Rr×k is random. How do you show that at initialisation the model equals the pre-trained one, what are the gradients ∂L/∂A and ∂L/∂B at the start, and what is the α/r factor for?