A negative result about the first step

Before a language model sees a single word, the text has been cut into tokens by an algorithm — in practice byte-pair encoding or one of its relatives. Those algorithms are heuristics: they are fast and they work well enough, and nobody has claimed they find the best possible vocabulary.

A paper by Violeta Kastreva, Philip Whittington, Dennis Komm and Tiago Pimentel, posted to arXiv on 25 November, now shows how far short of “best possible” any efficient method must fall. Their result is that, unless P equals NP, no polynomial-time algorithm can find a tokeniser whose objective is within any constant factor of the optimum. In complexity terms, tokenisation is not in APX.

Rows of rusted steel chain links
A problem outside APX admits no fixed-factor approximation guarantee. Illustration: stock photograph. Jan van der Wolf · pexels · Pexels License

What “not in APX” means in practice

APX is the class of optimisation problems for which some efficient algorithm is guaranteed to land within a fixed multiple of the best answer. Plenty of hard problems live there: a problem can be NP-hard to solve exactly and still admit a fast algorithm that is never worse than, say, twice the optimum.

Saying a problem is not in APX removes that consolation. There is no constant — not two, not a hundred — for which someone could write an efficient algorithm and promise never to do worse than that multiple of the optimal tokeniser. Whatever guarantee a fast method offers has to degrade as the input grows.

The authors establish this across the cases that matter rather than for one convenient formulation. The proof covers both direct and bottom-up tokenisation, under either a compression objective or a unigram log-likelihood objective, and for binary alphabets as well as larger ones.

The unary case

The sharpest part of the paper concerns the most degenerate input imaginable. Even over a unary alphabet — a language with exactly one symbol, where the only information in a string is its length — the authors show that direct tokenisation is APX-hard, and therefore admits no polynomial-time approximation scheme.

A brick wall with staggered courses
The result holds even over an alphabet with a single symbol. Illustration: stock photograph. Nur Yilmaz · pexels · Pexels License

That is the kind of result that closes a line of inquiry. If hardness survived only in rich alphabets, one could hope that the structure of real text made the problem easier. Hardness over one symbol means the difficulty is in the combinatorics of choosing a vocabulary, not in the variety of the characters being chosen from.

What it changes, and what it does not

Nothing about this result says byte-pair encoding performs badly. Heuristics routinely do well on instances that arise in practice while admitting no worst-case guarantee, and the enormous empirical literature on tokeniser quality is untouched by a complexity bound.

What changes is the shape of the research question. A line of work aimed at finding a provably near-optimal tokeniser in polynomial time can now be retired, and effort redirected to instance-specific guarantees, to parameterised algorithms, or to the empirical question of how far from optimal current tokenisers actually are on real corpora.

What to watch is whether anyone can bound that empirical gap. The proof says no algorithm can promise a constant factor in general; it says nothing about how large the gap is for English text at the vocabulary sizes production models use, and that number has never been measured.