ConvexTok: Global LP Tokenisation
- ConvexTok is a tokenisation algorithm that frames segmentation as a global optimisation problem using linear programming, offering clear quantifiable optimality guarantees.
- It employs convex relaxation by replacing integer constraints with continuous variables, enabling scalable and near-optimal solutions with minimal integrality gap.
- Empirical results show ConvexTok outperforms traditional greedy methods like BPE in compression metrics and language model performance on large corpora.
ConvexTok is a tokenisation algorithm for NLP based on global convex optimisation, specifically linear programming (LP). Unlike traditional tokenisation methods such as byte-pair encoding (BPE) and UnigramLM which employ greedy, locally optimal merges or pruning strategies, ConvexTok frames tokeniser construction as a global optimisation problem. The algorithm solves an LP defined over a tokenisation graph, providing near-optimal tokenisers with quantifiable optimality guarantees and demonstrating improved compression and representation efficiency for LLMs (Tempus et al., 21 May 2026).
1. Linear Programming Formulation
ConvexTok originates from a formal integer programming (IP) formulation of the tokenisation problem, constructed on a directed acyclic tokenisation graph . Each node represents a position in the concatenated dataset, and each edge corresponds to either a "free" byte step or a "priced" token step. Candidate tokens induce edge groups ("colours") . Decision variables are binary vectors indicating which free edges (), priced edges (), and token types () are used. Incidence matrices (, ), a supply/demand vector (), and an arc-to-colour assignment matrix () encode flow and token dependencies.
The integer program is:
Relaxation of integrality constraints to 0 intervals gives the ConvexTok LP: 1 This represents a convex hull over feasible discrete tokenisation configurations, indexed by the dataset and token vocabulary budget 2.
2. Convex Relaxation and Algorithmic Solution
The LP relaxation in ConvexTok replaces binary decisions with continuous variables in 3, forming an optimisation over a high-dimensional convex polytope. No auxiliary regularisers are required; all constraints remain linear. The convex relaxation enables the application of highly scalable first-order methods and convex solvers, in this instance the PDLP solver from NVIDIA's cuOpt library, which implements a primal–dual hybrid gradient method featuring presolving and adaptive step sizes.
On large corpora with vocabulary sizes up to 4k, the resulting LP contains approximately 5 million constraints and 6 million variables. Typical runtime is about 7 seconds to 8 relative accuracy on a single NVIDIA GH200 GPU, scaling from 9 seconds to 0 seconds across six tested vocabulary budgets. For smaller vocabulary budgets, the LP becomes marginally more expensive to solve.
3. Certification of Optimality
ConvexTok's LP provides a lower bound 1 on the best possible tokenisation objective (e.g., compression). After rounding the LP solution (via deterministic or biased rounding schemes), a discrete tokeniser with objective 2 is extracted and evaluated. The integrality gap ratio,
3
quantifies suboptimality. Empirical results show that, for vocabulary sizes 4k, this ratio remains within 5 (6) of the LP lower bound, indicating near-optimality of ConvexTok-rounded tokenisers on the data.
Dual multipliers from the LP solution (dual variables for flow and budget constraints) provide an additional certificate of optimality, with the dual LP related by strong duality up to solver tolerances.
4. Empirical Performance and Metrics
Evaluations span both intrinsic and extrinsic criteria.
Intrinsic tokenisation metrics (measured on held-out ClimbMix, Flores+, and similar datasets):
- Vocabulary utilisation: 7 to 8 percentage points over BPE.
- Type-token ratio: 9–0.
- Shannon entropy (Rényi 1) and 2: mixed, with BPE slightly higher in some cases.
- Average token length, tokens per line, and compression rate: consistently improved.
- Bias rounding achieves best bits-per-byte (BpB) compression and vocabulary utilisation.
LLM performance (bits-per-byte, BpB):
- Decoder-only GPT-style transformers (12/18/24 layers) trained on ClimbMix400B, same hyperparameters across tokenisers.
- 12-layer, 3k–4k: Deterministic rounding outperforms BPE on all but one configuration, with relative BpB improvement of 5–6.
- 18-layer, 7k–8k: Deterministic rounding is best at key vocabulary sizes, closely followed by bias rounding.
- 24-layer, 9k–0k: Bias and deterministic rounding match or beat BPE for larger vocabularies.
Downstream tasks (CORE, GLUE-style QA, commonsense, BBH, etc.):
- At 12 layers: ConvexTok deterministic rounding generally outperforms BPE, though certain tasks (e.g., BigBench CS–Algorithm) prefer BPE.
- At 18 layers: bias rounding and BPE often tie or show minor differences.
- At 24 layers: BPE has a slight advantage at 1k vocabulary, but ConvexTok surpasses at 2k and 3k.
- Larger vocabularies tend to favour ConvexTok.
5. Comparison with Greedy Tokenisation Algorithms
BPE and UnigramLM implement greedy, local update rules: BPE greedily merges the most frequent byte pair at each step up to the vocabulary budget, and UnigramLM prunes tokens based on individual contributions. ConvexTok, in contrast, optimises a global segmentation cost subject to a vocabulary budget constraint over all candidates simultaneously.
Empirically, BPE-compressed models use approximately 4–5 more bytes (higher BpB) and cannot certify their distance to optimality. ConvexTok provides a provable compression lower bound and marginally superior compression (about 6 improvement). This comes at a computational cost: BPE executes in seconds, while ConvexTok's LP requires minutes to hours per corpus–vocabulary configuration, though the solution can be reused across experiments.
6. Limitations and Prospects for Advancement
Several limitations constrain the current ConvexTok framework:
- Scalability: The LP formulation scales as 7 with dataset size and average sequence length, reaching 8 variables on large corpora. High-end GPU resources (e.g., NVIDIA GH200) are necessary, and memory or wall time may become prohibitive.
- Rounding and Integrality: Existing deterministic, biased, and integer rounding approaches do not guarantee feasible or integral solutions without post-processing. Improvements in rounding or incorporation of cutting-plane algorithms may further reduce the integrality gap.
- Optimisation Objective: The present instantiation focuses on compression minimisation. Extensions to alternative objectives (such as unigram log-likelihood or Rényi efficiency) are theoretically straightforward but remain unexplored experimentally.
- Pretokenisation: ConvexTok currently presumes external word- or regex-based pretokenisation, preserving these boundaries. Joint learning or relaxation of such boundaries, as in SuperBPE, is identified as future work.
7. Summary and Research Significance
ConvexTok advances the theory and practice of NLP tokenisation by casting vocabulary selection and segmentation as a large-scale LP. This allows the construction of tokenisers with certifiable near-optimality for compression, outperforming greedy baselines in both intrinsic and bits-per-byte metrics and remaining competitive in downstream task performance. The methodology involves a one-time computational cost that is offset by substantial gains in representational efficiency. Open research questions concern improved scalability, generalisation of objectives, and fully integrated pretokenisation learning (Tempus et al., 21 May 2026).