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

AI

AI's Word Selection: How Top-P Sampling Works

Joseph Fula 1 min read

When you ask an AI to generate text, it doesn't simply pick the most probable next word. Instead, it uses techniques like Top-P sampling to add variety and coherence. Also known as nucleus sampling, Top-P limits the AI's choices to a set of words whose cumulative probability reaches a threshold (e.g., 0.9). This means the AI dynamically selects from a smaller, more relevant pool of words, avoiding rare or nonsensical ones while still allowing for creativity. The result is text that feels more natural and less robotic. Understanding this mechanism helps demystify how large language models produce fluent responses.

React