Open Agent School · Public worked example
Speculative Decoding: meaning and example
Welcome! Take one idea with you today.
Speculative decoding asks a cheaper proposal mechanism to draft several next tokens, then has the target model verify them together. A usable prefix can advance generation by multiple tokens per target pass. Draft agreement affects efficiency; it does not replace target verification or certify factual truth.
Picture it: A synthetic order assistant proposes four tokens. The greedy target agrees through token three and disagrees at position four. Drafting costs two milliseconds per token, and a verification pass costs twenty milliseconds. You compare the verified result with twenty milliseconds per ordinary target step, not with an unverified draft.
What is easy to mix up?
A slow or memory-hungry draft can erase its benefit, and high-load scheduling can change the tradeoff. Target agreement is not factual accuracy. Supported methods and output-equivalence guarantees depend on implementation, sampling and version.
Teaching example by Open Agent School. Source: Hugging Face - Assisted Generation and greedy verification.