Introduction
Most modern Large Language Models (LLMs) do not process text character-by-character. Instead, they rely on subword tokenization (such as Byte-Pair Encoding), which groups common character sequences into discrete chunks. While computationally efficient, this approach is notoriously brittle: a single typographical error can completely alter the resulting token. Furthermore, subword tokenizers compress different languages at vastly different rates, often leading to disproportionate computational costs and latencies for non-English users.
Byte-level models, such as ByT5, solve these issues by processing raw bytes directly. This makes them incredibly robust to noise and ensures fairer processing across diverse languages. However, this robustness comes at a steep price: raw byte sequences are significantly longer than subword sequences, making byte-level models painfully slow to train and run.
This paper introduces MrT5 (MergeT5), a novel architecture that asks a critical question: Can we achieve the robustness of a byte-level model with the efficiency of a tokenized one? By dynamically "deleting" redundant tokens within the encoder, MrT5 learns to compress raw byte streams by up to 75%, achieving significant inference speedups while matching the performance of slower, full-sequence models.
How MrT5 Works
MrT5 modifies the standard ByT5 encoder by introducing a dynamic "delete gate" that shortens the input sequence on the fly.
- Initial Contextualization: The first few layers of the encoder process the full, raw byte sequence. This is a crucial step, allowing every byte to attend to its neighbors and absorb local context before any information is discarded.
- The Delete Gate: At a specific intermediate layer (optimally layer 3), a small, learned module evaluates the sequence and decides which tokens are essential and which can be safely discarded.
- Dynamic Merging: Because the retained tokens have already absorbed contextual information from the deleted ones during the initial layers, the model effectively "merges" the critical information into a much more compact sequence.
- Soft vs. Hard Deletion: To make the process differentiable during training, the model uses "soft deletion" via a soft attention mask. During inference, it switches to "hard deletion," physically removing columns from the computation matrix to realize actual savings in time and memory.
- Targeted Compression: To ensure the model hits specific compression targets (e.g., reducing sequence length by 50%), the authors employ a Proportional-Integral (PI) controller from classical control theory. This controller dynamically adjusts the penalty for keeping tokens during the training phase.
Key Insights and Discoveries
Context Before Compression
A major finding is that tokens cannot be deleted immediately at Layer 0. The model requires a few layers of full-sequence attention to "bake" the information from redundant bytes (like the 'u' following a 'q') into surrounding tokens. Only after this local context is established can tokens be safely dropped without losing semantic meaning.
Language-Specific Compression
Unlike fixed-rate compression schemes, MrT5 automatically adapts to the information density of different scripts and languages.
As shown in the evaluation across 15 typologically diverse languages, MrT5 learns to delete fewer tokens in highly information-dense languages (like Chinese) and aggressively compresses "sparser" languages (like English or French). This results in a naturally learned, language-specific compression rate.
Strategic Deletion
Unlike baseline methods that drop tokens randomly or at fixed intervals, MrT5 learns a task-specific strategy. In spelling correction tasks, it retains the specific characters necessary to fix an error; in broader semantic tasks, it learns to compress sequences much more aggressively.
Performance and Results
The researchers evaluated MrT5 across a wide battery of tasks, including multilingual C4 (mC4) pre-training, cross-lingual benchmarks like XNLI and TyDi QA, and diagnostic character-level tasks.
- Massive Sequence Reduction: MrT5 successfully reduces sequence lengths by up to 75% with minimal impact on bits-per-byte (BPB) performance.
- Inference Speedups: By physically removing tokens during the forward pass, the model achieved up to a 45% decrease in inference runtime compared to the ByT5 baseline.
- Performance Parity (and Gains): On the XNLI benchmark, MrT5 actually outperformed the full ByT5 model (65.31% vs. 64.72% accuracy) while operating significantly faster.
- Scaling Efficiency: The efficiency gains improve as the model scales. For a 1.23B parameter model, MrT5 achieved a 44.6% reduction in runtime, proving its viability for large-scale deployments.
Conclusion and Future Work
MrT5 represents a major step toward making "tokenization-free" models practical, potentially signaling an end to the era of brittle subword vocabularies.
While highly effective, the current architecture focuses primarily on the encoder. Future work may explore optimizing the decoder, which still processes full sequences, or implementing "multi-stage" deletion where the model dynamically decides when to compress based on the complexity of the input prompt. Despite these remaining avenues for optimization, MrT5 successfully bridges the gap between the robustness of raw bytes and the efficiency of subword tokens.
Summary updated