chat-gpt笔记:参数temperature与top_p

temperature

官方文档

temperature number or null Optional Defaults to 1

What sampling temperature to use, between 0 and 2. Higher values like 0.8 will make the output more random, while lower values like 0.2 will make it more focused and deterministic.

We generally recommend altering this or top_p but not both.
温度采样参数取值介于 0 和 2 之间。较高的值(如 0.8)将使输出更加随机,而较低的值(如 0.2)将使其更加集中和确定性。

我们通常建议此参数或top_p参数不要同时更改。

效果

随机性大可以理解为多次询问的回答多样性、回答更有创意、回答更有可能没有事实依据。随机性小可以理解为多次询问更有可能遇到重复的回答、回答更接近事实(更接近训练数据)。

作用机制

GPT 中的 temperature 参数调整模型输出的随机性。

下图显示不同温度值对单词出现在下一个位置的概率的影响:

top_p

官方文档

top_p number or null Optional Defaults to 1

An alternative to sampling with temperature, called nucleus sampling, where the model considers the results of the tokens with top_p probability mass. So 0.1 means only the tokens comprising the top 10% probability mass are considered.

We generally recommend altering this or temperature but not both.
有一种替代温度采样的方法,叫做核采样,模型会考虑概率质量在top_p内的tokens的结果。所以0.1意味着只有概率质量在前10%的tokens会被考虑。

我们通常建议此参数或temperature参数不要同时更改。

作用机制

top_p 参数接受的是一个累积概率,top_p 的大小影响到候选 token 的数量。

模型使用以下逻辑选择部分单词加入备选集合

  1. 对所有单词按照概率从大到小进行排序
  2. 将备选集合中的概率逐个相加,当超过top_n时停止处理后面的单词

假设有这几个单词可供选择,

单词 概率 累计概率
the 0.5 0.5
a 0.25 0.75
an 0.15 0.9
some 0.08 0.98
this 0.02 1

假设设定 top_p = 0.7 ,则备选集合为(the,a)

相关推荐
zhangrelay8 小时前
ROS项目设计案例智能大模型正经乱答案例
linux·笔记·学习·ubuntu·机器人
probex_8 小时前
学习笔记:知识图谱是什么,在测试里能干什么
笔记·学习·知识图谱
以为你知道啊9 小时前
90年代复古博客
笔记
波力海苔夹心脆67510 小时前
C# 值类型与引用类型详解:存储位置、赋值机制、参数传递、相等比较、装箱拆箱与常见陷阱
开发语言·jvm·经验分享·笔记·c#·.net
FluxArt10 小时前
GPT Image 2.5 中文提示词教程:Flux Art 可复用模板
前端·gpt·算法
张晓宇 .11 小时前
Codex 使用教程(2026年9月 0.158 最新版):安装、国内接入 DeepSeek / GPT-6、config.toml 配置与报错排查
gpt·大模型·openai·ai编程·codex·deepseek
乃嘿仔11 小时前
AI 热点日报 · 2026-09-30
人工智能·chatgpt
AOI小白新手上路12 小时前
从 Keil 调试视角看 51 指针,到 Cortex-M 内存映射访问寄存器 · 学习笔记
笔记·学习
坤坤子吖14 小时前
ELF加载、动态链接、GOT与PLT
linux·笔记·学习
烧烧的酒0.o14 小时前
Codex桌面版更新后不能使用最新模型问题-排查修复总结
chatgpt·bug