← Back to Glossary
Top-K & Top-P Sampling
Top-K and Top-P (Nucleus) Sampling
Filtering methods that restrict next-word choices to either the K most likely words or the top pool adding up to cumulative probability P.
Why it exists
High temperature sampling can occasionally select nonsensical long-tail words. Top-K and Top-P prune bad choices before sampling.
How it works
Top-K caps the candidate pool to the top K tokens (e.g. 50). Top-P dynamically keeps tokens until their combined probability reaches P (e.g. 0.9).
Related terms
Where you'll use this
roadmap