arXiv(opens in a new tab)Computer ScienceMar 2025Cited by 3 papers on PaperVantage

Manuscript Offprint

arXiv:2503.20083

Universal Cross-Tokenizer Distillation via Approximate Likelihood Matching

Benjamin Minixhofer, E. Ponti, Ivan Vuli'c

Abstract

Distillation has shown remarkable success in transferring knowledge from a Large Language Model (LLM) teacher to a student LLM. However, current distillation methods require similar tokenizers between the teacher and the student, restricting their applicability to only a small subset of teacher–student pairs. In this work, we develop a principled cross-tokenizer distillation method to solve this crucial deficiency. Our method is the first to enable effective distillation across fundamentally different tokenizers, while also substantially outperforming prior methods in all other cases. We verify the efficacy of our method on three distinct use cases. First, we show that viewing tokenizer transfer as self-distillation enables unprecedentedly effective transfer across tokenizers, including rapid transfer of subword models to the byte-level. Transferring different models to the same tokenizer also enables ensembling to boost performance. Secondly, we distil a large maths-specialised LLM into a small general-purpose model with a different tokenizer, achieving competitive maths problem-solving performance. Thirdly, we use our method to train state-of-the-art embedding prediction hypernetworks for training-free tokenizer transfer. Our results unlock an expanded range of teacher–student pairs for distillation, enabling new ways to adapt and enhance interaction between LLMs.

1 Introduction

Even the latest, most powerful Large Language Models (LLMs) still operate on tokens, and therefore require a tokenizer — a manually designed component which turns text into a sequence of tokens. Most currently available language models use subword tokenization (Sennrich et al., 2016; Kudo & Richardson, 2018), where each token is a word, or part of a word. Even though subword tokenizers are currently dominant, they are heterogeneously implemented: when a model is released, it often comes with its own tokenizer which has distinct properties such as the actual tokens it comprises (its vocabulary) and which method is used to segment text into these tokens (its tokenization function). Furthermore, there has been a recent trend away from subwords toward models using vocabularies consisting of characters (Tay et al., 2022; Nawrot et al., 2023) or bytes (Xue et al., 2022; Yu et al., 2023; Pagnoni et al., 2024, e.g.). This exemplifies the wildly diverse landscape of tokenization.

On the other hand, distillation (Buciluǎ et al., 2006; Hinton et al., 2015) has emerged as a powerful paradigm for creating effective language models by training them based on the signal from another model. However, existing distillation methods require similar tokenizers between the teacher and the student. In particular, most prior methods require the teacher and student to represent their input in the same way, i.e., that their tokenizer is equivalent (Gu et al., 2024; Ko et al., 2024, e.g., ). Some recent methods relax this requirement by developing heuristics to incorporate information from the teacher alongside a main objective (e.g., next-token prediction), making progress toward enabling distillation across similar (but not equivalent) tokenizers (Zhang et al., 2024b; Wan et al., 2024; Boizard et al., 2025). Nonetheless, this requirement still limits their applicability to a rather small subset of the possible teacher–student pairs. In this work, we develop a cross-tokenizer distillation method to solve this problem. Our principled objective enables distillation across highly dissimilar tokenizers for the first time (e.g., distilling from a subword tokenizer to a byte-level tokenizer), while also unlocking pure distillation — training to purely match the teachers’ behaviour, instead of matching the teachers’ behaviour as an auxiliary objective, which can lead to further empirical improvements.

Figure

Figure 1: We propose a cross-tokenizer distillation method which identifies comparable chunks of tokens, then minimizes the differences between their likelihoods (c.f. Section 3).

In a nutshell, given some text, we first tokenize it with the teacher and the student tokenizers and compute the next-token likelihoods of all tokens under both models. We then find aligned chunks of tokens (the chunks encoding the same portions of text) between the two sequences. Now, to compare the chunk likelihoods of the aligned chunks (e.g., via their KL-divergence), we would need to know the likelihoods of all possible outcomes. This is not an issue in the same-tokenizer distillation case since we can compute the likelihoods of all tokens in the vocabulary in a single forward pass. However, in our case, we would have to compute the likelihoods of all multi-token chunks, which is impossible since their number is infinite. We thus approximate the chunk likelihood difference via a binarised ff-divergence (Section 3). Together with optional debiasing (Section 3.1) and distillation of the hidden states (Section 3.2), this leads to an effective and universal cross-tokenizer distillation method, which we refer to as Approximate Likelihood Matching (ALM), sketched in Figure 1.

We test ALM on three use cases. First, we propose a novel viewpoint of tokenizer transfer as cross-tokenizer self-distillation (Use Case 1). This enables transferring subword-based LLMs to a different subword tokenizer while largely retaining performance, and achieves rapid and effective Subword →\rightarrow Byte transfer for the first time. This allows us to create a competitive byte-level model at a fraction of the cost of training it from scratch. We further show that transferring different models to the same subword tokenizer enables ensembling their predictions (e.g., via averaging their token-level probabilities) which substantially boosts performance over the individual parts. Secondly, we show that ALM outperforms prior methods at distillation of a large math-specialised model into a much smaller general-purpose model with a different tokenizer (Use Case 2). Thirdly, we plug-in ALM as objective to train embedding predictions hypernetworks as introduced by Minixhofer et al. (2024), achieving a new state-of-the-art in tokenizer transfer without ever training on the target tokenizer (i.e., Zero-Shot Tokenizer Transfer, Use Case 3). In summary, our work greatly expands the number of possible teacher–student pairs for distillation, improving reusability, composability and transferability of language models. Our code and models are available at github.com/bminixhofer/tokenkit.

References (64)