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

AI

Decoding AI Creativity: Temperature, Top-K, and Top-P

datarekha 2 min read

In the latest episode of the Generative AI Podcast, the hosts dive deep into three critical parameters that shape the output of large language models: temperature, top-k sampling, and top-p (nucleus) sampling. These settings control the randomness and creativity of AI-generated text, making them essential tools for developers and users alike.

Temperature governs the "creativity" of the model by scaling the probability distribution of the next token. A low temperature (e.g., 0.2) makes the model more deterministic, favoring high-probability words, while a high temperature (e.g., 1.0) introduces more randomness, enabling diverse and surprising outputs.

Top-k sampling limits the model to consider only the k most likely next tokens. For instance, with k=10, the model picks from the top ten candidates, cutting off the long tail of improbable words. This technique helps maintain coherence while allowing some variation.

Top-p sampling (also called nucleus sampling) dynamically selects a set of tokens whose cumulative probability exceeds a threshold p (e.g., 0.9). Unlike top-k, which uses a fixed number, top-p adapts based on the distribution, providing a more flexible balance between randomness and relevance.

The podcast explains how these parameters interact, often used together to fine-tune model outputs for different tasks—from factual summarization (low temperature, low top-p) to creative storytelling (higher settings). The episode also warns that extreme values can lead to gibberish or repetitive loops.

For practitioners, understanding these knobs is key to controlling AI behavior without altering the underlying model. The episode is a must-listen for anyone working with generative AI.

React