npx skills add ...
npx skills add firecrawl/ai-research-skills --skill speculative-decoding
Accelerate LLM inference using speculative decoding, Medusa multiple heads, and lookahead decoding techniques. Use when optimizing inference speed (1.5-3.6× speedup), reducing latency for real-time applications, or deploying models with limited compute. Covers draft models, tree-based attention, Jacobi iteration, parallel token generation, and production deployment strategies.
npx skills add firecrawl/ai-research-skills --skill speculative-decoding
Use Speculative Decoding when you need to:
Key Techniques: Draft model speculative decoding, Medusa (multiple heads), Lookahead Decoding (Jacobi iteration)
Papers: Medusa (arXiv 2401.10774), Lookahead Decoding (ICML 2024), Speculative Decoding Survey (ACL 2024)
Idea: Use small draft model to generate candidates, large target model to verify in parallel.
Algorithm:
Performance:
Source: arXiv 2401.10774 (2024)
Innovation: Add multiple prediction heads to existing model, predict future tokens without separate draft model.
Architecture:
Training:
Tree-based Attention:
Advantages:
Source: ICML 2024
Core idea: Reformulate autoregressive decoding as solving system of equations, solve in parallel using Jacobi iteration.
Mathematical formulation:
Two branches:
Lookahead Branch: Generate n-grams in parallel
Verification Branch: Verify promising n-grams
Performance:
| Method | Speedup | Training Needed | Draft Model | Quality Loss |
|---|---|---|---|---|
| Draft Model Speculative | 1.5-2× | No | Yes (external) | None |
| Medusa | 2-3.6× | Minimal (heads only) | No (built-in heads) | None |
| Lookahead | 1.5-2.3× | None | No | None |
| Naive Batching | 1.2-1.5× | No | No | None |
Draft Model Speculative:
Medusa:
Lookahead:
references/draft_model.md - Draft model selection and trainingreferences/medusa.md - Medusa architecture and trainingreferences/lookahead.md - Lookahead decoding implementation details