encyclopegia.org

Byte-pair encoding

In computing, byte-pair encoding (BPE), or digram coding, is an algorithm, first described in 1994 by Philip Gage, for encoding strings of text into smaller strings by creating and using a translation table. A slightly modified version of the algorithm is used in large language model tokenizers. The original version of the algorithm focused on compression. It replaces the highest-frequency pair of bytes with a new byte that was not contained in the initial dataset. A lookup table of the replacements is required to rebuild the initial dataset. The modified version builds "tokens" (units of recognition) that match varying amounts of source text, from single characters (including single digits or single punctuation marks) to whole words (even long compound words).

In computing, byte-pair encoding (BPE), or digram coding, is an algorithm, first described in 1994 by Philip Gage, for encoding strings of text into smaller strings by creating and using a translation table. A slightly modified version of the algorithm is used in large language model tokenizers. The original version of the algorithm focused on compression. It replaces the highest-frequency pair of bytes with a new byte that was not contained in the initial dataset. A lookup table of the replacements is required to rebuild the initial dataset. The modified version builds "tokens" (units of recognition) that match varying amounts of source text, from single characters (including single digits or single punctuation marks) to whole words (even long compound words). ==Original algorithm== The original BPE algorithm operates by iteratively replacing the most common contiguous sequences of characters in a target text with unused 'placeholder' bytes. The iteration ends when no sequences can be found, leaving the target text effectively compressed. Decompression can be performed by reversing this process, querying known placeholder terms against their corresponding denoted sequence, using a lookup table. In the original paper, this lookup table is encoded and stored alongside the compressed text. Z=aa Then the process is repeated with byte pair "ab", replacing it with "Y": ZYdZYac Y=ab Z=aa The only literal byte pair left occurs only once, and the encoding might stop here. Alternatively, the process could continue with recursive byte-pair encoding, replacing "ZY" with "X": XdXac X=ZY Y=ab Z=aa This data cannot be compressed further by byte-pair encoding because there are no pairs of bytes that occur more than once. To decompress the data, simply perform the replacements in the reverse order. Suppose we are encoding the previous example of "aaabdaaabac", with a specified vocabulary size of 6, then it would first be encoded as "0, 0, 0, 1, 2, 0, 0, 0, 1, 0, 3" with a vocabulary of "a=0, b=1, d=2, c=3". Then it would proceed as before, and obtain "4, 5, 2, 4, 5, 0, 3" with a vocabulary of "a=0, b=1, d=2, c=3, aa=4, ab=5". So far this is essentially the same as before. However, if we only had specified a vocabulary size of 5, then the process would stop at vocabulary "a=0, b=1, d=2, c=3, aa=4", so that the example would be encoded as "4, 0, 1, 2, 4, 0, 1, 0, 3". Conversely, if we had specified a vocabulary size of 8, then it would be encoded as "7, 6, 0, 3", with a vocabulary of "a=0, b=1, d=2, c=3, aa=4, ab=5, aaab=6, aaabd=7". This is not maximally compressed, because modified BPE does not aim for maximum compression. Instead, it aims for an encoding that is efficient and practical for language model training. ==See also== Re-Pair Sequitur algorithm ==References==

References

No reference rows published for this article.

Cite this article

MLA

"Byte-pair encoding." encyclopegia.org, 2026, https://encyclopegia.org/wiki/byte-pair-encoding. Accessed 24 November 2026.

Chicago

"Byte-pair encoding." encyclopegia.org. Accessed November 24, 2026. https://encyclopegia.org/wiki/byte-pair-encoding.

APA

encyclopegia.org. (2026). Byte-pair encoding. Retrieved November 24, 2026, from https://encyclopegia.org/wiki/byte-pair-encoding

Accessed November 24, 2026 · CC BY-SA 4.0 · citation page · JSON

Related articles

Holothurin

enwiki · references available

Al Loquasto

enwiki · references available

Autoimmune lymphoproliferative syndrome

enwiki · references available

Zamania

enwiki · references available

Prime farmland

enwiki · references available

Portia labiata

enwiki · references available

Taj Pul

enwiki · references available

Takhatpur

enwiki · references available

Talai

enwiki · references available

Talaja, Bhavnagar

enwiki · references available

Talbandha

enwiki · references available

Takanori Kono

enwiki · references available
CC BY-SA 4.0 · share-alike · https://en.wikipedia.org/w/index.php?oldid=1346605957 · 0.5 · snapshot enwiki-001346605957

Cite · JSON · Search

Related services and records

Services

  • Estate — measured countries, lanes and facts
  • Intel — live corroborated events
  • Legal — statutes, cases and citations
  • Encyclopedia — articles with inline sources
  • Space — launches, satellites and orbits
  • Search — federated search and reports
  • Pass — passport account and SSO
  • Corpora — read-only corpus origins
  • e01 — self-hosted corpora and tools

Text and metadata only; each target carries its own sources. Missing data is published as no-data, never estimated.