DReSD: Dense Retrieval for Speculative Decoding

Milan Gritta, Huiyin Xue, Gerasimos Lampouras

Introduction

Large Language Models (LLMs) typically generate text auto-regressively, a process that is computationally expensive due to the need for a full model pass for every token. Speculative Decoding (SD) mitigates this by using a faster "draft model" to propose token sequences, which the target LLM then verifies in parallel. While retrieval-based SD methods like REST have shown promise, they rely on sparse retrieval (exact string matching), which is brittle and sensitive to minor variations in prompts. This paper introduces DReSD (Dense Retrieval for Speculative Decoding), which utilizes semantic dense retrieval to improve the robustness and efficiency of speculative decoding.

Methodology

DReSD shifts the drafting paradigm from surface-level string matching to semantic context matching. The pipeline involves extracting the last hidden state of the LLM to represent the current context. To ensure real-time performance, these high-dimensional embeddings undergo Z-score normalization and Principal Component Analysis (PCA). The authors demonstrate that compressing 4096-dimensional embeddings to just 64 dimensions (a 98% reduction) preserves sufficient information for accurate retrieval.

The DReSD pipeline for dense retrieval-based speculative decoding.

Using the compressed embeddings, DReSD queries a dense datastore via Scalable Nearest Neighbors (ScaNN). This process retrieves multiple candidate sequences that are semantically relevant to the current context, which are then verified in a single batch by the LLM.

Experimental Setup

The framework was evaluated on the Llama-2 model family (7B and 13B parameters) across two primary domains:

  • Code Generation: Evaluated on CodeAlpaca using a datastore derived from EvolInstructCode (~78k prompts).
  • General Assistant Tasks: Evaluated on MT-Bench using a subset of UltraChat-200K for the datastore.

The study compared DReSD against standard auto-regressive generation and existing speculative methods, including standard SD, Predictive Layer Decoding (PLD), and the sparse retrieval-based REST.

Results

DReSD significantly outperforms sparse retrieval methods in both acceptance rates and wall-clock speed. The system achieved an 87% higher mean acceptance rate (MAR) compared to the REST framework. This improved accuracy allowed the LLM to accept 65% more tokens per speculative step on average.

Decoding speed comparison across various speculative decoding methods.

In terms of raw performance, DReSD provided up to a 4.64x speedup over standard generation for code tasks and was 19% faster than the best-performing sparse retrieval baselines. While gains on general chat tasks were more modest (~1.52x), DReSD consistently demonstrated superior robustness to prompt variations and alignment levels.

Discussion and Limitations

The success of DReSD highlights the high redundancy in LLM hidden states and the power of semantic retrieval over exact matching. The authors identify three critical alignment factors for success: prompt alignment, response alignment, and sampling alignment.

Despite its performance gains, DReSD introduces a significant storage overhead, requiring 30x-40x more space for embeddings compared to raw text. Additionally, while the algorithm is faster, current sparse retrieval implementations are more mature. Future research may focus on optimizing these storage requirements and exploring dynamic datastores that update during inference.

Summary updated

BibTeX
@inproceedings{gritta2025dresd,
  author = {Milan Gritta and Huiyin Xue and Gerasimos Lampouras},
  title = {{DReSD: Dense Retrieval for Speculative Decoding}},
  booktitle = {Annual Meeting of the Association for Computational Linguistics},
  year = {2025},
}
Figure