Byte Pair Encoding

Common letter combinations need not be stored one character at a time. Byte pair encoding repeatedly joins frequent neighbouring pieces, building a vocabulary that can reuse parts across different words.

14 sections · 15 questions · 4 coding challenges

1 / 14

Could Repeated Fragments Solve the Rare-Word Problem?

BOTIE

A whole-word vocabulary has a recurring problem: names, compounds, and unfamiliar word forms keep arriving. Storing every possibility is impractical. Spelling everything one character at a time avoids some missing-word problems but makes sequences longer.

Philip Gage described byte pair encoding in 1994 as a compression method based on replacing frequent adjacent pairs. Sennrich and colleagues adapted the merging idea to subword units for neural translation in 2016, allowing rare words to be represented through reusable smaller pieces.

Start with small units that cover the training text. Count neighbouring pairs, merge a frequent pair, and repeat. Common fragments gradually become single entries, while less familiar words can remain sequences of smaller pieces. The learned merge order matters during encoding. The name alone does not tell us whether an implementation begins with bytes or characters, or how it handles a previously unseen starting symbol.

Sources for this history