# Speculative decoding

> Canonical: https://skillalmanac.com/glossary/speculative-decoding | Last verified: 2026-11-25 | Index status: index-eligible

Speculative decoding aims to accelerate language-model generation by proposing candidate tokens cheaply and checking them together with the target model. A smaller draft model is one setup; other methods propose candidates without a separate model.

Also called: speculative sampling, draft model decoding, speculative decoding LLM.

## In plain language

A large language model writes text one small piece at a time, called a token, and each piece needs a full pass through a big, slow model. In the original two-model setup, a cheap helper guesses the next few pieces. The big model then checks all the guesses in one go and keeps the ones it agrees with. It is like a junior colleague drafting a sentence that a senior editor approves or corrects. The limit is that a poor helper wastes effort and can make things slower, and the gain depends on your hardware and workload. A separate helper can require extra memory; ngram proposals need no separate draft model.

## Technical definition

Leviathan, Kalman and Matias (arXiv, submitted 30 November 2022) describe decoding K tokens with a large autoregressive model as K serial model runs. Their method runs the large model in parallel over the outputs of a more efficient approximation model, with a sampling method designed to leave the output distribution unchanged. Hugging Face's May 2023 assisted-generation post describes a greedy shared-tokenizer setup: the main model checks candidates in one forward pass and discards the suffix after the first mismatch. This is a particular historical setup, not a method-wide tokenizer requirement. Current Transformers documentation supports different-tokenizer assistance, and vLLM documents ngram proposals without a separate draft model.

## How it shows up when you use agents

Speculative decoding sits inside the model server, not in your prompt or your agent. If you use a hosted service through Claude Code, Codex or Cursor, the provider decides whether to use it and you see just the response time. It becomes your decision when you run a model yourself with a server such as vLLM, where the documentation lists it as a way to reduce inter-token latency.

Agents make this relevant because a coding session produces many model calls in a row, and waiting for each reply adds up. A faster generation step can shorten the loop. That is a reason to try it, not a promise: the vLLM page says real gains depend on your model family, traffic pattern, hardware and sampling settings.

What breaks when it is misunderstood: people enable it and assume the output is unchanged. The standard method is designed to preserve the output distribution, but vLLM notes that floating-point errors may cause slight variations, and that one listed method relaxes verification and is not distribution preserving. A weak draft model can also slow generation down, as Hugging Face notes.

Next action: read your server's documentation for the method you pick, check the selected proposal method's model and tokenizer requirements, and measure speed and answer quality on your own prompts before relying on it. See [Inference](/glossary/inference) and [Large language model](/glossary/large-language-model).

## Common confusions

- **Speculative decoding versus a smaller model.** A smaller model replaces the large one and may give different answers. In speculative decoding the large model still checks the proposals.
- **Same distribution versus identical text every run.** The original paper's method aims to keep the output distribution unchanged. That is different from byte-identical text each run, and vLLM says it does not currently guarantee stable token logprobs.
- **Speculative decoding versus quantization.** [Quantization](/glossary/quantization) changes how a model's numbers are stored. Speculative decoding changes how tokens are produced and checked. They are separate techniques.
- **Myth.** "A draft model makes generation faster." Hugging Face says a weak assistant adds cost with little benefit, and measuring on your own workload is the safer habit.

## Worked examples in this catalogue

### [local-model-sizing](https://skillalmanac.com/skills/skill-almanac/local-model-sizing)

Status: illustrative example from the item's own documentation, not executed for this page.

What you see: The skill works out whether an open-weight language model will run on a given GPU, Mac or PC, with a script that computes weight, KV-cache and overhead memory per quantization.

Why it exercises the concept: A draft model is a second model that also needs memory. This skill sizes one model at a time, so use it for each model separately. The catalogue has no skill that configures speculative decoding.

### [Self-Hosting an AI Agent: What You Take On](https://skillalmanac.com/learn/self-hosted-ai-agent-considerations)

Status: illustrative example from the item's own documentation, not executed for this page.

What you see: A guide on what you own when an agent runs on your machine: model memory, network exposure, file access and vetting skills.

Why it exercises the concept: Speculative decoding is something you configure when you run the model server yourself, where memory is your own concern. The guide covers the surrounding decisions, not this feature.

### [llm-eval-test-sets](https://skillalmanac.com/skills/skill-almanac/llm-eval-test-sets)

Status: illustrative example from the item's own documentation, not executed for this page.

What you see: The skill builds and validates an eval dataset for any LLM feature, with a checker for duplicates, missing graders, imbalance and leakage.

Why it exercises the concept: vLLM's documentation says some methods are not distribution preserving and that gains depend on your setup. A fixed eval set lets you compare outputs before and after. The skill does not measure speed itself.

## Related terms

- [Inference](https://skillalmanac.com/glossary/inference.md)
- [Transformer](https://skillalmanac.com/glossary/transformer.md)
- [Token](https://skillalmanac.com/glossary/token.md)
- [Large language model (LLM)](https://skillalmanac.com/glossary/large-language-model.md)
- [Tokenizer](https://skillalmanac.com/glossary/tokenizer.md)
- [Quantization](https://skillalmanac.com/glossary/quantization.md)

## Sources

- [Fast Inference from Transformers via Speculative Decoding — Leviathan, Kalman and Matias](https://arxiv.org/abs/2211.17192), arXiv (accessed 2026-11-24)
- [Assisted Generation: a new direction toward low-latency text generation](https://huggingface.co/blog/assisted-generation), Hugging Face (accessed 2026-11-24)
- [Speculative Decoding](https://docs.vllm.ai/en/latest/features/speculative_decoding/), vLLM documentation (accessed 2026-11-24)
- [Text generation: assistant and tokenizer parameters](https://huggingface.co/docs/transformers/main_classes/text_generation), Official documentation (accessed 2026-11-25)

Definitions are written by Skill Almanac from the sources above and checked against them on 2026-11-25. [Glossary index](https://skillalmanac.com/glossary.md).
