À suivreGuide suivant
Échantillonnage typique
IA linguistique
GUIDE IA du langage
Top-k and nucleus (top-p) sampling are stochastic decoding methods that truncate a model’s next-token distribution before drawing a token.
Écoutez ce guideNarré par l'IA · ~2 min
Temperature rescales logits and changes distribution sharpness; none of these settings guarantees factual accuracy.
Holtzman et al. identify a gap between likelihood training and open-ended generation: likelihood-maximizing decoding can produce bland and repetitive text in their experiments. Nucleus sampling retains a dynamic set of tokens containing most probability mass and samples from it, trimming the unreliable tail. Top-k instead fixes the number of candidates. Later analysis explains properties and limitations of truncation heuristics; their findings are scoped to the studied models and tasks. For a no-sampling baseline, greedy decoding selects the highest-scoring next token directly. This removes token-sampling randomness for a fixed model and input; it does not guarantee correct code, and deployment-level reproducibility can also depend on system details.
Top-k keeps a fixed number of high-probability tokens at a step.
Top-p keeps the smallest probability-ranked set whose cumulative mass reaches the chosen threshold.
Temperature changes the relative sharpness of the distribution before sampling.
When evaluating open-ended outputs, compare decoding settings on diversity, coherence and repetition rather than assuming one setting is best.
Choose decoding settings by task-specific evaluation and record the model, prompt and sampling parameters for reproducibility. Assess diversity and coherence alongside task success. The cited papers do not establish a universal default or guarantee that sampling prevents repetition or errors.
Newsletter gratuite
Trois histoires d'IA vérifiées chaque matin de la semaine, écrites dans un anglais simple. Gratuit pour toujours, sans publicité.
Un e-mail chaque jour de la semaine. Désabonnez-vous en un clic. Nous ne vendons ni ne partageons jamais votre adresse.
Testez-vous
Commentaires instantanés sur chaque réponse et un certificat partageable avec une pièce d'identité vérifiable une fois que vous avez réussi un cours.
Soutenez l’enseignement gratuit de l’IA. AI Understanding est une organisation à but non lucratif 501(c)(3) : pas de publicité, pas de paywall, jamais. Faire un don
Top-k and nucleus (top-p) sampling are stochastic decoding methods that truncate a model’s next-token distribution before drawing a token. Temperature rescales logits and changes distribution sharpness; none of these settings guarantees factual accuracy.
Top-k tronque la distribution à un nombre fixe k de jetons les plus probables, les renormalise et en échantillonne.
Top-p conserve le plus petit groupe de jetons supérieurs dont la probabilité cumulée atteint le seuil p, puis échantillonne parmi eux.
L'ensemble des candidats de Top-p diminue lorsque le modèle est confiant et augmente lorsqu'il est incertain, contrairement au nombre fixe de top-k.
Une température plus basse concentre la probabilité sur les jetons supérieurs (plus déterministe) ; une température plus élevée l'aplatit (plus diversifiée).
Holtzman et al. report that sampling from the dynamic nucleus produced more diverse generations while retaining fluency and coherence in their evaluated setups; this is not a universal guarantee.
Continuez à apprendre
Plus de guides sélectionnés pour ce sujet
À suivreGuide suivant
Échantillonnage typique
IA linguistique