MAGNET: Improving the Multilingual Fairness of Language Models with Adaptive Gradient-Based Tokenization

Orevaoghene Ahia, Sachin Kumar, Hila Gonen, Valentin Hofmann, Tomasz Limisiewicz, Yulia Tsvetkov, Noah A. Smith

TL;DR

MAGNET (Multilingual Adaptive GradieNt-basEd Tokenization) introduces script-specific, gradient-based tokenization to eliminate the "over-segmentation" bias that penalizes non-Latin scripts in multilingual models. By learning adaptive boundaries for different writing systems, it achieves more equitable performance and significantly faster inference without sacrificing downstream accuracy.

What Problem Does This Paper Address?

Traditional subword tokenizers (like BPE) are data-driven and frequency-biased. In multilingual settings, high-resource languages like English are compressed efficiently, while low-resource or non-Latin scripts (e.g., Telugu, Hindi, Russian) are often "over-segmented" into tiny fragments. For example, a Telugu sentence might require 3x more tokens than its English equivalent to convey the same meaning.

This disparity isn't just a linguistic quirk; it creates a "fairness tax." Over-segmented languages suffer from higher compute costs, shorter effective context windows, and degraded model performance. While "tokenizer-free" byte-level models avoid BPE's pitfalls, they are computationally expensive. Previous gradient-based tokenization methods attempted to solve this but applied a uniform compression rate across all languages, failing to address the fundamental script-level imbalance.

Methods

MAGNET builds upon the Hourglass Transformer architecture, which uses a hierarchical structure to process long sequences efficiently. The core innovation is the introduction of modularity into the tokenization layer:

  1. Script-Specific Boundary Predictors: Instead of a single tokenizer, MAGNET employs multiple internal sub-modules (predictors) tailored to specific scripts (e.g., Latin, Cyrillic, Indic).
  2. Routing Mechanism: Input byte sequences are tagged by their script and routed through the corresponding predictor.
  3. Differentiable Tokenization: The model learns to predict segment boundaries between bytes end-to-end. It uses the Gumbel-sigmoid trick to make the discrete sampling of boundaries differentiable during training.
  4. Adaptive Binomial Priors ($\beta$): To ensure fairness, the authors set different target compression rates ($\beta$) for each script based on their average byte-to-word ratios. This forces the model to learn a similar granularity of representation (e.g., roughly word-level) regardless of the script's byte density.
Figure 1: MAGNET routes byte-level sequences via language-script specific boundary predictors. These predictors infer boundaries leading to equitable segmentation across languages. Prior work infers boundaries with a single predictor across languages and leads to over-segmentation.

Datasets

  • Pretraining: The models were trained on a subset of the OSCAR dataset covering nine languages across three script groups: Latin (English, Spanish, French), Cyrillic (Russian, Ukrainian, Belarusian), and Indic (Telugu, Bengali, Hindi).
  • Evaluation: The authors tested downstream utility using standard benchmarks:
  • XNLI (Natural Language Inference)
    • XQuAD (Question Answering)
    • PAWS-X (Paraphrase Detection)
    • SIB-200 (Topic Classification)
    • FLORES-200 (Parallel corpus used to analyze segmentation granularity)
    • Dialectal Tasks: ILI (Indo-Aryan Language Identification) and HaSCoSVa-2022 (Spanish dialect hate speech detection).

Key Insights and Ideas

  • Modularity is the Key to Fairness: A "one-size-fits-all" tokenizer is a bottleneck for multilingual equity. By allowing the model to "breathe" differently for different scripts, MAGNET balances the computational load.
  • Closing the Granularity Gap: MAGNET successfully reduces the token count for Indic languages by nearly 5x compared to standard methods, bringing them in line with Latin script token counts.
  • Efficiency without Sacrifice: Unlike previous methods where high compression often meant lower accuracy, MAGNET maintains competitive performance because the compression is adaptive and learned alongside the language modeling objective.
Figure 2: Average number of tokens after seg- menting the FLORES dataset. Subword tok- enizers and DTP result in over-segmentation in non-Latin script languages, while MAGNET closes the gap.

Key Results

  • Equitable Segmentation: As shown in Figure 2, MAGNET effectively flattens the token-count curve across languages, whereas BPE and fixed-rate models show massive spikes for non-Latin scripts.
  • Downstream Performance: MAGNET (specifically the 1,2,4x configuration) achieved an average XNLI accuracy of 68.74%, slightly outperforming the vanilla byte-level baseline (68.68%) and significantly beating fixed-compression models (DTP).
  • Inference Speedup: MAGNET models are roughly 3x faster than byte-level models during inference. For languages like Hindi and Russian, MAGNET achieved lower inference times than models using fixed 5x or 10x compression.
Figure 3: Language-specific accuracy on the XNLI task across byte-level, and all DTP and MAGNET models. Results are mostly competitive between byte-level and MAGNET models on Latin languages and Russian.

Limitations and Future Work

  • Scale: The experiments were conducted on relatively small models (~126M parameters). The authors hypothesize that the benefits of MAGNET will scale even further with larger LLMs.
  • Script Complexity: The current method relies on whitespace as a proxy for "words" to set the binomial priors. This is challenging for scripts like CJK (Chinese, Japanese, Korean) that do not use spaces.
  • Morphological Complexity: The authors note that the current byte-level segmentation might not be ideal for Semitic languages (like Arabic) where morphemes are often discontinuous.
  • Compression Sensitivity: For Indic languages, very high compression rates (e.g., 20x) led to a ~5% drop in performance, suggesting a limit to how much information can be squeezed into a single token representation.

Summary updated

Abstract

In multilingual settings, non-Latin scripts and low-resource languages are usually disadvantaged in terms of language models' utility, efficiency, and cost. Specifically, previous studies have reported multiple modeling biases that the current tokenization algorithms introduce to non-Latin script languages, the main one being over-segmentation. In this work, we propose MAGNET; multilingual adaptive gradient-based tokenization to reduce over-segmentation via adaptive gradient-based subword tokenization. MAGNET learns to predict segment boundaries between byte tokens in a sequence via sub-modules within the model, which act as internal boundary predictors (tokenizers). Previous gradient-based tokenization methods aimed for uniform compression across sequences by integrating a single boundary predictor during training and optimizing it end-to-end through stochastic reparameterization alongside the next token prediction objective. However, this approach still results in over-segmentation for non-Latin script languages in multilingual settings. In contrast, MAGNET offers a customizable architecture where byte-level sequences are routed through language-script-specific predictors, each optimized for its respective language script. This modularity enforces equitable segmentation granularity across different language scripts compared to previous methods. Through extensive experiments, we demonstrate that in addition to reducing segmentation disparities, MAGNET also enables faster language modelling and improves downstream utility.
BibTeX
@inproceedings{ahia2024magnet,
  author = {Orevaoghene Ahia and Sachin Kumar and Hila Gonen and Valentin Hofmann and Tomasz Limisiewicz and Yulia Tsvetkov and Noah A. Smith},
  title = {{MAGNET: Improving the Multilingual Fairness of Language Models with Adaptive Gradient-Based Tokenization}},
  booktitle = {Advances in Neural Information Processing Systems},
  year = {2024},
  url = {https://openreview.net/forum?id=1e3MOwHSIX},
}
Figure