What does nucleus (top-p) sampling do when picking the next token?

Samples only from the most likely tokens and cuts off the unreliable tail.

Start playing free

  1. Always picks the single most likely token
  2. Picks any token in the vocabulary equally
  3. Samples from the top tokens, dropping the unlikely tail ✔

Why: Top-p keeps the smallest group of tokens whose probabilities add up to p, then samples among them. You still get variety, but the weird low-probability tokens are thrown out.

Huh, didn't know that: Nucleus sampling was introduced in the 2019 paper The Curious Case of Neural Text Degeneration.

The dad joke
Nucleus sampling is like ordering at a restaurant. You pick from the favorites, not the mystery soup.
Like this card?
Play the game

References

Answer: Samples from the top tokens, dropping the unlikely tail. Top-p keeps the smallest group of tokens whose probabilities add up to p, then samples among them. You still get variety, but the weird low-probability tokens are thrown out.

  1. Holtzman et al., The Curious Case of Neural Text Degeneration (arXiv 1904.09751) arxiv.org/abs/1904.09751
    sampling text from the dynamic nucleus of the probability distribution, which allows for diversity while effectively truncating the less reliable tail
    Checked 2026-10-10.

Think this answer is wrong? Tap "Challenge this answer" on the card in the game and tell us why.

Test yourself in the game