知识卡片
固定候选数与累计质量不同
top-k按排名固定保留数量,top-p按累计概率质量自适应决定集合;两者都需在保留集合上重归一化抽样。分布很尖或很平时,固定k可能分别保留低质量尾部或漏掉合理多样项。
这张卡片看不懂?
这张卡片已通过人工审查,不再接受失败反馈。
已有反馈 · 0 条
还没有人提交反馈。
在整书笔记中的位置
- · 按任务适配模型
原书出处 · 1 处
- · 查看原书依据
Top-k Sampling In top-k sampling, the model samples from a distribution of just the k tokens of the output distribution that have the highest probability. The probability mass is redistributed over the k tokens, and the model samples from this distribution to generate the next token. Hugging Face provides the top_k parameter in its generate function: output = model.generate(**inputs, max_new_tokens=50, do_sample=True, top_k=40) print(tokenizer.decode(output[0], skip_special_tokens=True)) Figure
参考来源
- 位置:《Designing Large Language Model Applications》第05章《按任务适配模型》(来源项目:a19c7933-4eda-4176-aebd-30fe7e1ad292;源文件:extracted/Designing Large Language Model Applications/_epub-src/OEBPS/ch05.html)
- 结论依据:摘录中关于固定候选数与累计质量不同的定义、比较或条件支撑卡片;原书表述不严谨的范围已在覆盖记录逐项限定,不把案例结果外推为普遍结论。
- 原始内容:Top-k Sampling In top-k sampling, the model samples from a distribution of just the k tokens of the output distribution that have the highest probability. The probability mass is redistributed over the k tokens, and the model samples from this distribution to generate the next token. Hugging Face provides the top_k parameter in its generate function: output = model.generate(**inputs, max_new_tokens=50, do_sample=True, top_k=40) print(tokenizer.decode(output[0], skip_special_tokens=True)) Figure