Top-p Sampling
also: nucleus sampling · top-k
Sampling from the smallest set of tokens whose probabilities sum to p — adaptive randomness control.
Top-p (nucleus) sampling keeps the most-probable tokens until their cumulative probability reaches p (say 0.9), then samples within that set. Unlike top-k (a fixed count), the nucleus adapts: confident distributions shrink it, flat ones widen it. Combined with temperature, these knobs trade determinism against diversity — low for code and extraction, higher for ideation.