speculative-decoding

Accelerate LLM inference using draft models, Medusa heads, and lookahead decoding techniques.

1|Updated Mar 5, 2026
One-click install
npx skills add https://github.com/Clay-HHK/claude-skills --skill speculative-decoding-clay-hhk
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: speculative-decoding
Source: https://github.com/Clay-HHK/claude-skills/tree/main/speculative-decoding
Command: npx skills add https://github.com/Clay-HHK/claude-skills --skill speculative-decoding-clay-hhk

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill requires transformers, torch, and includes references (resource) components.

What problem does it solve? Autoregressive LLM inference generates tokens sequentially, creating latency bottlenecks for real-time applications like chatbots and code generation. This Skill provides implementation guidance for speculative decoding, Medusa, and lookahead decoding to achieve 1.5-3.6× speedups without quality loss. ## Core Features & Use Cases - Draft Model Speculative Decoding: Use a small draft model to propose tokens that a large target model verifies in parallel via transformers' assisted generation. - Medusa Multiple Heads: Train lightweight prediction heads on a frozen or fine-tuned base model to generate candidate token trees verified in a single forward pass. - Lookahead Decoding: Apply Jacobi iteration with n-gram generation and verification branches for training-free speedups on any model. - Use Case: Deploy Llama-2-70b with a 7b draft model through vLLM's speculative decoding to serve low-latency chat responses at production scale. ## Quick Start Use the speculative-decoding skill to set up draft-model speculative decoding for my Llama-2-70b deployment with a 7b assistant model.

Frequently Asked Questions about speculative-decoding

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I speed up LLM inference with speculative decoding?▼

Speculative decoding uses a small draft model to generate candidate tokens that the large target model verifies in one parallel forward pass. In transformers 4.36+, pass the draft model as assistant_model to the target model's generate method for 1.5-2× speedup with no quality loss.

What is the difference between Medusa and draft model speculative decoding?▼

Medusa adds trained prediction heads directly to the base model, eliminating the need for a separate draft model and achieving 2-3.6× speedup. Draft model speculative decoding requires an external small model but needs no training, typically yielding 1.5-2× speedup.

How do I choose a draft model for speculative decoding?▼

Select a draft model 5-10× smaller than the target model from the same family for compatible tokenization. For example, use Llama-2-7b as the draft for Llama-2-70b; smaller targets under 13B benefit more from Medusa or lookahead decoding instead.

Does lookahead decoding require training or a draft model?▼

Lookahead decoding requires neither training nor a draft model. It reformulates autoregressive decoding as Jacobi iteration, generating and verifying n-grams in parallel to achieve 1.5-2.3× speedup out-of-the-box with any existing model.

Does speculative decoding reduce output quality?▼

Speculative decoding is mathematically equivalent to standard target-model sampling, so outputs have zero quality loss. Medusa-1 with a frozen backbone is also lossless, while aggressive Medusa-2 configurations may trade minor quality for higher speedup.

Can I use speculative decoding with vLLM in production?▼

Yes, vLLM supports speculative decoding by passing speculative_model and num_speculative_tokens parameters when initializing the LLM class. This enables production serving of large models like Llama-2-70b with a smaller draft model for reduced latency.