Introduction
Large Language Models (LLMs) typically evaluate text based on a single "canonical" tokenization, overlooking numerous valid alternative representations of the same string. This standard practice can be fragile, as subword vocabularies are often overlapping. For instance, the word "learning" might be tokenized as ["learn", "ing"] or ["lea", "rn", "ing"]. Research suggests that marginalization—the process of summing probabilities across all possible tokenizations—yields a more robust measure of a model's true belief. However, exact marginalization is computationally prohibitive (NP-Hard). Existing approximations rely on importance sampling, which requires slow, serial LLM generation (decoding). This paper introduces a "decoding-free" lattice-based sampling strategy that achieves significant speedups and improved accuracy.
Methodology: Decoding-Free Lattice Sampling
The proposed approach shifts the computational burden from expensive LLM generation to efficient graph-based manipulations.
The method involves three core components:
- Subword Lattice Construction: All possible tokenizations of a string are represented as a Directed Acyclic Graph (DAG). Each path through the lattice corresponds to a valid tokenization.
- Lattice Sampling Algorithm: Instead of decoding samples from the LLM, the algorithm samples paths directly from the lattice. It prioritizes "off-by-one" enumerations—tokenizations nearly identical to the canonical one—as these contain the bulk of the probability mass. Additional unique paths are then sampled uniformly.
- Parallel Scoring: Once candidate tokenizations are identified, the LLM is used to score them. Unlike generation, which requires $O(n)$ serial forward passes, scoring is a single, highly parallelizable forward pass.
Experimental Setup
The researchers evaluated the lattice-based marginalization strategy across two primary tasks using the Llama 2 and Gemma 3 model families:
- Question Answering (Q&A): Benchmarked on OpenBookQA, MedMCQA (medical domain), and ARC (AI2 Reasoning Challenge).
- Machine Translation: Evaluated on WMT24++ for English to German and Czech.
Key Results and Insights
The decoding-free approach demonstrates that we do not need the LLM to generate tokenizations; we only need it to evaluate them. By turning a serial generation task into a parallel scoring task, the authors unlock massive efficiency gains.
- Significant Efficiency Gains: The lattice approach achieved speedups between 1.4x and 36.5x compared to traditional importance sampling. These gains scale with model size, with the largest models (e.g., Gemma-27B) showing the most dramatic improvements.
- Improved Accuracy: Lattice-based estimates were generally more accurate than importance sampling. Traditional methods often underestimate the true marginal because their proxy distributions align poorly with the model's actual distribution.
- Performance Benefits of Marginalization: On the MedMCQA dataset, marginalization outperformed the standard canonical-only approach, indicating that non-canonical tokenizations capture valuable semantic signals that models otherwise ignore.
Conclusion and Future Work
While highly effective, this method requires direct access to model logits, limiting its current applicability to open-source models or APIs that expose raw scores. Future research may explore integrating this decoding-free logic with speculative decoding or using these insights to refine tokenizer training. This work provides a scalable path toward more robust LLM evaluation through efficient marginalization.
Summary updated