Cross-Tokenizer Likelihood Scoring Algorithms for Language Model Distillation

Buu Phan, Ashish Khisti, Karen Ullrich · DOI

Abstract

Knowledge distillation is a cornerstone of efficient language model deployment, yet it faces a significant hurdle when the teacher and student models utilize different tokenizers. This "vocabulary misalignment" prevents direct comparison of probability distributions. We present a probabilistic framework leveraging the recursive nature of Byte-Pair Encoding (BPE) to enable exact or highly accurate likelihood scoring across disparate vocabularies. Our approach facilitates efficient vocabulary trimming and cross-model distillation, achieving state-of-the-art performance on reasoning and coding benchmarks while reducing memory footprints.

Introduction: The Vocabulary Misalignment Problem

In the pursuit of deploying large language models (LLMs) on resource-constrained edge devices, model distillation is frequently employed to transfer knowledge from a large "teacher" to a smaller "student." Standard distillation techniques assume a shared tokenizer; however, optimizing for specific hardware often necessitates custom, smaller vocabularies for the student.

When tokenizers differ, the probability space becomes misaligned. For instance, a teacher might predict the token "Distill" with high probability, while the student's tokenizer splits this into "Dis" and "till". This discrepancy introduces "tokenization bias," where the student cannot directly learn from the teacher's distribution because the target sequences are represented differently.

Figure 1: Illustration of vocabulary misalignment between Qwen2.5 and Gemma2 tokenizers. The conversion algorithm maps probabilities across different tokenization schemes.

Methodology: BPE as a Recursive Hierarchy

The core innovation of this work lies in treating Byte-Pair Encoding (BPE) not as a flat list of identifiers, but as a recursive hierarchy. Since BPE tokens are formed by iteratively merging pairs of existing tokens (starting from a base byte alphabet), any token can be "demerged" into its constituent parts to find common ground between different tokenizers.

Relative Alphabets and Operators

We define a "relative alphabet" where one vocabulary acts as an intermediate stage for another. By utilizing Merge and Demerge operators, the framework can traverse the BPE tree. This allows the system to translate the teacher's probability distribution into the student's token space without losing the nuanced signals inherent in the teacher's predictions.

Figure 5: The recursive structure of BPE vocabularies and the corresponding Merge/Demerge operators used for cross-tokenizer alignment.

Scoring Algorithms

  1. Full-to-Subset Conversion: When the student vocabulary is a strict subset of the teacher's, we provide an $O(1)$ algorithm for exact likelihood computation. This is ideal for "vocabulary trimming," where an existing model's head is reduced for efficiency.
  2. General Cross-Tokenizer Scoring: For arbitrary tokenizer pairs (e.g., distilling a Qwen teacher into a Gemma student), we derive a lossless recursive algorithm that accounts for all possible tokenization paths.
  3. Beam-Search Approximation: To mitigate the potential exponential complexity of the general case, we introduce a fast beam-search approximation. This identifies the most significant alignment terms, maintaining high fidelity (RMSE of 0.015) with minimal computational overhead.

Experimental Evaluation

The proposed methods were evaluated using Qwen2.5 (1.5B and 7B) and Gemma-2 (2B) models across several benchmarks, including GSM8K (mathematical reasoning), HumanEval/MBPP (Python coding), and DialogSum (summarization).

Key Results and Insights

The researchers found that "less is more" in many scenarios. Smaller, "trimmed" vocabularies can actually outperform larger ones because reducing the "output head" of the model allows the student to focus its parameters more effectively on the most useful tokens.

  • Memory Efficiency: Applying the method to the Qwen2.5-1.5B model resulted in a 12% reduction in memory footprint by trimming the vocabulary, while actually improving performance by up to 4% on reasoning tasks.
  • Distillation Superiority: On the GSM8K benchmark, this approach improved accuracy by more than 2% over the previous state-of-the-art method (Approximate Likelihood Matching).
  • Coding & Reasoning: In vocabulary trimming experiments, the "FKL" (Forward Kullback-Leibler) method consistently outperformed standard Supervised Fine-Tuning (SFT) and other alignment baselines across GSM8K, HumanEval, and MBPP.

Conclusion

By bridging the gap between disparate tokenizers, this framework enables more flexible and efficient model distillation. It resolves the "tokenization bias" that previously hindered the creation of specialized, small-vocabulary models. While currently optimized for BPE-based models, future work will explore adaptations for other tokenization schemes and further optimize search algorithms for massive-scale vocabularies.

Summary updated

BibTeX
@inproceedings{phan2026cross,
  author = {Buu Phan and Ashish Khisti and Karen Ullrich},
  title = {{Cross-Tokenizer Likelihood Scoring Algorithms for Language Model Distillation}},
  booktitle = {International Conference on Learning Representations},
  year = {2026},
  url = {https://openreview.net/forum?id=hD69qj15Os},
}
Figure