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

AI

How AI Selects Its Next Word: The Top K Mechanism Explained

Joseph Fula 1 min read

When you ask a generative AI to complete a sentence, it doesn't just pick the single most probable word. Instead, it uses a technique called Top K sampling to introduce variety and creativity. This method narrows down the list of possible next words to the top K most likely candidates, then randomly selects from that shortlist. The value of K controls the balance between coherence and surprise: a lower K (e.g., 10) yields more predictable text, while a higher K (e.g., 100) allows for more unexpected turns. This subtle tuning is what makes AI-generated content feel less robotic and more human.

React