Skip to content
ai

Top-p

Top-p (Nucleus) Sampling

Definition

Top-p (nucleus) sampling selects the smallest set of tokens whose cumulative probability exceeds p, then samples from this nucleus. Unlike top-k, the nucleus size adapts to the model's confidence — when the model is certain, few tokens dominate, and when uncertain, more tokens are included.

A typical production value is p=0.9 or p=0.95, balancing diversity against incoherence.


Ship secure code faster

Crash Override integrates security into the developer workflow. No context switching, no waiting on reviews.