Abstract
Autoregressive decoding is the primary bottleneck in Large Language Model (LLM) inference, requiring a full forward pass for every generated token. Speculative decoding mitigates this by using a draft model to propose candidate tokens, but this adds significant system complexity and memory overhead. We present PROMTEC (Prompt Multi-Lookup with Template Database and Common Sequences), a retrieval-based framework that eliminates the need for a separate draft model. PROMTEC leverages three lookup strategies—Prompt Multi-Lookup, Template Datastores, and Common Sequences—to generate high-quality speculative candidates. These candidates are verified in parallel using tree attention. Our experiments on mathematical reasoning and code generation benchmarks show that PROMTEC achieves speedups of up to 4.23x, outperforming both standard decoding and existing retrieval-based methods.
1. Introduction
The efficiency of LLM inference is limited by the sequential nature of token generation. While speculative decoding has emerged as a promising solution, the requirement for a secondary draft model limits its practical deployment. PROMTEC addresses this by observing that in structured domains like math and code, the "DNA" of the output is often present in the input prompt or in common structural patterns. By replacing the draft model with efficient retrieval mechanisms, PROMTEC provides a lightweight and high-performance alternative.
2. Methodology
PROMTEC replaces the draft model with a multi-faceted retrieval system. These lookups are highly efficient, typically requiring less than 1ms, which is negligible compared to the hundreds of milliseconds required for an LLM forward pass. The system employs three distinct retrieval strategies to generate candidate sequences for a single verification pass by the target LLM.
2.1 Prompt Multi-Lookup
PROMTEC extends Prompt Lookup Decoding (PLD) by using a reversed Z-function algorithm to scan the input prompt for multiple repeating patterns. Unlike PLD, which typically identifies a single match, PROMTEC retrieves several potential continuations, significantly increasing the probability of a successful speculative guess.
2.2 Template Datastore
For domains with rigid structures, such as LaTeX mathematics or Python code, PROMTEC utilizes a Template Datastore. This datastore organizes frequent patterns into a trie structure. To ensure broad applicability, patterns are "normalized" during construction: specific variables are replaced with generic placeholders (e.g., -1, -2). This allows the system to match structural templates even when the specific variable names in the prompt differ from those in the datastore.
2.3 Common Sequences
As a fallback mechanism, PROMTEC maintains a database of frequently occurring short sequences and single-variable formulas. This ensures that even in the absence of prompt-specific or template-based matches, the system can still accelerate the generation of standard phrases and common LaTeX snippets.
2.4 Parallel Verification and Tree Attention
The retrieved candidates are organized into a token tree. PROMTEC utilizes tree attention to verify all potential paths in a single forward pass of the LLM. This process is highly efficient; the authors found a linear relationship between the logarithm of the model's forward time and the number of nodes in the tree, allowing for the optimization of tree size to maximize the Mean Accepted Tokens (MAT) without incurring significant verification latency.
3. Evaluation and Results
PROMTEC was evaluated on the miniF2F (Olympiad-level math) and HumanEval (Python coding) benchmarks.
- Mathematical Reasoning: Using Llama 2 7B, PROMTEC achieved a 3.91x speedup. This significantly outperformed the REST datastore method (1.78x) and traditional speculative decoding with a TinyLlama 1B draft model (1.65x).
- Code Generation: On HumanEval with Code Llama 7B, PROMTEC achieved a peak speedup of 4.23x.
- Decoding Efficiency: The Mean Accepted Tokens (MAT) increased from 1.0 in standard decoding to as high as 5.74 in coding tasks, effectively skipping nearly five autoregressive steps per forward pass.
4. Conclusion
PROMTEC demonstrates that retrieval-based speculative decoding is a powerful alternative to draft-model approaches. By leveraging normalized templates and multi-pattern prompt lookups, it achieves substantial speedups with minimal computational overhead. Future work will explore the application of PROMTEC to less structured domains and the refinement of fallback mechanisms for novel expressions.
Summary updated