AI / LLM Basics Interview Questions
What are Top-k and Top-p Sampling?
Top-k and top-p are two related techniques that limit which tokens a model is allowed to consider when picking its next word, rather than sampling from the full vocabulary every time.
- Top-k sampling: restricts the choice to only the k highest-probability tokens
- Top-p sampling, also called nucleus sampling: restricts the choice to the smallest set of tokens whose combined probability adds up to at least p
Both exist to avoid the model occasionally picking a bizarre, very-low-probability token purely by chance, while still allowing some genuine variety in its output, unlike always picking the single most likely token.
More Related questions...