Sampling Strategies: Greedy, Multinomial, Beam Search & Contrastive Search

~20 min read

Even with a probability distribution over next tokens, you still need a strategy to actually pick one. The 4 main strategies — greedy, multinomial, beam search, contrastive search — trade off speed, coherence, and diversity very differently.

Sampling Strategies: Greedy, Multinomial, Beam Search & Contrastive Search is a Pro topic

Sign in, then upgrade to Pro or Power to unlock this topic and the full AI Engineering curriculum.

Key points

  • Greedy: always picks the single highest-probability token — fast, deterministic, but prone to repetitive loops
  • Multinomial: samples from the probability distribution (shaped by temperature) instead of always taking the top token
  • Beam search: keeps the top-k PARTIAL sequences alive at each step, approximating whole-sequence maximization instead of greedy per-token choices
  • Beam search is widely used where correctness matters more than creativity, e.g. machine translation
  • Contrastive search: penalizes candidates too similar to what's already generated, balancing fluency with diversity to avoid repetition loops