Overview
Byte Pair Encoding builds a compact subword or byte-level vocabulary by merging the most common pair at each step.
Repeatedly replaces frequent adjacent symbol pairs with new symbols.
Compact metadata for implementation and discovery.
Byte Pair Encoding builds a compact subword or byte-level vocabulary by merging the most common pair at each step.
Quick facts
Runtime and memory behavior at a glance.
Best
O(n)
Average
O(k n)
Worst
O(k n)
Space
O(k)
best_pair = argmax_pair count(pair)Selects the adjacent pair that occurs most often.
Show symbols being transformed into codes and reconstructed by the decoder state.
Byte Pair Encoding should be used with the assumptions and tradeoffs of dictionary Compression in mind.
What each reference supports for this entry.
Reference for BPE merge operations as a practical subword coding algorithm.
Open sourceCompression reference for Byte Pair Encoding's practical encoding variants and decoder-side reconstruction details.
Good next jumps from the relationship graph, ranked for useful discovery.
Modern tokenizers often use byte-pair encoding to learn merge-based subword vocabularies.
Byte Pair Encoding is an alternative to LZW within the Dictionary Compression family.