Ver código fonte

docs(chapter11): 为 GRPO 学习率补充策略坍塌提示(注释与说明)

章节 11 的 GRPO demo 与文档建议学习率 1e-5~5e-5,在小参数模型
(如 Qwen3-0.6B)+ GSM8K 上,5e-5 会导致 GRPO 策略坍塌
(准确率 57.0% → 2.4%),1e-6 可稳定收敛。

本次仅做注释与文档层面的补充,不改动任何代码行为:
- code/chapter11/00_quick_test.py、05_grpo_training.py:在 GRPO 配置处
  添加注释,提示学习率过大可能导致策略坍塌,必要时可调至 1e-6;
- docs/chapter11(中英两版):GRPO 学习率建议改为 1e-6~1e-5,并提示风险。
Meredith2328 2 dias atrás
pai
commit
046f71bae6

+ 3 - 0
code/chapter11/00_quick_test.py

@@ -83,6 +83,9 @@ def quick_test():
     # ========================================================================
     print("\n测试3: GRPO训练")
     print("-"*80)
+
+    # 注意:GRPO 对学习率比较敏感,默认 5e-5 在小模型(如 Qwen3-0.6B)上
+    # 可能导致策略坍塌(准确率大幅下降),如需更稳定可显式设置 learning_rate=1e-6。
     
     grpo_config = {
         "action": "train",

+ 1 - 1
code/chapter11/05_grpo_training.py

@@ -75,7 +75,7 @@ def standard_grpo_training():
         # 训练配置
         "num_epochs": 3,
         "batch_size": 2,  # GRPO需要更多显存
-        "learning_rate": 1e-5,  # 比SFT小10倍
+        "learning_rate": 1e-5,  # 比SFT小10倍;注意:5e-5 在小模型上可能导致策略坍塌,必要时可调至 1e-6
         
         # LoRA配置
         "use_lora": True,

+ 1 - 1
docs/chapter11/Chapter11-Agentic-RL.md

@@ -1258,7 +1258,7 @@ GRPO has some specific parameters that need to be understood and tuned.
 
 **Optimization Parameters**:
 
-- `learning_rate`: GRPO's learning rate is usually smaller than SFT because we don't want to deviate too far from the SFT model. Recommend 1e-5 to 5e-5.
+- `learning_rate`: GRPO's learning rate is usually smaller than SFT because we don't want to deviate too far from the SFT model. Recommend 1e-6 to 1e-5; too large a learning rate (e.g., 5e-5) on small models may cause policy collapse.
 - `kl_coef`: KL divergence penalty coefficient, controls magnitude of policy updates. Too small (0.01) may cause policy to deviate too far, too large (0.5) may limit learning. Recommend 0.05-0.1.
 - `clip_range`: Policy ratio clipping range, similar to PPO's epsilon. Recommend 0.2.
 

+ 1 - 1
docs/chapter11/第十一章 Agentic-RL.md

@@ -1254,7 +1254,7 @@ GRPO 有一些特定的参数需要理解和调优。
 
 <strong>优化参数</strong>:
 
-- `learning_rate`: GRPO 的学习率通常比 SFT 小,因为我们不想偏离 SFT 模型太远。建议 1e-5 到 5e-5
+- `learning_rate`: GRPO 的学习率通常比 SFT 小,因为我们不想偏离 SFT 模型太远。建议 1e-6 到 1e-5;小模型上学习率过大(如 5e-5)可能导致策略坍塌
 - `kl_coef`: KL 散度惩罚系数,控制策略更新的幅度。太小(0.01)可能导致策略偏离太远,太大(0.5)可能限制学习。建议 0.05-0.1。
 - `clip_range`: 策略比率裁剪范围,类似 PPO 的 epsilon。建议 0.2。