Generative AI & LLMs
Top-k sampling
Choosing the next piece of AI-written text from a set number of the highest-scoring options.
Example
A generator allows selection from its top 40 candidate tokens.
Why people use it
It limits how many possible next pieces the AI may choose from.
What you'll hear
“Allow only the top few next-word choices.”
What this means for you
Tune the setting against actual quality and consistency needs.
Can you control it?
Sometimes
Sometimes. Your choices depend on the tool and your access. The settings available to an everyday user may differ from those available to the people running it.
Common questions
- Does a larger k guarantee better writing?
- No. It changes the range of choices and may increase variability.
- What happens if k is one?
- The system chooses only the highest-scoring option at each step, rather than sampling among several.
- Does the same k mean the same amount of variety every time?
- No. The likelihoods of the available choices can differ from one step to another.