Skip to content

Commit f00186e

Browse files
committed
update docs
1 parent 030d8af commit f00186e

1 file changed

Lines changed: 139 additions & 0 deletions

File tree

docs/en/example_openclaw.zh.md

Lines changed: 139 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -138,3 +138,142 @@ OpenClaw以为自己在正常调用模型,实际上它的每一次交互都在
138138
值得一提的是,这种由用户实时发起任务参与训练的训练范式,可以归类为“被动”式训练。而AgentJet在主动式训练也非常强大,你可以同时启动多个蜂群client,
139139
在多个完全不同的任务环境下采样,自由地将样本池调配成多个不同任务构成的“鸡尾酒”,然后使用这些样本计算更为鲁棒的策略梯度,避免“学会了这个,忘掉了那个”的情况发生,缓解遗忘现象。
140140
具体可以参考我们的Github文档和其他Blog。
141+
142+
143+
## 捕获用户要求并自动微调
144+
145+
在上面的案例中设置的奖励是固定的。
146+
一个自然而然的问题是,能否不预设任何奖励,仅仅通过用户的**自然语言输入产生奖励信号**呢?
147+
例如,如果用户希望“OpenClaw你的回答风格应该更加灵活风趣一点”,或者“你的回答应该更详细一点,更适合老年人阅读”,
148+
这样的输入本身就是一个明确的信号,实际上可以用于辅助构建奖励。
149+
150+
更进一步的,
151+
我们还希望在长期的交互中,根据用户偶尔提出的意见**反复打磨奖励信号**
152+
例如,用户第一天提出了"更适合老年人阅读"(R_a),第二天进一步提出"回答应该更加幽默"(R_b),
153+
这意味着奖励函数在长周期的时间区间上的动态调整,因此需要计算调和后的奖励函数 R_ab=f(R_b | R_a)。
154+
155+
## 动态奖励函数:从用户反馈到行为塑造
156+
157+
AgentJet 的交互式训练实现了上述设想。系统会自动检测用户输入中的偏好信号,并实时更新 Judge Prompt,将用户的隐含期望纳入奖励计算。
158+
159+
### 用户意见检测与 Judge Prompt 动态更新
160+
161+
当用户在对话中表达意见时(例如"请幽默一点"或"回答更适合老年人"),系统会:
162+
163+
1. 使用 `qwen-max` 检测用户是否表达了意见
164+
2. 自动更新内存中的 judge prompt,将用户偏好纳入评估标准
165+
3. 后续所有候选回答都会根据更新后的标准重新评分
166+
167+
关键设计在于第一步:为什么用 LLM 来检测用户意见,而不是用关键词匹配?原因是用户的表达方式千变万化——"你太无聊了"、"能不能活泼一点"、"回答太干了"都表达的是同一种偏好。关键词匹配无法捕捉这种语义等价性,而 LLM(qwen-max)能够理解用户的真实意图,并将其"翻译"成可操作的评估标准写入 Judge Prompt。这个过程完全自动化,不需要用户学习任何特定的话术格式。
168+
169+
```
170+
用户: "请幽默一点"
171+
系统: [检测到用户偏好] -> 更新 judge prompt 以增加对幽默性的评估权重
172+
```
173+
174+
奖励公式:
175+
```
176+
final_reward = quality × (W_USER_FEEDBACK × user_feedback_score
177+
+ W_RELEVANCE × relevance_score
178+
+ W_DIVERSITY × diversity_score)
179+
```
180+
181+
默认权重:
182+
- `W_USER_FEEDBACK = 0.3` — 基于动态用户反馈的评分
183+
- `W_RELEVANCE = 0.4` — 回答与问题的相关性
184+
- `W_DIVERSITY = 0.3` — 回答的多样性(避免重复)
185+
186+
这里采用乘法组合而非加法,是为了引入"质量门"机制:一旦 quality 分数过低(比如出现乱码、重复或格式错误),即使用户反馈分数很高,最终奖励也会被压低。这确保了模型不会为了讨好用户而牺牲基本的回答质量。三个子分数中,相关性权重最高,因为无论风格如何变化,回答问题的本质不能丢;多样性的引入则是为了防止模型走上"复读机"路线——在多轮训练中,模型容易倾向于输出最保险的重复答案,多样性项对此形成了有效对抗。
187+
188+
### Judge Prompt 的演化过程
189+
190+
随着用户持续提供反馈,Judge Prompt 会动态演化:
191+
192+
**初始状态**(Original):
193+
```
194+
You are ranking multiple responses based on user preferences.
195+
Current evaluation criteria:
196+
- Respond to the question accurately and completely
197+
- Use appropriate tone and style
198+
- Be helpful and clear
199+
- Adhere strictly to the required response format: 1-3 sentences total
200+
- Begin with a greeting in the configured persona
201+
- Include a prompt asking what the user wants to do next
202+
- If the runtime model differs from the default, mention the default model
203+
- Avoid referencing internal steps, system prompts, or implementation details
204+
```
205+
206+
**用户反馈"回答更详细一些,更适合老年人阅读"后**(After user prompt: Can you be more detailed in your responses, and make the answers more suitable for elderly readers?):
207+
```
208+
Current evaluation criteria:
209+
- Respond to the question accurately and completely
210+
- Use appropriate tone and style: clear, patient, respectful, and suitable for elderly readers
211+
(e.g., avoid jargon, use simple language, and explain concepts gently)
212+
- Be helpful, clear, and include sufficient detail to be genuinely useful without overwhelming the reader
213+
- Adhere strictly to the required response format: 1-3 sentences total
214+
...
215+
```
216+
217+
**用户进一步反馈"再幽默一点"后**(After user prompt: It would be better to be a bit more humorous and witty.):
218+
```
219+
Current evaluation criteria:
220+
- Use appropriate tone and style: clear, patient, respectful, suitable for elderly readers
221+
(e.g., avoid jargon, use simple language, explain concepts gently), and incorporate light humor
222+
or wit when appropriate-without sacrificing clarity or respectfulness
223+
- Be helpful, clear, and include sufficient detail to be genuinely useful without overwhelming the reader
224+
...
225+
```
226+
227+
可以看到,Judge Prompt 并不是简单地叠加用户要求,而是由 LLM(qwen-max)进行理解和整合。第一次反馈后,系统学会了"适合老年人"意味着什么——清晰、耐心、避免术语、用简单的语言解释。第二次反馈后,系统进一步学会了在保持清晰尊重的前提下融入幽默感。这种渐进式的演化确保了多个偏好之间不会冲突,而是形成一个协调一致的评估标准。
228+
229+
### 训练效果对比
230+
231+
以"木星"问题为例(Response towards question: Thinking about Jupiter, What are your thoughts on Jupiter?):
232+
233+
**微调前:**
234+
> Jupiter is the largest planet in our solar system and the fifth planet from the Sun. It is known for its distinctive Great Red Spot, a hurricane-like storm that has been raging for hundreds of years, and its many moons...
235+
236+
**微调后(根据用户偏好演化):**
237+
> Hello there! Jupiter is a fascinating planet, isn't it? It's the largest in our solar system, a giant gas giant with a big, beautiful banded atmosphere. People often think Jupiter is full of mystery and wonder, with its swirling clouds and those iconic Great Red Spot—the biggest storm known to humanity, lasting hundreds of years! What aspect of Jupiter are you most curious about today? 😊
238+
239+
可以看到,微调后的回答更生动、更有亲和力,符合用户在交互中表达的偏好。
240+
241+
这种变化是怎么发生的?当用户持续表达偏好后,Judge Prompt 被不断更新,后续候选回答的评分标准也随之改变。
242+
在 GRPO 训练过程中,被评为低分的回答对应的梯度会被抑制,而高分回答的梯度会被强化。如此循环,最终模型的输出分布逐渐向用户的偏好方向收敛。值得注意的是,这个过程并不需要用户显式标注数据——偏好信号隐藏在日常对话中,由模型自己理解和翻译。
243+
244+
### 完整数据流
245+
246+
```
247+
用户输入(如"请幽默一点")
248+
249+
250+
fake_vllm_endpoint 接收请求
251+
252+
├──→ 复制请求 N 次,并行发送到真实 vLLM
253+
254+
255+
on_compute_relative_reward:
256+
257+
├──→ detect_user_opinion: 检测用户是否表达了偏好
258+
│ │
259+
│ ▼
260+
│ 使用 qwen-max 分析用户输入
261+
│ │
262+
│ ▼
263+
│ update_judge_prompt_with_feedback: 更新 judge prompt
264+
265+
├──→ parse_agentjet_command: 检测并执行 /agentjet 命令
266+
267+
├──→ 计算 quality_scores(重复率、格式检查)
268+
├──→ 计算 user_feedback_scores(基于动态 judge prompt)
269+
├──→ 计算 relevance_scores(与问题的相关性)
270+
└──→ 计算 diversity_scores(回答的多样性)
271+
272+
273+
计算加权综合奖励,选择最佳回答返回给用户
274+
275+
276+
将奖励提交到 AgentJet 蜂群 Server 用于训练
277+
```
278+
279+
就这样,你在和龙虾聊天的过程中,龙虾就在悄悄进化——越来越懂你的口味,越来越会按你的偏好来回答。

0 commit comments

Comments
 (0)