IT lexicon › AI & ML › BPE

BPE Byte Pair Encoding

AI & ML På svenska → Updated: 2026-07-29

The algorithm that splits text into subwords for almost every language model. Originally a compression method from 1994, adapted to language processing by Sennrich et al. in 2016.

Training it is simple: start with individual characters, find the most frequent adjacent pair, merge it into a new symbol, repeat until the vocabulary is the right size. Common words end up as a single token while rare ones are built from several pieces. That solves two problems at once — a word the model has never seen can still be represented, and the vocabulary needn't contain every inflected form. Byte-level BPE (GPT-2 onward) works on raw bytes and can therefore encode anything, including emoji and code. This is also where the uneven cost comes from: languages underrepresented in the training data are split into more tokens and cost more per character.

← Back to the lexicon