Neura saysTop-k, top-p (nucleus), and repetition penalty refine which tokens sampling considers.
Raw sampling can pick absurd low-probability tokens. Top-k restricts choices to the k most likely; top-p (nucleus) keeps the smallest set whose probabilities sum to p (adapts to confidence). Repetition/frequency penalty discourages repeating tokens, avoiding loops. Together with temperature these are the decoding knobs — tune them per task to balance coherence, diversity, and avoiding repetition.
Power-ups you unlock
Top-k: limit to k most likely tokens
Top-p (nucleus): smallest set summing to p
Repetition penalty curbs loops
Tune with temperature per task
The Overfit Ogre attacks — common mistakes
Stacking aggressive penalties → incoherent text
Top-p=1 + high temp → gibberish risk
Same decoding for every task
Boss battleExplain how top-p adapts the candidate set to model confidence.
Example code
<!doctype html><html><head><meta charset="utf-8"></head>
<body style="background:#06040d;color:#e6e0ff;font-family:monospace;padding:20px"><pre>top-k: keep top 40 tokens
top-p 0.9: keep smallest set summing to 90%
repetition penalty: stop "the the the"</pre></body></html>