# Pair-Merge Tokenisation Is Hard to Approximate on Binary Strings and Strongly NP-Hard on Unary Datasets

arXiv: https://arxiv.org/abs/2611.13568 · HTML: https://mlsanity.com/paper/2611.13568/

## Key facts

- No citing papers in the map yet (data through 24 Nov 2026).
- Builds on 8 of its 45 references that are in the map.
- Submitted 10 Nov 2026.

## Builds on (most cited first, 8 of 8)

- [Neural Machine Translation of Rare Words with Subword Units](https://mlsanity.com/paper/1508.07909/) (2015)
- [Theoretical Analysis of Byte-Pair Encoding](https://mlsanity.com/paper/2411.08671/) (2024)
- [Tokenisation is NP-Complete](https://mlsanity.com/paper/2412.15210/) (2024)
- [A Partition Cover Approach to Tokenization](https://mlsanity.com/paper/2501.06246/) (2025)
- [Tokenisation over Bounded Alphabets is Hard](https://mlsanity.com/paper/2511.15709/) (2025)
- [Approximation of grammar-based compression via recompression](https://mlsanity.com/paper/1301.5842/) (2013)
- [The smallest grammar problem revisited](https://mlsanity.com/paper/1908.06428/) (2019)
- [Greedy BPE with Replacement Counts Achieves the Tight Approximation Ratio (1-e-2)/2](https://mlsanity.com/paper/2611.08671/) (2026)

## Abstract (arXiv)

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 k merges that leave a string of length n almost as short as possible; doing nothing is already within a factor n. We prove that, unless P = NP, no polynomial-time algorithm comes within a factor c,n/log n, for some constant c>0, already for one binary string and for BPE-style merges that replace every occurrence. The key idea is that k merges form a grammar with k 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 O(n/loglog n), and no Karp reduction can prove hardness beyond order n/log n unless coNP subseteq 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.
