Skip to content
AI Skills Central

Type to search Agent Skills, workflows, tutorials, tools and the glossary.

Speculative decoding

Definition

A speed-up where a small draft model proposes tokens and the large model checks them in one pass, keeping the ones it accepts.

In more detail

Generating one token at a time leaves a large model's hardware underused. With speculative decoding a cheap drafter, which can be a small model or extra prediction heads, guesses the next few tokens. The large model verifies them in parallel, accepts the matching prefix and corrects the first wrong one.

Done properly the output follows the same distribution as the large model alone, so quality does not change; only speed does. Gains depend on how often the drafter is right, which is high for predictable text such as code. Serving engines like vLLM and SGLang support it.

  • Inference

    Running a trained model to produce outputs, as opposed to training it. Inference cost and speed decide what an AI feature costs to run.

  • KV cache

    Memory where a transformer stores attention keys and values for tokens it has already processed, so it does not recompute them each step.

  • Latency

    The time from sending a request to a model to getting the response, often split into time to first token and total generation time.

  • Throughput (tokens per second)

    How many tokens a model or serving system generates per second, measured per request or across all requests.

  • vLLM

    High-throughput inference and serving engine for LLMs with an OpenAI-compatible server.

    Tool

  • SGLang

    High-performance serving engine for LLMs and multimodal models with fast prefix caching.

    Tool

  • Local models

    Running open-weight models on your own hardware for privacy, cost or offline use.

    SkillBeginner

  • LLM serving

    Running models behind an API for many users, tuned for latency, throughput and GPU cost.

    SkillAdvanced