One probability distribution. Many possible continuations.

Greedy decoding commits early, beam search keeps several hypotheses alive, and nucleus sampling draws from a dynamic probability mass. Change the controls and watch the same token tree produce different text paths.

Open decoding tree

Local certainty can hide a better sequence.

The most likely token now does not guarantee the most likely complete sequence. Search strategies trade computation, diversity, and global sequence score. Sampling adds controlled randomness; beam search systematically prunes; greedy decoding spends one path.

Root context · no branch selectedDrag to orbit · wheel to zoom
survivingprunedselected
Active hypotheses1

Partial sequences retained after pruning.

Best log score0.00

Accumulated token log-probability with length normalization.

Tokens evaluated0

Candidate next tokens scored across active branches.

Path diversity0.00

Fraction of retained hypotheses with distinct prefixes.

Greedy commits immediately

Select the highest-probability token at every step. It is fast and deterministic but cannot recover when an early local choice blocks a stronger full sequence.

yₜ = argmaxᵥ p(v | y<t, x)

Beam search delays commitment

Expand every retained hypothesis, add token log-probabilities, and keep the best B candidates. Length penalties reduce the bias toward prematurely short sequences.

score(y) = log p(y|x) / length(y)^α

Nucleus sampling adapts the candidate set

Sort tokens by probability and keep the smallest set whose cumulative mass reaches p. High-entropy contexts admit more tokens; confident contexts admit fewer.

V(p) = min set where Σᵥ∈V p(v) ≥ p

Wide beams

Search more sequences but multiply memory and compute. Larger beams can favor generic, high-probability continuations.

More search is not always better text.

High temperature

Flattened logits make lower-probability tokens more competitive, increasing diversity and error risk.

Temperature changes probabilities before truncation.

Low top-p

A small nucleus excludes the long tail and behaves more deterministically when probability is concentrated.

The candidate count changes at every step.

Primary reading

Google's Neural Machine Translation System: Bridging the Gap Wu et al.The Curious Case of Neural Text Degeneration Holtzman et al.Hierarchical Neural Story Generation Fan et al.Typical Decoding for Natural Language Generation Meister et al.