Top-k sampling
Top-k sampling is a method that limits an AI model’s word choices to the k most likely options at each step.
When an AI tool writes text, it predicts likely next words and assigns each a chance. Top-k sampling keeps only the k most likely candidates and throws away the rest, then randomly picks from that short list. This matters because it controls how adventurous or predictable the output feels. A small k makes replies more focused and repeatable; a larger k allows more variety but can add odd choices. For example, if k is 3 and the top candidates are “the,” “a,” and “one,” the tool ignores every other possibility and chooses only among those three.