跳转到主要内容

生成参数

调整这些设置以控制模型输出。

关键参数

Temperature

控制回复中的随机性。
效果用例
0.0 - 0.3非常一致,确定性事实性答案,代码
0.5 - 0.7平衡一般对话
0.8 - 1.0更多变化,创造性创意写作
1.0+非常随机头脑风暴
Low temperature (0.3):  "The capital of France is Paris."
High temperature (1.2): "Paris, the city of lights, serves as France's bustling capital!"

Max Tokens

回复的最大长度。
典型用途
50-100简短答案
256标准回复
512-1024详细解释
2048+长文本内容
更大的 max tokens = 更长的生成时间。

Top-p (Nucleus Sampling)

将 token 选择限制为累积概率。
  • 0.95 (UI 默认值) - 考虑直到 95% 概率质量的 tokens
  • 0.9 - 稍微更聚焦
  • 0.5 - 非常聚焦

Top-k

限制为 k 个最可能的 tokens。
  • 50 (默认值) - 考虑前 50 个 tokens
  • 10 - 非常聚焦
  • 100 - 更多变化

参数组合

事实性问答

temperature: 0.3
max_tokens: 256
top_p: 0.9
一致、准确的答案。

创意写作

temperature: 0.9
max_tokens: 1024
top_p: 0.95
多样化、创造性的输出。

代码生成

temperature: 0.2
max_tokens: 512
top_p: 0.95
精确、语法正确的代码。

对话

temperature: 0.7
max_tokens: 256
top_p: 0.9
自然、多样化的回复。

找到正确的设置

从默认值开始

默认设置适用于大多数情况:
  • temperature: 0.7
  • max_tokens: 256
  • top_p: 0.95
  • top_k: 50
  • do_sample: true

UI 滑块范围

聊天界面提供以下参数范围:
参数最小值最大值步长默认值
Temperature020.10.7
Max Tokens50204850256
Top P010.050.95
Top K0100550

一次调整一个

  1. 如果回复太随机 → 降低 temperature
  2. 如果回复太重复 → 提高 temperature
  3. 如果回复被截断 → 增加 max_tokens
  4. 如果回复太长 → 减少 max_tokens

系统化测试

对于重要应用:
  1. 选择 5-10 个测试提示
  2. 尝试每个参数设置
  3. 比较输出
  4. 记录有效的方法

高级参数

Repetition Penalty

减少重复短语。
  • 1.0 - 无惩罚
  • 1.1 - 轻微惩罚(推荐)
  • 1.3+ - 强惩罚

Stop Sequences

当这些 tokens 出现时结束生成。
  • 对结构化输出有用
  • 示例:["\n\n", "User:"]

Do Sample

控制是否使用采样或贪心解码。
  • true (默认值) - 使用 temperature/top-p/top-k 进行采样
  • false - 贪心解码(总是选择最可能的 token)

System Prompt

设置系统消息以指导模型行为。可在聊天界面设置面板中使用。 示例 system prompts:
  • “You are a helpful coding assistant. Provide concise code examples.”
  • “You are a creative writing partner. Be imaginative and descriptive.”
  • “You are a technical documentation expert. Be precise and thorough.”
System prompt 会前置到对话上下文中,并在整个会话期间影响模型的响应方式。

参数效果总结

参数低值高值
temperature一致,聚焦随机,创造性
max_tokens短回复长回复
top_p聚焦多样化
top_k非常聚焦更多选项
repetition_penalty可能重复避免重复

下一步