Thursday, December 3, 2026 | London 11°C · Drizzle
DailyGlimpse

AI

Mastering AI Output: How Top-p Controls Randomness Better Than Temperature

sourcecode 1 min read

When using AI language models, you've probably tweaked the temperature setting to control creativity. But there's another parameter that experts argue is even more important: top-p, or nucleus sampling.

Here's how it works. When an AI model predicts the next word in a sentence, it assigns a probability to thousands of possible options. For example, completing "the cat sat on the..." might give "mat" a 50% chance, "floor" 15%, "bed" 10%, and "bicycle" a mere 0.001%.

Top-p decides which of these options are even considered. With top-p set to 0.9, the model keeps only the top words whose cumulative probabilities reach 90%. A top-p of 0.5 narrows the list even further. Unlikely words like "bicycle" are cut entirely.

This is distinct from temperature. While temperature influences how the model chooses from the shortlist, top-p determines the composition of that shortlist. A low top-p prevents odd words from appearing, even if temperature is cranked high.

Think of temperature as controlling chaos, and top-p as controlling which chaos has a chance to play. For smarter, more controlled randomness, use both together.

React