Top-p (Nucleus) Sampling
Also known as: Nucleus sampling
Sample from the smallest token set whose probabilities sum to ≥p; an adaptive alternative to top-k.
A decoding strategy that samples the next token from the smallest set whose cumulative probability exceeds p. Adapts the candidate pool size dynamically: broad when many tokens are plausible, narrow when one dominates.
In practice
One of the two main decoding knobs (with temperature). Interviews probe its interaction with temperature and why low-p + temp=0 are duplicative.
How it compares
Temperature reshapes the probability curve; top-p truncates the tail before sampling.
Related topics
Related terms
KV Cache
Cache attention's K and V tensors per layer so each new token doesn't re-process every prior token.
Temperature
Sampling knob (low = focused, high = diverse), applied to the logits before softmax.
Quantization
Run the model at lower numerical precision to save memory and accelerate inference.
FlashAttention
A memory-aware attention kernel that's 2-4x faster than vanilla, with identical math.
Grouped-Query Attention (GQA)
Compromise between MHA and MQA: query heads share KV heads in groups, cutting KV cache by 4-8x.
Knowledge Distillation
Train a small student model to match a big teacher's outputs: cheap, fast inference with most of the quality.