Accelerating LLM Inference with Lossless Speculative Decoding Algorithms for Heterogeneous Vocabularies

Nadav Timor, Jonathan Mamou, Daniel Korat, Moshe Berchansky, Gaurav Jain, Oren Pereg, Moshe Wasserblat, David Harel

Accelerating the inference of Large Language Models (LLMs) is a critical challenge in generative AI. Because LLM inference is notoriously "memory-bound"—meaning the bottleneck lies in moving model weights into memory rather than the actual computation—techniques like Speculative Decoding (SD) have become essential.

In standard SD, a tiny, fast "drafter" model guesses several tokens ahead, and the massive "target" model verifies them all in a single parallel pass. However, current SD techniques suffer from a major constraint: the drafter and target must share the exact same vocabulary and tokenizer. If you want to speed up a state-of-the-art model like Mixtral or Llama-3, you cannot simply grab a random small model off the shelf. Instead, you are forced to find or train a "mini-me" version that speaks the exact same token language, limiting the pool of available drafters and often necessitating expensive retraining.

Recent research introduces three new algorithms—SLEM, TLI, and SLRS—that break this vocabulary barrier. These methods enable lossless speculative decoding between models with completely different vocabularies, delivering up to 2.8x speedups using off-the-shelf models without any additional training.

Breaking the Vocabulary Barrier

The researchers propose three distinct algorithms to enable heterogeneous speculative decoding while remaining lossless (ensuring the final output is mathematically identical to what the large target model would have produced alone):

  1. SLEM (String-Level Exact Match): The most practical of the three, SLEM uses plain text as a "universal translator." The drafter produces tokens, which are converted to text and then re-tokenized for the target model. Crucially, SLEM includes a "look behind" mechanism to handle non-injective tokenizers—cases where encoding a string and then decoding it doesn't return the original input, a common headache in NLP.
  2. TLI (Token-Level Intersection): A purely token-based approach. It mathematically adjusts the drafter’s probability distribution so it only samples tokens that exist in both the drafter's and the target's vocabularies.
  3. SLRS (String-Level Rejection Sampling): A novel, theoretically optimal verification mechanism. Instead of checking if tokens match exactly, it performs rejection sampling at the string level. While mathematically elegant, it can be computationally expensive for vocabularies with very long tokens due to the exponential number of ways to decompose a long string into tokens.

Key Insights and Empirical Results

The researchers evaluated their methods across diverse domains, including text summarization (CNN/DailyMail), Python code generation (OpenAI HumanEval), and long-context reasoning (SCROLLS). They tested a wide array of model pairs, mixing families like DeepSeek, Phi, Mixtral, Qwen, Llama, and Starcoder.

By removing vocabulary constraints, any small, fast model can now act as a "scout" for any large model. For example, a tiny 68M parameter Vicuna model can draft for a massive 141B Mixtral model, even if they were trained by different organizations years apart.

Performance of the TLI Algorithm

As shown in the TLI performance evaluations, the Token-Level Intersection method consistently accelerates inference, reaching up to a 1.77x speedup (e.g., pairing CodeLlama-13b with a tiny_starcoder_py drafter on HumanEval).

Performance of the SLEM Algorithm

SLEM proved even more effective in many scenarios. By proving that raw text is a viable intermediate representation for SD, SLEM achieved up to a 2.79x speedup over standard autoregressive decoding. The overhead of re-tokenizing text was found to be negligible compared to the massive gains of skipping target model forward passes.

Interestingly, because the pool of potential drafters is now virtually unlimited, the authors found cases where an off-the-shelf model from a different family actually performed better as a drafter than the "official" smaller version of the target model.

Real-World Impact and Future Directions

These algorithms are not just theoretical exercises. The SLEM and TLI algorithms proved so effective and robust that they have already been integrated into the Hugging Face Transformers library as the default behavior for heterogeneous speculative decoding.

While the results are highly promising, there are still limitations to explore:

  • SLRS Scalability: Algorithm 3 (SLRS) is currently impractical for models with large vocabularies due to the "combinatorial explosion" of possible token sequences. It remains best suited for "byte-level" models.
  • Drafter Alignment: Even if vocabularies match or are bridged, SD only works well if the drafter is "smart" enough to guess what the target model would say. Future work will focus on finding better ways to align these heterogeneous models without full retraining.
  • Small Vocabularies: Exploring how these algorithms perform with extremely small-vocabulary drafters could further reduce computational overhead.

By enabling any off-the-shelf model to serve as a drafter, this work substantially broadens the applicability of the Speculative Decoding framework, making faster LLM inference accessible to a much wider range of developers and use cases.

Summary updated

BibTeX
@inproceedings{timor2025accelerating,
  author = {Nadav Timor and Jonathan Mamou and Daniel Korat and Moshe Berchansky and Gaurav Jain and Oren Pereg and Moshe Wasserblat and David Harel},
  title = {{Accelerating LLM Inference with Lossless Speculative Decoding Algorithms for Heterogeneous Vocabularies}},
  booktitle = {International Conference on Machine Learning},
  year = {2025},
  url = {https://openreview.net/forum?id=vQubr1uBUw},
}
Figure