Profile

Settings

Loading…

← Papers

Help

FAQ

Which features require signing in?

You can read the commentary, paper info, Model Structure and related papers of public papers without signing in. Sign in to manage your account or contact us about your inquiries.

Can I upload a PDF file?

Upload papers with an arXiv or DOI link; the commentary is public to everyone. Papers whose source and terms of use can't be verified, so the commentary can't be made public, can't be uploaded. Uploading PDF files and keeping papers private are for subscribers only, and a paper uploaded as a file is saved as private only. Searching for official info by title runs only when you press the button.

Are the figures and AI commentary accurate?

Figures come only from the original paper, and only those whose terms of use are verified are shown. The commentary is written by AI and may be wrong. Check important claims, numbers and figure context against the evidence in the original paper.

I want to report a copyright issue.

Terms of use and the source of the original paper are on the Paper info tab. If there's a problem, choose "Paper content, figures and copyright" under Contact us and send the paper link, the part in question, and evidence that you hold the rights. Receiving your report doesn't confirm any rights or remove anything right away. You can see the result of the review under My inquiries.

I forgot my password.

If you signed up with email, use Forgot password in the sign-in window to reset it with your verified email. If you signed up with Google, Naver or Kakao, change your password with that service.

What should I include in an inquiry?

Tell us which screen you were on and what you were doing when the problem happened, along with the paper link. Don't include personal information such as passwords, API keys, verification codes or phone numbers. Inquiries and replies are stored in Refivu and you can see them under My inquiries.

How do I delete my account?

In Settings, under My account, press Delete account. Review what will be deleted and complete identity verification to delete your account. For other requests, choose "Account" under Contact us.

Paper commentary

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

Pair-merge tokenisation proves hard to approximate on binary strings

  • Problem Choosing k merges that shorten a string as much as possible was not known to be efficiently approximable, and BPE-style merges on binary strings were left open. Kastreva et al. asked whether these problems admit constant-factor approximations.
  • Method The authors turn a sequence of merges into grammar rules, so a vertex-cover gap becomes a grammar-size gap. They amplify that gap with relabelled copies and encode the result in binary.
  • Results Unless P = NP, no polynomial-time algorithm approximates compressed length within c n/log n, already for one binary string and full merges.

Table 2: Notation for Sections 2 to 4

Table 2 : Notation for Sections 2 to 4.

Original paper · CC BY 4.0 · Kundan Baliga, Aiden Xie, Aditya Byju · Pair-Merge Tokenisation Is Hard to Approximate on Binary Strings and Strongly NP-Hard on Unary Datasets · Original paper figure · Extracted the figure area from page 5 of the original PDF.

Why approximating merge counts is hard

Byte-Pair Encoding shortens a string by repeatedly naming an adjacent pair of symbols as one new symbol. Fewer tokens mean less compute, so the question is which k merges leave the shortest string. The compressed length counts the symbols that remain after the merges, and it is the quantity being approximated. Doing nothing is already within a factor n of the optimum, because the optimum keeps at least one symbol.

A full merge replaces every occurrence of its pair, as BPE does, while a partial merge replaces only a chosen set of occurrences.

Kastreva et al. asked whether the binary versions of their tokenisation problems lie in APX, meaning they admit a constant-factor approximation. This paper addresses that question for bounded alphabets, except for direct tokenisation.

The main binary result says that, unless P = NP, no polynomial-time algorithm approximates the compressed length within c⋆n/log n. This hardness already holds for one binary string and for full merges as in BPE. For partial merges, a simple algorithm achieves O(n/log log n), so the gap is narrowed from both sides. The hard instances use a large budget, k = Θ(n/log n), and in the yes case they compress the whole string to one token.

The key idea is that k merges form a grammar with k rules, so a gap in vertex cover becomes a gap in grammar size.

The vertex-cover gap is the source of the hardness, and it is multiplied by relabelled copies of the string. A reduction from vertex cover on cubic graphs gives the additive gap, which the proof then amplifies. Hardness of vertex cover on cubic graphs is NP-complete, and the same map yields the unbounded-alphabet bound. The authors give the full construction over large alphabets first, so the later binary construction can reuse it as a black box.

Merges behave like small grammars

A sequence of k merges is a grammar with k rules of the form X to YZ, much like a BPE merge table. Each merge of a pair (a,b) introduces a fresh symbol X and gives the rule X to ab, so the merge table reads as a set of grammar rules. Full merges replace every occurrence of their pair, while partial merges replace only a chosen set of non-overlapping occurrences.

The authors use this view because it lets a lower bound on grammar size become a lower bound on compressed length.

