Top-K and top-P
确定性:总是选择概率最高的 token(但需注意,若两个 token 的预测最高概率相同,根据平局处理方式的不同,即使温度参数设为 0 也可能得到不同输出)。
温度值接近上限时,输出随机性更强。随着温度值不断升高,所有 token 作为下一个预测 token 的出现概率会趋于均等。
Gemini 温度控制机制可类比机器学习中的 softmax 函数:低温设置类似低 softmax 温度 (T),突出单一优选温度的高确定性;高温设置则类似高 softmax 温度,使选定温度周围更大范围值变得可接受。这种增强的不确定性适用于非严格精准温度要求的场景,例如创意输出实验。
Top‑K 与 top‑P
Top‑K 与 top‑P(又称核采样)是大型语言模型中用于限制预测下一个令牌来自最高预测概率令牌的两种采样设置。与温度参数类似,这些采样设置控制生成文本的随机性和多样性。~
- Top‑K 采样从模型预测的分布中选择前 K 个最可能的令牌。top‑K 值越高,模型输出越具创
造性和多样性;top‑K 值越低,模型输出越受限且趋于事实性。top‑K 值为 1 时等同于贪婪解码。
全站分卷索引 · 34 卷
- 1Introduction
- 2Prompt engineering
- 3LLM output configuration
- 4Sampling controls
- 5Top-K and top-P
- 6Putting it all together
- 7Prompting techniques
- 8One-shot & few-shot
- 9System, contextual and role prompting
- 10System prompting
- 11Role prompting
- 12Contextual prompting
- 13Step-back prompting
- 14Chain of Thought (CoT)
- 15Self-consistency
- 16Tree of Thoughts (ToT)
- 17ReAct (reason & act)
- 18Automatic Prompt Engineering
- 19Code prompting
- 20Prompts for explaining code
- 21Prompts for translating code
- 22Prompts for debugging and reviewing code
- 23What about multimodal prompting?
- 24Design with simplicity
- 25Be specific about the output
- 26Control the max token length
- 27Experiment with input formats and writing styles
- 28Adapt to model updates
- 29JSON Repair
- 30Working with Schemas
- 31Experiment together with other prompt engineers
- 32CoT Best practices
- 33Summary
- 34Endnotes