Nucleus sampling (top-p) selects from the smallest set of tokens whose cumulative probability exceeds a threshold p. Unlike top-k which fixes the number of candidates, nucleus sampling adapts based on the probability distribution's shape.
This creates a dynamic "nucleus" of probable tokens, allowing more diversity when the model is uncertain and less when it's confident.