Learn AI Math

Byte Pair Encoding (BPE)

What is Byte Pair Encoding (BPE)?

In one sentence: Byte Pair Encoding is a popular way to build a tokenizer by repeatedly merging the most common pairs of characters into new tokens.

It starts with single characters. Then it finds which two pieces appear next to each other most often, like "t" and "h," and merges them into "th." It keeps doing this thousands of times until it has a vocabulary of useful chunks, from letters to whole words.

What does Byte Pair Encoding (BPE) look like?

After many merges, BPE might learn tokens like "ing," "tion" and "the."

Why does Byte Pair Encoding (BPE) matter?

BPE is used by GPT models and many others, so it shapes how much your text costs in tokens.

Last updated · Fact-checked by The AI Math

Linking to this page from a lesson or article?

Like this explanation? Get one every week.

The AI Math newsletter turns confusing AI news into plain English. No hype, no jargon walls.