speculative_decoding

Accelerate LLM inference with speculative decoding, Medusa heads, and Lookahead.

11.5k|842|Updated Nov 3, 2025
One-click install
npx skills add https://github.com/Orchestra-Research/AI-Research-SKILLs --skill speculative-decoding-orchestra-research
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: speculative_decoding
Source: https://github.com/Orchestra-Research/AI-Research-SKILLs/tree/main/19-emerging-techniques/speculative-decoding
Command: npx skills add https://github.com/Orchestra-Research/AI-Research-SKILLs --skill speculative-decoding-orchestra-research

SYSTEM DOCUMENTATION & REQUIREMENTS

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

What problem does it solve?

This Skill significantly accelerates Large Language Model (LLM) inference, reducing latency and increasing throughput without compromising output quality.

Core Features & Use Cases

  • Speculative Decoding: Utilizes a smaller "draft" model to predict tokens, which are then verified by the larger target model in parallel, achieving 1.5-3.6× speedup.
  • Medusa: Employs multiple decoding heads within the LLM to predict future tokens, enabling faster generation.
  • Lookahead Decoding: Reformulates decoding as an equation-solving problem, using Jacobi iteration for parallel verification of n-grams.
  • Use Case: Deploying real-time chatbots, code generation tools, or any application requiring low-latency LLM responses on constrained hardware.

Quick Start

Use the speculative_decoding skill to accelerate inference for the 'meta-llama/Llama-2-70b-hf' model using 'meta-llama/Llama-2-7b-hf' as a draft model.

Frequently Asked Questions about speculative_decoding

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

FAQPage Schema
How do I reduce LLM inference latency without compromising output quality?

Reduce LLM inference latency by using speculative decoding to verify tokens from a smaller draft model in parallel, achieving 1.5-3.6× speedup without compromising output quality. This avoids quality loss by verifying draft predictions against the target model.

Does speculative decoding work with vLLM and Hugging Face transformers?

Yes, speculative decoding works with vLLM and Hugging Face transformers because the Skill depends on both frameworks alongside PyTorch and Accelerate. This integration allows you to accelerate models like Llama-2-70b using a Llama-2-7b draft model directly.

What is the best way to speed up LLM generation on resource-constrained hardware?

The best way to speed up LLM generation on constrained hardware is deploying Medusa's multiple decoding heads or Lookahead Decoding, which reformulates decoding as an equation-solving problem using Jacobi iteration for parallel n-gram verification.

How does Lookahead Decoding compare to using a draft model for inference acceleration?

Lookahead Decoding differs from draft model inference acceleration by eliminating the need for a separate model, instead using Jacobi iteration to solve decoding equations and verify n-grams in parallel. Draft models require training a smaller model to predict tokens.

Do I need to train Medusa heads to use speculative decoding for my LLM?

No, you do not need to train Medusa heads to use speculative decoding, as the Skill supports multiple independent techniques. You can choose standard draft model verification, Medusa with its multiple decoding heads, or Lookahead Decoding based on your deployment needs.

Why does speculative decoding require a smaller draft model for my target LLM?

Speculative decoding requires a smaller draft model to efficiently predict future tokens, which the larger target LLM then verifies in parallel. This asynchronous verification process drastically reduces generation latency and increases overall throughput.