deniz.in

Markets

Weather

Loading weather

· via dev.to (home feed)

Optimal tokenisation is inapproximable within any constant factor, new proof shows

A new hardness result shows that, unless P equals NP, no polynomial-time algorithm can come within any constant factor of optimal tokenisation, capping what tokeniser design can provably guarantee.

Optimal tokenisation is inapproximable within any constant factor, new proof shows

What the proof shows

A new theoretical result has drawn a hard line under tokenisation, the step that turns raw text into the discrete units a language model actually consumes. According to a dev.to summary posted on 27 November 2026, which describes a paper on arXiv, the authors prove that unless P equals NP, no algorithm running in polynomial time can produce a tokenisation whose cost is within any constant multiple of the optimum.

The strength of the claim is worth pausing on. This goes beyond showing that computing the exact optimum is intractable. Even a very loose guarantee — an algorithm promised to be within ten times, or a thousand times, of the best possible result — is unattainable in polynomial time for this problem, under the standard assumption that P and NP are distinct classes. No fixed quality bar survives.

Which variants it covers

The proof earns attention through its breadth rather than a single clever construction. Per the dev.to write-up, the hardness result spans several dimensions:

  • Direct tokenisation, where a text is segmented into tokens in one step, and bottom-up tokenisation, where a segmentation is assembled from smaller pieces.
  • Compression objectives, which reward minimising the size of the output, and unigram log-likelihood objectives, which score a segmentation by the likelihood a simple probabilistic model over tokens assigns to it.
  • Binary alphabets and larger ones, so an input needs only two distinct symbols for the hardness to apply.

On top of that, the paper adds a separate finding for unary alphabets, where the input consists of a single symbol. There, direct tokenisation is APX-hard, which eliminates any hope of a polynomial-time approximation scheme — a family of algorithms that, for any requested accuracy, runs in polynomial time and gets that close to optimal. Even the most degenerate alphabet does not open a loophole.

Why it matters

Tokenisers sit at the front of every large language model pipeline. Training corpora, prompts and model outputs all pass through one, and its choices shape sequence length, compute cost and what the model can cleanly represent. A hardness result landing on this problem therefore lands close to practice.

The immediate consequence is a firm ceiling on provable quality. No efficient method can certify that its segmentation is within a constant factor of the best possible one for the studied variants and objectives. That repositions the heuristics the field already relies on — merge-based vocabularies, greedy matching, trained unigram models — from stopgap to structural necessity. In the worst case, nothing efficient carrying a constant-factor guarantee can replace them unless the complexity landscape changes dramatically.

The result also calibrates expectations for research. Improving tokenisers empirically remains entirely possible, but a theory of provably near-optimal tokenisation, of the kind available for some other optimisation problems, is closed off for these formulations.

What the theorem does not say

The dev.to analysis flags the central caveat: practical impact is the open question, and tokenisers built on heuristics might already work well in spite of the worst-case result. Hardness proofs describe adversarially constructed inputs. Natural-language corpora are not guaranteed to resemble those constructions, and the gap between worst-case and typical behaviour can be wide.

The theorem therefore does not show that current tokenisers are poor, nor that improving them is futile. It shows that improvements must be argued empirically or for restricted input distributions, not backed by a general near-optimality guarantee.

One note on provenance: the dev.to article carries a disclosure that it was produced with AI assistance and reviewed for accuracy, and it cites arXiv as the origin of the paper. Readers who need the constructions, proofs and authorship details should treat the arXiv paper as the authoritative reference.

  • #tokenisation
  • #complexity-theory
  • #llms
  • #algorithms
  • #nlp

Related posts