Overcoming Vocabulary Mismatch: Vocabulary-agnostic Teacher Guided Language Modeling

Haebin Shin, Lei Ji, Xiao Liu, Yeyun Gong

Introduction

Knowledge distillation—the process of transferring the capabilities of a large "teacher" model into a smaller, more efficient "student"—is a cornerstone of modern Large Language Model (LLM) development. However, this process has historically been constrained by a significant technical bottleneck: the requirement that both models share the exact same vocabulary and tokenizer. In an era where diverse tokenization schemes are used to optimize different models, this constraint forces researchers to choose teachers based on architectural compatibility rather than raw performance.

This paper introduces VocAgnoLM (Vocabulary-agnostic Teacher Guided Language Modeling), a framework that enables effective knowledge transfer between models with entirely different vocabularies. By leveraging character-level alignment and teacher-loss reweighting, VocAgnoLM allows a 1.1B student model to achieve a 46% performance boost by learning from a 7B teacher, even when the two models share as little as 6% of their vocabulary.

The Problem: The Vocabulary Bottleneck

Standard teacher-student guidance typically relies on comparing the output probabilities (logits) of the two models. When vocabularies differ, two primary issues arise:

  1. Token Sequence Mismatch: Different tokenizers chop the same sentence into different numbers of tokens. A single word might be one token for the student but three for the teacher, making direct step-by-step comparison impossible.
  2. Logit Distribution Divergence: You cannot directly compare the probability distributions of two models if their "output heads" represent different sets of tokens. Mapping a teacher's 50,000-word vocabulary to a student's 32,000-word vocabulary is mathematically complex and often lossy.

Because of these hurdles, researchers have often settled for weaker teachers that happen to share a vocabulary, missing out on the superior guidance offered by state-of-the-art (SOTA) specialized models.

The VocAgnoLM Framework

VocAgnoLM bypasses the need for shared vocabularies through two primary innovations:

1. Token-level Lexical Alignment

Instead of attempting to align tokens by index, VocAgnoLM uses character-level offsets from the raw text. The system maps each student token to the specific range of teacher tokens that cover the same character span. This creates a precise one-to-many (1:N) mapping that respects the linguistic boundaries of both models, ensuring the student is always being guided by the teacher's interpretation of the exact same text segment.

2. Teacher Guided Loss

Rather than trying to force the student to mimic the teacher’s exact logit distribution, VocAgnoLM uses the teacher’s loss as a signal. The framework treats the teacher as an "importance rater." If the teacher model exhibits low loss on a specific token (indicating high confidence and understanding) while the student exhibits high loss, that token is flagged as a high-priority learning signal. The student's training loss is then reweighted to focus on these high-value tokens, effectively filtering the training data to emphasize the most instructive examples.

Experimental Setup

The researchers evaluated VocAgnoLM in the demanding domain of mathematical reasoning.

  • Training Data: Models were trained on OpenWebMath, a 15-billion-token corpus of math-related web content.
  • Models: The student model was a TinyLlama 1.1B. Teachers included several 7B models: Mistral-ProXMath, DeepSeekMath, and Qwen2.5-Math.
  • Benchmarks: Performance was measured across 9 benchmarks, including GSM8k, MATH, MMLU STEM, and SAT.

Key Insights

The "Stronger Teacher" Rule

The most significant finding of the study is that teacher quality matters more than vocabulary similarity. For instance, Qwen2.5-Math-Instruct shares only ~6% of its vocabulary with TinyLlama. Despite this massive mismatch, it provided significantly better guidance than models with 100% vocabulary overlap. This suggests that the depth of the teacher's internal representations is more valuable than the surface-level alignment of their tokenizers.

Loss as a Universal Language

While logits are tied to specific vocabulary indices, cross-entropy loss is a universal metric of how well a model predicts a sequence. By using loss-based reweighting, VocAgnoLM bypasses the mathematical complexity of mapping different probability spaces, providing a cleaner and more scalable signal for distillation.

The Necessity of Granularity

The paper demonstrates that "coarse-grained" alignment (e.g., dividing text into equal chunks) is insufficient for high-level reasoning tasks. Precise lexical alignment—mapping based on the actual characters—is necessary to ensure the student receives the correct guidance for the specific word or symbol it is currently processing.

Results and Impact

VocAgnoLM demonstrated substantial improvements over existing methods:

  • Performance Gain: Using Qwen2.5-Math-Instruct as a teacher led to a 46% improvement over naive continual pretraining.
  • Superiority over Baselines: VocAgnoLM outperformed Universal Logit Distillation (ULD)—the previous SOTA for mismatched vocabularies—by a 33% margin on math tasks.
  • Efficiency: The method allows small models to "inherit" the specialized capabilities of high-performing teachers without the prohibitive cost of retraining the teacher or the student's tokenizer.

Conclusion and Future Work

VocAgnoLM effectively decouples the choice of teacher from the constraints of the student's architecture. While this study focused on the mathematical domain, the framework's reliance on universal metrics like character offsets and loss suggests it could be equally effective for general-purpose training, multi-modal models, or cross-lingual distillation.

Future research will focus on scaling this method to larger datasets and exploring whether students can eventually surpass their teachers by aggregating signals from multiple, vocabulary-diverse models simultaneously.

Summary updated

BibTeX
@inproceedings{shin2025overcoming,
  author = {Haebin Shin and Lei Ji and Xiao Liu and Yeyun Gong},
  title = {{Overcoming Vocabulary Mismatch: Vocabulary-agnostic Teacher Guided Language Modeling}},
  booktitle = {International Conference on Machine Learning},
  year = {2025},
  url = {https://openreview.net/forum?id=nXfZcVtykP},
}
Figure