AlgoPlus//machine learning / sampling
Read the theory

Sampling & Decoding

Temperature, top-k, and top-p reshape the distribution before picking a token.

Strategy
Top-k (3)
Sampled
Decoding strategy
Legend
Adjusted prob
Cut off
Sampled
AI Tutor Workspace
In a nutshell
The model only gives you odds for the next token; a decoding strategy decides which one to actually output. Greedy always takes the single most likely token — safe but repetitive. Temperature is a dial that sharpens the odds below 1 (more focused) or flattens them above 1 (more creative). Top-k keeps only the k most likely tokens, and top-p (nucleus) keeps the smallest set whose odds add up to p; both throw away the unlikely tail, then rescale and randomly pick from what's left. Lower settings stay safe and on-topic; higher ones get more diverse and surprising.
Ready
Press play to begin the cinematic walkthrough.
The model hands you odds; you decide how adventurous to be. Always pick the favorite (greedy), or warm things up and roll the dice among the plausible few.
Key terms
Go deeper in the lesson
Read the full theory, intuition & complexity for Sampling & Decoding.