SDE & MLE Prep

Decoding Strategies

Q: Greedy, beam search, temperature, top-k, top-p — when to use which?

  • Greedy: argmax each step; deterministic, can be repetitive.
  • Beam search: keep the b best partial sequences; good for translation/summarization with a "correct" answer; bland for open-ended text.
  • Temperature T: divide logits by T; T < 1 sharper (more deterministic), T > 1 more diverse.
  • Top-k: sample from the k most likely tokens. Top-p (nucleus): sample from the smallest set whose probability mass ≥ p (adapts to the distribution's shape).
  • Repetition/frequency penalties, stop sequences, constrained/structured decoding (JSON grammars) for reliable output formats.