Skip to content

Greedy BPE with Replacement Counts Achieves the Tight Approximation Ratio (1−e−2)/2(1-e^{-2})/2

Kundan Baliga, Aiden Xie, Aditya Byju

cs.DS

Abstract

Byte-Pair Encoding (BPE) builds the tokenisers of many language models by repeatedly merging a most frequent adjacent pair of symbols. Kozma and Voderholzer showed that kk greedy merges save, in the worst case, between 1/31/3 and (1−e−2)/2≈0.43233(1-e^{-2})/2 \approx 0.43233 of what the best kk merges save, and asked for the exact constant. We resolve this question for the replacement-count rule they analyse. For every string and weighted word table, every budget kk, and every tie-breaking rule, greedy saves at least 12(1−(1−2/k)k)\frac12(1-(1-2/k)^k) of the optimum. This establishes the exact worst-case approximation ratio (1−e−2)/2(1-e^{-2})/2, approached as k→∞k\to\infty but never attained. The proof is based on a shadow inequality: after ii greedy steps, the optimum is at most 2Gi+kgi+12G_i+kg_{i+1}, where GiG_i is greedy's saving so far and gi+1g_{i+1} its next gain. We also show that the worst-case ratio at budget kk exceeds the limiting constant by Θ(k−1/2)Θ(k^{-1/2}). For the overlapping-count rule used by deployed trainers, we prove a lower bound greater than 0.389540.38954 and an asymptotic upper bound of approximately 0.404070.40407; determining its exact constant remains open.

Create a lesson

Metadata

Categories
cs.DS, cs.CL
Comments
58 pages. v3 supersedes v2 (0.391 bound), establishing the exact worst-case approximation ratio for replacement-count BPE, a finite-budget convergence result, and bounds for overlapping-count BPE. Code and certificates: https://doi.org/10.5281/zenodo.24451469