Pair-Merge Tokenisation Is Hard to Approximate on Binary Strings and Strongly NP-Hard on Unary Datasets
Abstract
Tokenisers such as Byte-Pair Encoding (BPE) shorten text by repeatedly merging an adjacent pair of symbols into a new one; fewer tokens mean less computation. We ask whether an efficient algorithm can choose merges that leave a string of length almost as short as possible; doing nothing is already within a factor . We prove that, unless P = NP, no polynomial-time algorithm comes within a factor , for some constant , already for one binary string and for BPE-style merges that replace every occurrence. The key idea is that merges form a grammar with rules: a vertex-cover gap becomes a grammar-size gap, which we amplify with relabelled copies, encode in binary and realise with explicit merges. For merges that may skip occurrences, a simple algorithm achieves , and no Karp reduction can prove hardness beyond order unless coNP NP/poly. Over a one-letter alphabet, both tokenisation problems left open by Kastreva et al. are strongly NP-complete on datasets with repeated strings.
Create a lesson
Metadata
- Categories
- cs.DS, cs.CC, cs.CL
- Comments
- 34 pages, 11 figures. Code and certificates: https://doi.org/10.5281/zenodo.24023730
Related papers
How Hard Is Tokenisation? Algorithms and Complexity Beyond NP-Hardness
Shared title terminologycs.DSAndrei Robert Ion, Rares Mateiu, Adrian Miclaus et al.
Planning Width Is Hard to Approximate Even Given the Unique Optimal Plan
Shared title terminologycs.DSViet Bac Nguyen
Hardness, Approximation, and Parameterized Algorithms for Asynchronous Border Minimization
Shared title terminologycs.DSGiulian Buzatu, Adrian Miclăuş, Alexandru Popa
Tokenization: Hardness and Bicriteria Approximation Algorithms
Shared title terminologycs.DSAtieh Bastan, Xiaoling He, A. Pavan et al.
Source Assignment: Hardness, Approximation, and Parameterized Algorithms
Shared title terminologycs.DSRuxandra Marinescu-Ghemeci, Adrian Miclăuş, Alexandru Popa
Improved Approximation and Hardness Bounds for β-TSP
Shared title terminologycs.DSPaul Liu, Jack Spalding-Jamieson, Da Wei Zheng