the.ai

Inference / Decoding

verified

Nucleus Sampling

Top-k always keeps the same number of tokens, whatever the model thinks. Nucleus sampling keeps the same amount of probability instead: take tokens in order until their total reaches p, then sample from those. Where the model is confident that is one or two tokens; where it is unsure it may be hundreds.

Viz primitive · update-spectrump = 0.9 · bars = 8

8 values. The left group decays steeply; the right group is 99% of the way to flat, and reads flatter than the left.

The distribution with the nucleus highlighted against the tail it excludes. Drag p down to watch the tail get cut away and the kept set close to the few tokens the model is confident about.

0.9

Reviewed by opendroid · 2026-08-04