Decoding & sampling

Wiki chapters and blog posts about Decoding & sampling.

Wiki

Decoding and Sampling: Temperature, Top-k, Top-p and Beam Search

Decoding turns the model's output distribution into tokens: greedy picks the most likely one, temperature sharpens or flattens the distribution, top-k and top-p cut off the unlikely tail, and beam search keeps several candidates. Together they set how deterministic and diverse the output is.

Beginner 14 min read

Speculative Decoding: Draft with a Small Model, Verify with a Large One

Speculative decoding lets a small, fast draft model guess the next few tokens and the large model verify them in one parallel forward pass, with an accept-and-correct rule that keeps the output distribution unchanged. This page derives the expected speedup and lets you tune it interactively.

Intermediate 15 min read

Blog posts

Fast Inference from Transformers via Speculative Decoding

In speculative decoding a small draft model guesses several tokens, the large model verifies them in one parallel pass, and a sampling rule keeps the output distribution unchanged. This post reads the paper's formulas, recomputes its Tables 1 and 4, and explains the 1.4x to 3.4x measured on T5-XXL.

Paper notes ICML 2023

Topics