The first bridge says that if k partial merges leave a sequence of length ℓ, then the grammar size g(s) is at most k + ℓ − 1. Its proof reads each final symbol as the part of s it covers and adds ℓ − 1 rules that join those symbols from left to right. Hence LEN full(s,k) and LEN part(s,k) are at least g(s) − k + 1, so a grammar gap becomes a bound on the remaining length.

The second bridge runs the other way: for partial merges, any string with length at least 2 is reduced to one symbol by g(s) merges. The proof takes a smallest SLP, processes its rules children first, and partially merges the occurrences of each pair YZ. Together the two bridges give LEN part(s,k) = 1 if and only if g(s) ≤ k. Full merges lack the second bridge, because they also hit occurrences the grammar does not want, so the authors build full-merge sequences by hand.

The gap source is vertex cover, and the cubic-graph gap version gives a constant ε0 > 0 with a polynomial-time reduction from SAT. Satisfiable instances have vc(H) ≤ κ, while unsatisfiable ones have vc(H) ≥ (1 + ε0)κ. Since |E| = 3|V|/2 in a cubic graph, vc(H) is at least |V|/2, so the authors assume κ ≥ |V|/2.

Building the binary hard instance

The construction starts from a gadget string over a large alphabet, and its grammar gap must survive the move to two letters. The gadget string has an additive gap of vc(H) minus κ rules, but it needs many distinct letters. Writing each letter in binary costs extra rules, so the construction pays that cost once while multiplying the gap. The affine copies are built so that no adjacent pair is shared between two copies.

Because of this, grammar size adds up over the copies and the gap becomes t times the vertex-cover gap.

The affine copies use a prime p at least q and an injection of the letters of w into the field F p. Each copy is wrapped in fresh guard letters, so that the copy boundaries are unique as well. Each letter is then written as a codeword of length L = 4d + 3, built from the bit pairs η(0) = 10 and η(1) = 11. The identifier is written twice and an anchor bit marks the codeword phase, so a repeated piece of the binary string can be read back as a piece of the amplified string.

Because of this decoding, the grammar of the binary string is at least as large as that of the amplified string.

In the yes case, a first stage of about q_W times 2d full merges turns each codeword into one token. A second stage then runs the full-merge schedule inside each copy and joins the copies. The no-case bound becomes t(R(vc(H)) + 3) − 1, and the Fact 3 gap assumption drives it.

Worked example on the single edge K2

The smallest graph, a single edge, lets the whole construction be checked by hand before the binary code is added. For K2 the gadget grammar size is R(1) = 12 + 3 − 1 + 1 = 15, so the vertex-cover number of one edge sets the value. With 14 merges, Lemma 1 and Corollary 7 force at least 2 symbols to remain, so the budget of 15 is tight.

The binary worked example takes the prime p = 11 and a single copy, with t = 1. For this copy the number of distinct letters is qW = 10, with d = 4 and codeword length L = 19. The binary string F then has 380 bits, and the Stage-A cost Ccode is 73.

With all t = p² = 121 copies, the code grows to qW = 110 and d = 7, with L = 31.

Strong NP-hardness on one-letter alphabets

Kastreva et al. left two unary decision problems open, and this section closes both of them. Unary OPE-seg had only weak NP-hardness, because the known reduction came from addition sequences whose binary-encoded targets become exponentially long in unary. Standard bottom-up tokenisation had no hardness result at all. The authors model unary inputs as runs of one character, with datasets as multisets so that repeated strings are allowed.

The same strong NP-completeness holds for standard bottom-up tokenisation, that is, full merges, on datasets with repeated strings.

The tokenisers are defined precisely before the hardness claim. A merge sequence for OPE-seg builds a vocabulary, and each string is then segmented at the minimum number of vocabulary tokens. For standard bottom-up tokenisation, each merge replaces every non-overlapping occurrence of its pair, applied to the token string of one letters. Extra merges never hurt, because appending a merge only enlarges the vocabulary or shortens strings, so exactly k and at most k merges give the same problem.

Strong NP-hardness matters here because the numbers are written in unary, so a hard instance cannot rely on exponentially long strings. Membership in NP holds because maximum token size is bounded by the input size, so a list of at most maxD merges is a certificate.

Each vertex v gets a number αv, and each edge needs an edge string whose cost depends on whether an endpoint was bought. A cover string αv + M for each vertex costs one token once bought, while an edge string αu + αv + M costs two tokens at the endpoint. The authors choose powers of two for small scaffold numbers and a Sidon set for vertex numbers, so that θu + θv determines the edge.

The local notation sets the prime ϖ, the values ξv and θv, the bit length β, and the scaffold S with its weight ω.

