GreedTok & Partition Cover: Tokenization Optimization
- GreedTok is a polynomial-time greedy algorithm that formulates tokenization as a partition cover optimization problem linked to weighted maximum coverage.
- It leverages NP-hard reductions and approximation guarantees to improve tokenization efficiency compared to relaxed greedy methods like GreedWMC and BPE.
- Empirical evaluations show GreedTok reduces average tokens per word by 3–5% over BPE, highlighting its practical performance and optimization advantages.
GreedTok is a polynomial-time greedy algorithm for the partition cover approach to tokenization, formulated as an optimization problem that generalizes traditional NLP tokenization objectives. The partition cover perspective connects tokenization to the weighted maximum coverage problem and, in a broader context, links with the Partition Set Cover problem and its approximation-theoretic landscape. Both areas share foundations in combinatorial optimization and admit rigorous analysis in terms of computational hardness and approximation guarantees.
1. Partition Cover Formulation of Tokenization
Tokenization can be framed as selecting a set of tokens from a vocabulary to minimize the total number of segments (tokens) required to represent a corpus. Let be the finite alphabet and the set of words in the corpus, each with multiplicity . Singleton tokens are always available. The designer may select up to additional tokens , where is a candidate set of substrings (typically, length at least 2).
For each word and token-set , define: where “0” denotes concatenation.
Equivalently, one may define a covering score: 1 with the identity: 2.
Objective formulations:
- Compression (minimize tokens):
3
- Cover maximization: (equivalent after adjusting by a constant)
4
A mixed-integer programming (MIP) formulation for the cover version introduces binaries for token selection (5) and pairwise coverage (6 and 7), along with “no-overlap” constraints to enforce valid token segmentations (Lim et al., 8 Jan 2025).
2. Computational Hardness and Relation to Classical Cover Problems
The decision version of the partition cover tokenization problem is NP-hard. The hardness proof uses a reduction from Vertex Cover: an instance 8 of vertex cover is encoded into a tokenization instance where each graph edge becomes a word, and tokens correspond to covering graph vertices. Reaching a partition size threshold corresponds exactly to covering all edges with at most 9 vertices, establishing NP-hardness (Lim et al., 8 Jan 2025).
This formulation admits a direct relaxation to the weighted maximum coverage (WMC) problem: given elements (here, positions in words) with weights and eligible covering sets (candidate tokens), select up to 0 sets to maximize covered weight. In this relaxation, coverage overlaps (i.e., invalid token segmentations) are allowed, and the standard greedy algorithm achieves a 1-approximation (Lim et al., 8 Jan 2025).
3. GreedTok Algorithm and GreedWMC
GreedTok sequentially selects tokens to greedily maximize the increment in the cover objective, entirely respecting overlap constraints necessary for valid tokenizations. For each round up to 2, it computes the marginal gain 3—the summed counts of newly covered, so-far-uncovered segments—for each candidate 4. The maximally beneficial token is appended to the token set, and the cover state is updated. The process is efficient: with precomputation of token occurrences, the total time is 5 and space is 6 (Lim et al., 8 Jan 2025).
GreedWMC applies standard greedy weighted maximum coverage—dropping “no-overlap” constraints—which guarantees a 7-approximation for the relaxed covering problem. Implementation and complexity are analogous to GreedTok. GreedWMC may, however, generate invalid tokenizations due to overlapping token selection (Lim et al., 8 Jan 2025).
4. Partition Set Cover: Connections and Generalized Covering
The Partition Set Cover problem generalizes standard set cover by partitioning the ground set 8 into 9 color classes 0 (possibly overlapping), with demand 1 for each class. The goal is to select a minimum-weighted collection of sets so that for each 2, at least 3 elements from 4 are covered.
The canonical integer program introduces indicator variables 5 (for sets) and 6 (for elements); its “natural” LP relaxation can exhibit a 7 gap, thus a stronger LP plus knapsack-cover inequalities is employed. The approximation guarantee is stated in terms of 8, the best-known rounding-factor for induced set cover projections. For instance, geometric settings (disks/halfspaces in 9) yield 0, while other low-VC-dimension systems also achieve sublogarithmic 1 (Inamdar et al., 2018).
The main result is a randomized two-phase LP-rounding algorithm yielding an 2-approximation: heavy elements are covered by a 3-approximate algorithm; light elements are covered through 4 randomized rounds, ensuring each class’ demand is met with probability at least 5, and the total cost is 6 times the LP optimum (Inamdar et al., 2018). This bound is essentially tight: 7-hardness holds even for simple special cases.
5. Empirical Evaluation and Comparative Performance
Empirical studies compare GreedTok, GreedWMC, and Byte-Pair Encoding (BPE) on four English corpora (UN General Debate, arXiv abstracts, Wikipedia, PubMed) under equal vocabulary size constraints. Metrics include:
- Average tokens per word (TPW):
8
- Covering score:
9
Notable findings include:
- To reach the same TPW target, GreedTok uses on average 13% fewer tokens than BPE.
- At fixed vocabulary size 0, GreedTok achieves 3–5% lower TPW versus BPE; its covering scores are within 90% of GreedWMC (for large 1), consistent with near-optimality to the relaxed problem.
| Vocabulary 2 | BPE TPW | GreedTok TPW | GreedWMC TPW |
|---|---|---|---|
| 3500 | 2.189 | 2.120 (–3.2%) | 2.105 (–3.8%) |
| 5000 | 1.992 | 1.905 (–4.4%) | 1.892 (–5.0%) |
Similar reductions in TPW and covering efficiency hold across other datasets (Lim et al., 8 Jan 2025).
6. Comparative Analysis and Algorithmic Insights
BPE is efficient (3) but limited to pairwise merges, often selecting suboptimal tokens for global coverage. GreedWMC achieves the 4 theoretical guarantee for the relaxed problem but may produce segmentations violating the non-overlap constraint. GreedTok enforces exact partition constraints and, while only modestly slower, consistently outperforms BPE by 3–5% and closely tracks the optimal relaxed cover. The partition-cover MIP from which GreedTok derives allows for injective customization (e.g., domain-specific tokens or corpus-parallelization), which is unattainable for bottom-up merge algorithms (Lim et al., 8 Jan 2025).
From the set covering perspective, greedy algorithms for Partition Set Cover (e.g., extensions of Slavík’s PSC-greedy) achieve 5, but the LP-rounding yields tighter 6 bounds, especially when 7. Naive greedy for 8-frequency combinatorial systems gives 9, yet LP-rounding achieves 0. Ignoring cross-class coverage synergies leads to an 1 factor loss, whereas the advanced covering methods handle all class demands collectively (Inamdar et al., 2018).
7. Extensions, Limitations, and Outlook
The partition cover framework extends to related facility location objectives and outlier-minimum covering, maintaining 2-approximation via analogous decomposition into “heavy” and “light” client subsystems. Hardness persists: even geometric and metric variants disallow 3-approximations unless P=NP (Inamdar et al., 2018).
A plausible implication is that the merge-free, coverage-driven approach exemplified by GreedTok and its theoretical kin provides both increased flexibility and superior practical compression—subject to computational budget and candidate token enumeration feasibility. The ability to inject custom subtoken vocabularies and adapt to partitioned data suggests that these methodologies can subsume prior heuristic tokenization methods, offering a unified optimization-centric view.