Springe direkt zu Inhalt

Johannes Voderholzer:

Theoretical Analysis of Byte-Pair Encoding

Kurzbeschreibung

Byte-Pair Encoding (BPE) is a widely used method for subword tokenization, with origins in grammar-based text compression. It is employed in a variety of language processing tasks such as machine translation or large language model (LLM) pretraining and inference, to create a token dictionary of a prescribed size. Most evaluations of BPE to date are empirical, and the reasons for its good practical performance are not well understood.

In this work we focus on the optimization problem underlying BPE: finding a pair encoding that achieves optimal compression utility. We show that this problem is APX-complete, indicating that it is unlikely to admit a polynomial-time approximation scheme. This answers, in a stronger form, a question recently raised by Zouhar et al.

On the positive side, we show that BPE approximates the compression utility of the optimal pair encoding to a worst-case factor between 1.6 and 3. Our results aim to explain the ongoing success of BPE and are, to our knowledge, the first rigorous guarantees on its compression utility that hold for all inputs.

Additionally, we demonstrate how BPE can be efficiently implemented in C to achieve linear runtime. Our implementation matches the performance of other modern libraries while significantly reducing code complexity. We further propose an enhanced algorithm that tries to balance token dictionary quality and compression ratio, and conjecture that this approach could improve LLM performance.

Abschluss
Master of Science (M.Sc.)
Abgabedatum
28.01.2025