The authors also check that the construction is polynomial in size. The example K2 has prime ϖ = 3 and the threshold gives δ = 102 minus κ, showing the two cases separate. For full merges the reachable reading and the literal reading give the same answer, so the result holds under either reading.

What can be approximated, and what Karp reductions cannot prove

For partial merges, a simple algorithm reaches a ratio of O(n/log log n) on the compressed length. Theorem 34 bounds the output length by ⌈n/m⌉ whenever the sum of 2^ℓ over ℓ from 1 to m is at most k. For binary strings the block length can be taken as m = ⌊log(k+4)⌋ − 1, so the bound shrinks as the budget grows. Corollary 36 outputs the better of doing nothing and this construction, which gives the O(n log σ / log log n) ratio for σ letters.

Doing nothing is already within a factor of 2^k when k is small, which covers the small-budget regime.

Full merges can't respect a block alignment, so the authors work in phases instead. This halves the length, while the number of distinct symbols grows to at most 3|T|^3 per phase. Theorem 35 gives LEN_full(s,k) ≤ (n−1)/2^I + 1 for a binary string once log k ≥ 1.8·3^I + 2. For full merges the same construction gives the ratio O(n/(log log n)^{log₃ 2}), so the bound is weaker by the exponent log₃ 2, about 0.63.

Figure 11 puts the partial-merge picture on one scale: the ratio on top and the budget k at the bottom. A Karp gap reduction maps satisfiable formulas to instances with optimum at most θ_yes(n), and unsatisfiable ones to optimum at least θ_no(n). The authors prove that if approximating LEN_part within ratio ρ(n) with ρ(n) log n / n tending to infinity were NP-hard by such a reduction, then coNP ⊆ NP/poly.

The same collapse follows for LEN_full when ρ(n)(log n)^{log₃ 2}/n tends to infinity. The proof idea is that yes-instances with small k and optimum o(log n) are too few to be the image of a Karp reduction. Such a sparse set would force coNP ⊆ NP/poly through the density theorem of Buhrman and Hitchcock. So for partial merges the n/log n barrier is tight among Karp reductions, and the remaining gap lies between n/log n and n/log log n.

The authors conjecture that the true ratio for partial merges is Θ(n/log log n). Conjecture 38 links this to Gap-ETH and sketches a gap vertex-cover instance encoded as a binary word. The missing piece is a robust per-copy count of vertex-cover witnesses, and the authors haven't proved it.

What the results do not establish

The binary hardness is a worst-case statement, and it does not say that BPE performs badly on natural text. The hard instances need a large budget, k = Θ(n/log n), and in the yes case they compress the whole string to one token.

For partial merges, a simple algorithm reaches O(n/log log n), and the gap to the n/log n lower-bound regime stays open. The authors expect Θ(n/log log n) to be the true answer for partial merges, but they haven't proven it. Their Gap-ETH route to that bound needs a lemma about robust per-copy counts of vertex-cover witnesses. The authors haven't proved that lemma, and Lemma 1 is too weak for the purpose.

The direct tokeniser isn't covered by these results, so the APX question for it stays open. The partial-merge binary bound follows from Nowicki's bounds, so the new binary contribution is the full-merge schedule. The Karp barrier doesn't rule out hardness for budgets between log n and n^ε, which the authors leave open.

Paper info

Authors
Kundan Baliga, Aiden Xie, Aditya Byju
Venue
arXiv · Preprint
First published
2026-11-10
Added
2026-11-11
Updated
2026-11-10
Version
v1
arXiv
2611.13568
Category
cs.DS · cs.CC · cs.CL
Original paper terms
CC BY 4.0
What we show
Paper info, commentary and permitted figures from the original paper

AI commentary is a separate explanation from the original paper and may contain errors. The original paper and figures follow each source's terms of use and any rights noted separately.

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 $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/\log\log 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.

Quote from the paper

Kundan Baliga, Aiden Xie, Aditya Byju (2026). Pair-Merge Tokenisation Is Hard to Approximate on Binary Strings and Strongly NP-Hard on Unary Datasets. arXiv:2611.13568v1. https://arxiv.org/abs/2611.13568v1

BibTeX
@misc{baliga2026pair,
  title = {{Pair-Merge Tokenisation Is Hard to Approximate on Binary Strings and Strongly NP-Hard on Unary Datasets}},
  author = {Kundan Baliga and Aiden Xie and Aditya Byju},
  year = {2026},
  eprint = {2611.13568},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2611.13568v1}
}

See related papersBrowse other papers

Paper preview
Account security

Connect Google account

If you connect a Google account, you can sign in with it too.

Refivu

Delete account

Refivu
Refivu

Sign up