СледваСледващо ръководство
Типично вземане на проби
Езиков AI
Език AI РЪКОВОДСТВО
Top-k and nucleus (top-p) sampling are stochastic decoding methods that truncate a model’s next-token distribution before drawing a token.
Чуйте това ръководствоAI-разказан · ~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.
Безплатен бюлетин
Три проверени AI истории всяка делнична сутрин, написани на достъпен език. Безплатно завинаги, без реклами.
Един имейл всеки делничен ден. Отписване с едно кликване. Никога не продаваме и не споделяме вашия имейл адрес.
Тествайте себе си
Незабавна обратна връзка за всеки отговор и сертификат за споделяне с подлежащ на проверка идентификационен номер, след като преминете курс.
Подкрепете безплатното AI образование. AI Understanding е 501(c)(3) с нестопанска цел — без реклами, без платен достъп, никога. Направете дарение
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 съкращава разпределението до фиксиран брой k от най-вероятните токени, пренормира и взема проби от тях.
Top-p запазва най-малката група от топ токени, чиято кумулативна вероятност достига прага p, след което взема проби сред тях.
Наборът от кандидати на Top-p се свива, когато моделът е уверен, и расте, когато е несигурен, за разлика от фиксирания брой на top-k.
По-ниската температура концентрира вероятността върху горните токени (по-детерминистично); по-високата температура го изравнява (по-разнообразно).
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.
Продължавай да учиш
Още ръководства, избрани за тази тема
СледваСледващо ръководство
Типично вземане на проби
Езиков AI