Top-p (nucleus sampling)

Top-p restricts sampling to the smallest set of tokens whose probabilities sum to p.

Where temperature rescales the whole distribution, top-p truncates its tail, so unlikely tokens are never chosen. Tuning one of temperature or top-p is normally enough; adjusting both at once makes results hard to reason about.

All AI terms