the.ai

Inference / Decoding

verified

Top-k Sampling

Sampling from the full distribution occasionally picks something absurd, because the tail holds thousands of tokens that are each unlikely but collectively probable. Top-k keeps only the k most likely tokens, renormalises, and samples from those. The tail is cut off rather than merely made improbable.

Viz primitive · update-spectrumk = 8 · bars = 8

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

The token distribution before truncation and after, renormalised. Drag k to watch the tail disappear and the remaining mass redistribute.

8

Reviewed by opendroid · 2026-08-04