Introduction
Knowledge Distillation (KD) is a cornerstone technique for transferring capabilities from large "teacher" models to smaller, more efficient "student" models. However, standard KD methods assume that both models share the same tokenizer, allowing for direct comparison of output probabilities (logits). As the LLM landscape diversifies with models like Llama, Qwen, and Gemma using distinct vocabularies—and some moving toward byte-level processing—this assumption often fails.
Traditional cross-tokenizer distillation attempts have relied on computationally expensive heuristics or complex architectural additions that often degrade teacher performance. To address this, we present Approximate Likelihood Matching (ALM), a principled framework that enables seamless knowledge transfer across fundamentally different vocabularies by aligning "chunks" of tokens that represent the same underlying text.
Methodology: Approximate Likelihood Matching
The core innovation of ALM is shifting the focus from individual tokens to aligned chunks. A chunk is defined as a sequence of tokens from the teacher and student that maps to the exact same string of bytes.
The ALM process involves three primary steps:
- Tokenization: The input text is processed by both the teacher and student tokenizers.
- Chunk Identification: The system identifies comparable token sequences (chunks) that represent identical text segments.
- Likelihood Minimization: The model minimizes the difference in likelihood between these chunks.
Technical Innovations
- Chunk-Level Probability: The probability of a chunk is calculated as the product of the next-token probabilities within that sequence.
- Binarized f-divergence: To handle the infinite space of multi-token sequences, ALM treats the problem as a binary choice between a specific chunk and all other possible sequences, allowing for finite computation of divergence measures like KL-Divergence.
- Outcome Chunk Debiasing: ALM corrects for "tokenization bias" in subword tokenizers by adjusting chunk probabilities based on the marginal probability of boundary characters (e.g., spaces or newlines).
- GradMag: A simplified gradient-balancing technique ensures that distillation and standard language modeling losses contribute effectively to training without excessive overhead.
Experimental Setup
ALM was evaluated across several key domains:
- Instruction Tuning: Using the Tulu3 dataset to test tokenizer transfer (e.g., Gemma2 or Llama3 to the Qwen2 tokenizer).
- Math Specialization: Distilling a math-specialized 8B model into a 2B general-purpose model using OpenMathInstruct-2.
- General Benchmarks: Performance was measured across standard tasks including PiQA, ARC-Challenge, BoolQ, MMLU, AGIEval, IFEval, GSM8K, and MATH.
Key Results and Insights
ALM consistently outperforms existing heuristic-based methods and standard fine-tuning across various benchmarks.
Performance and Efficiency
In transferring Gemma2 2B to the Qwen2 tokenizer, ALM achieved an average score of 55.1, significantly higher than standard SFT (51.6) and the prior state-of-the-art MinED (53.0). Furthermore, ALM is highly efficient, requiring 34% less memory and fewer FLOPs than competing methods like DSKD by avoiding expensive cross-attention mechanisms.
Tokenizer Transfer and Ensembling
ALM effectively treats tokenizer transfer as a form of self-distillation, preserving original model behavior better than fine-tuning. It also enables token-level ensembling by mapping different models (e.g., Llama and Gemma) to a single "pivot" tokenizer and averaging their probabilities, resulting in performance that exceeds any individual model. Notably, ALM is the first method to successfully transfer subword-based models to byte-level architectures, paving the way for vocabulary-free models robust to multilingual noise.
Conclusion and Future Work
Approximate Likelihood Matching provides a robust, efficient framework for cross-tokenizer distillation. While currently demonstrated on 0.6 billion tokens, future work will explore scaling to trillion-token regimes and applying ALM to on-policy settings like Reinforcement Learning from Human Feedback (RLHF). Additionally, moving beyond "greedy" chunk alignment to overlapping sequences may further enhance performance.
Summary updated