# REINFORCE

**REINFORCE** 是强化学习中最古老的蒙特卡洛策略梯度算法之一：它从当前策略中采样完整回合，然后沿着能提高通向高回报动作概率、降低通向低回报动作概率的方向调整策略参数<sup>[1](https://introml.mit.edu/notes/reinforcement_learning.html)</sup><sup> • </sup><sup>[2](https://www.mdpi.com/2673-2688/6/3/46)</sup>。其更新规则为

\[ \theta \leftarrow \theta + \alpha \, G_t \, \nabla_\theta \log \pi_\theta(a_t \mid s_t), \]

在每个采样回合的每个时间步上应用，其中 \( \alpha \) 是学习率超参数，\( G_t \) 是从时间步 \( t \) 开始的采样回报<sup>[3](https://arxiv.org/abs/2401.13662)</sup><sup> • </sup><sup>[4](https://robert-moss.com/pdf/rl.pdf)</sup>。该名称是“REward Increment = Nonnegative Factor × Offset Reinforcement × Characteristic Eligibility”（奖励增量 = 非负因子 × 偏移强化 × 特征资格）的首字母缩写，描述了更新的形式<sup>[5](https://link.springer.com/content/pdf/10.1007%2FBF00992696.pdf)</sup>。尽管该算法早于策略梯度定理的正式表述，但可以看作该定理的直接应用<sup>[3](https://arxiv.org/abs/2401.13662)</sup>。

| 关键事实 | 详情 |
|---|---|
| 更新规则 | \( \theta \leftarrow \theta + \alpha G_t \nabla_\theta \log \pi_\theta(a_t \mid s_t) \)，在采样回合的每个时间步上应用<sup>[4](https://robert-moss.com/pdf/rl.pdf)</sup><sup> • </sup><sup>[3](https://arxiv.org/abs/2401.13662)</sup> |
| 估计器质量 | 策略梯度的无偏蒙特卡洛估计，但方差较高<sup>[6](https://cs229.stanford.edu/notes-spring2019/cs229-notes14.pdf)</sup><sup> • </sup><sup>[3](https://arxiv.org/abs/2401.13662)</sup> |
| 基线 | 减去任何与动作无关的基线 \( b(s) \) 不改变梯度期望，适当选择的基线可以降低方差；\( b(s) = \hat{V}(s) \) 产生优势风格的更新<sup>[4](https://robert-moss.com/pdf/rl.pdf)</sup> |
| CartPole-v1 结果 | 原始 REINFORCE 在最后 50 个回合中平均回报约为 95.1；使用价值基线后约为 493.0，接近 500 步上限<sup>[7](https://walkinglabs.github.io/hands-on-modern-rl/en/chapter08_policy_gradient/baseline-experiment)</sup> |
| 方差测量 | 梯度估计方差原始版约为 100.41，使用价值基线后约为 38.27，约为原来的 38.1%<sup>[7](https://walkinglabs.github.io/hands-on-modern-rl/en/chapter08_policy_gradient/baseline-experiment)</sup> |
| 估计器误差 | 以 \( O(I^{-1/2}) \) 的速率收敛到真实梯度，\( I \) 为推演次数<sup>[8](http://www.scholarpedia.org/article/Policy_gradient_methods)</sup> |
| 现代应用 | 带基线的 REINFORCE 风格估计器（RLOO、GRPO）现已成为语言模型 RLHF 中的标准方法，可超越 PPO<sup>[9](https://aclanthology.org/2024.acl-long.662.pdf)</sup><sup> • </sup><sup>[10](https://rlhfbook.com/teach/course/lec3-chap6-p1/)</sup> |

## 背景：策略梯度定理与似然比技巧

策略梯度定理指出，对于任何可微策略 \( \pi \)，期望回报目标的梯度为

\[ \nabla_\theta J(\theta) = \sum_s d^\pi(s) \sum_a q^\pi(s,a) \, \nabla_\theta \pi(a \mid s, \theta), \]

其中 \( d^\pi \) 是同策略状态分布，\( q^\pi \) 是动作价值函数<sup>[11](https://opencourse.inf.ed.ac.uk/sites/default/files/https/opencourse.inf.ed.ac.uk/rl/2024/rl11policygradientmethods.pdf)</sup>。等价地，\( \nabla_\theta V(\theta) = \mathbb{E}[Q^{\pi_\theta}(s,a) \nabla_\theta \log \pi_\theta(a \mid s)] \)<sup>[4](https://robert-moss.com/pdf/rl.pdf)</sup>。

REINFORCE 使用的估计器源自似然比（得分函数）技巧：由于 \( \nabla_\theta \log p(\tau \mid \theta) \) 乘以轨迹概率，期望回报的梯度可以写成 \( \nabla_\theta \log p(\tau \mid \theta) \, R(\tau) \) 的期望，直接从采样轨迹中估计。因此，将回报乘以对数概率梯度之所以有效，是因为回报以每个动作带来的后续奖励多少来加权该动作的得分，而该乘积的期望恰好是策略梯度<sup>[6](https://cs229.stanford.edu/notes-spring2019/cs229-notes14.pdf)</sup><sup> • </sup><sup>[12](https://hankyang.seas.harvard.edu/OptimalControlReinforcementLearning/policy-gradient.html)</sup>。

这一技巧本身早于强化学习。Scholarpedia 的记述将似然比方法追溯到 Glynn（1987）以及 Aleksandrov、Sysoyev 和 Shemeneva（1968），并将其（更常被称为 REINFORCE）列为应用于机器人学的最突出的策略梯度估计方法之一，与有限差分方法并列<sup>[8](http://www.scholarpedia.org/article/Policy_gradient_methods)</sup>。

## 算法

REINFORCE 是一种[蒙特卡洛方法](https://www.edgepedia.org/zh/monte-carlo-method)：它在当前策略下运行完整回合，计算回报 \( G_t \)，并使用上述规则在每个时间步更新一次参数<sup>[4](https://robert-moss.com/pdf/rl.pdf)</sup>。Sutton 等人的回合形式将更新写为 \( \Delta \theta_t \propto \alpha \, \gamma^t R_t \, \nabla \ln \pi(S_t, A_t) \)，并带有对偏好动作过度采样的修正项<sup>[13](https://proceedings.nips.cc/paper_files/paper/1999/file/464d828b85b0bed98e80ade0a5c43b0f-Paper.pdf)</sup>。

在 Williams 的原始表述中，每个网络权重 \( w_{ij} \) 的增量为

\[ \Delta w_{ij} = \alpha_{ij} (r - b_{ij}) e_{ij}, \]

其中 \( \alpha_{ij} \) 是学习率因子，\( b_{ij} \) 是强化基线，\( e_{ij} = \partial \ln g_i / \partial w_{ij} \) 是该权重的特征资格，即单元输出分布对该权重的敏感度<sup>[5](https://link.springer.com/content/pdf/10.1007%2FBF00992696.pdf)</sup>。Williams 指出的一个主要优势是，该框架为单元以几乎任意方式计算随机输出的网络规定了统计梯度跟随算法，并且可以与反向传播集成<sup>[5](https://link.springer.com/content/pdf/10.1007%2FBF00992696.pdf)</sup>。

**同策略数据使用。** 标准 REINFORCE 估计器使用来自当前策略的新鲜轨迹来估计 \( \nabla_\theta J \)，这使得采样数据的使用效率较低<sup>[8](http://www.scholarpedia.org/article/Policy_gradient_methods)</sup><sup> • </sup><sup>[14](https://d2l.smola.org/chapter_reinforcement-learning/)</sup>。

## 基线与方差缩减

蒙特卡洛策略梯度的弱点是回报 \( G_t \) 在回合之间往往具有高方差<sup>[4](https://robert-moss.com/pdf/rl.pdf)</sup>。标准的补救方法是基线：从回报中减去一个函数 \( b(s) \) 得到同一梯度的不同估计器，适当选择的基线可以降低其方差<sup>[6](https://cs229.stanford.edu/notes-spring2019/cs229-notes14.pdf)</sup>。

无偏性论证很简短。由于策略的动作概率在每个状态下之和为一，\( \sum_a \nabla_\theta \pi(a \mid s, \theta) = \nabla_\theta 1 = 0 \)，因此任何形如 \( b(s) \sum_a \nabla_\theta \pi(a \mid s,\theta) \) 的项对期望梯度的贡献为零<sup>[11](https://opencourse.inf.ed.ac.uk/sites/default/files/https/opencourse.inf.ed.ac.uk/rl/2024/rl11policygradientmethods.pdf)</sup>。等价地，轨迹概率的梯度在所有轨迹上的积分为零，因此常数基线在无限数据的期望中消失，而适当选择的常数基线可以在有限数据下降低估计器的方差<sup>[8](http://www.scholarpedia.org/article/Policy_gradient_methods)</sup>。基线可以是任何函数，只要它不随动作变化<sup>[4](https://robert-moss.com/pdf/rl.pdf)</sup>。

最常见的选择是学习到的状态价值函数估计 \( b(s) = \hat{v}(s, w) \)，它将学习信号转化为优势 \( A_t = G_t - \hat{V}(s_t) \)<sup>[11](https://opencourse.inf.ed.ac.uk/sites/default/files/https/opencourse.inf.ed.ac.uk/rl/2024/rl11policygradientmethods.pdf)</sup><sup> • </sup><sup>[7](https://walkinglabs.github.io/hands-on-modern-rl/en/chapter08_policy_gradient/baseline-experiment)</sup>。自适应基线也有效：指数加权运行基线 \( b_n = \gamma R(h_n) + (1 - \gamma) b_{n-1} \) 在仿真中大幅降低了方差<sup>[15](https://ryanpe05.github.io/EE227C_Final.pdf)</sup>。对多条轨迹进行小批量处理是另一种实用的方差缩减工具；在 CartPole-v1 上的实验表明，通过小批量进行方差缩减对于稳定学习和获得强策略至关重要<sup>[12](https://hankyang.seas.harvard.edu/OptimalControlReinforcementLearning/policy-gradient.html)</sup>。

关于基线的一个条件在不同文献中表述不同：全局收敛分析要求基线独立于整个轨迹<sup>[16](https://arxiv.org/pdf/2010.11364v2.pdf)</sup>，而教科书处理仅要求它不随动作变化<sup>[4](https://robert-moss.com/pdf/rl.pdf)</sup>。上述标准选择满足这两个条件，但已发表的收敛证明所依据的是更严格的轨迹独立性条件。

## 数据说话

一项受控的 CartPole-v1 比较（4 维状态、2 个动作、每步 +1 奖励、500 步回合上限）量化了基线带来的收益。原始 REINFORCE 在最后 50 个回合中平均回报约为 95.1；价值基线版本达到约 493.0，接近 500 步上限<sup>[7](https://walkinglabs.github.io/hands-on-modern-rl/en/chapter08_policy_gradient/baseline-experiment)</sup>。梯度估计的实测方差原始版约为 100.41，使用基线后约为 38.27，降至原来的约 38.1%<sup>[7](https://walkinglabs.github.io/hands-on-modern-rl/en/chapter08_policy_gradient/baseline-experiment)</sup>。

同一研究解释了原始版本的失败模式：早期幸运轨迹强化了并未导致成功的动作，产生大幅训练曲线振荡；使用基线后，学习信号变为优势 \( A_t = G_t - V(s_t) \)<sup>[7](https://walkinglabs.github.io/hands-on-modern-rl/en/chapter08_policy_gradient/baseline-experiment)</sup>。

还有两个量刻画了估计器本身。回合式 REINFORCE 梯度估计器以理论上最快的误差下降速率 \( O(I^{-1/2}) \) 收敛到真实梯度，\( I \) 为推演次数，即使对于高度随机系统也是如此<sup>[8](http://www.scholarpedia.org/article/Policy_gradient_methods)</sup>。学习率的影响是非单调的：实验显示学习率与性能之间呈碗形关系，过小和过大的学习率都会导致较高的次优性，过大的学习率表现出高方差，阻碍收敛<sup>[17](https://proceedings.neurips.cc/paper_files/paper/2025/file/17a84369cf6e2803101294b5d74dd92c-Paper-Conference.pdf)</sup>。

## 与其他方法的比较

**与基于价值的方法相比。** Williams 的 REINFORCE 无需学习价值函数即可找到无偏梯度估计，但学习速度远慢于使用价值函数的强化学习方法；Sutton 等人得出结论，学习价值函数并用它来降低梯度估计的方差似乎是快速学习的关键，这推动了演员-评论家方法<sup>[13](https://proceedings.nips.cc/paper_files/paper/1999/file/464d828b85b0bed98e80ade0a5c43b0f-Paper.pdf)</sup>。在表格表示中，根据 Scholarpedia 的记述，价值函数方法保证收敛到全局最大值，而策略梯度仅收敛到局部最大值<sup>[8](http://www.scholarpedia.org/article/Policy_gradient_methods)</sup>；后来的理论对此有所修正，因为现在已有 REINFORCE 的全局收敛结果（见下文）。

**与 PPO 和 TRPO 相比。** 在策略梯度估计器的比较表中，REINFORCE 的估计器为 \( G \, \nabla_\theta \ln \pi_\theta(a \mid s) \)，而 A3C 使用优势加权估计器，TRPO 和 PPO 使用带裁剪的重要性比率估计器<sup>[3](https://arxiv.org/abs/2401.13662)</sup>。PPO 对每批数据执行多个更新轮次，因此多个梯度步基于相同的转移，并用熵奖励增强其目标，提高了样本效率并加速学习<sup>[3](https://arxiv.org/abs/2401.13662)</sup>。在一项比较研究中，原始策略梯度遭受最频繁的奖励下降，TRPO（使用 KL 散度的黑塞矩阵和回溯线搜索）下降多于 PPO，而 PPO 在较低计算复杂度下更为有效<sup>[15](https://ryanpe05.github.io/EE227C_Final.pdf)</sup>。

**与自然策略梯度相比。** 对于同等表达能力的参数化，自然策略梯度独立于策略参数化，并且可以比常规梯度快一个数量级，但其估计器涉及矩阵求逆，可能在数值上脆弱，且更难实现<sup>[8](http://www.scholarpedia.org/article/Policy_gradient_methods)</sup>。

## 历史

Williams 于 1988 年提出了 REINFORCE 算法，并于 1992 年在《Machine Learning》上发表了期刊版本；一份历史记述指出，它们催生了多种策略梯度方法。同年，Sutton 引入了 TD(λ)，1989 年 Watkins 提出了 [Q-learning](https://www.edgepedia.org/zh/q-learning)<sup>[18](https://cse.sc.edu/~foresta/assets/files/Agostinelli2018_Chapter_FromReinforcementLearningToDee.pdf)</sup>。Williams 本人指出的主要缺点是该类算法缺乏一般收敛理论，以及如同所有梯度算法一样，似乎容易收敛到虚假最优<sup>[5](https://link.springer.com/content/pdf/10.1007%2FBF00992696.pdf)</sup>。

理论基础随后于 1999 年出现，当时 Sutton 及其同事证明了使用任意可微函数近似的策略迭代收敛到局部最优策略，扩展了 Williams 的 REINFORCE<sup>[13](https://proceedings.nips.cc/paper_files/paper/1999/file/464d828b85b0bed98e80ade0a5c43b0f-Paper.pdf)</sup>。一篇经同行评审的策略梯度方法理论综述，涵盖最优性、近似和分布偏移，是 Agarwal 等人的 JMLR 论文<sup>[19](https://www.jmlr.org/papers/volume22/19-736/19-736.pdf)</sup>。现代综述将 20 世纪 90 年代初提出的 REINFORCE 描述为最早的显式策略梯度算法之一，常被称为蒙特卡洛策略梯度<sup>[2](https://www.mdpi.com/2673-2688/6/3/46)</sup>。

## 近期发展

近期一个显著转变是 REINFORCE 风格估计器在语言模型的人类反馈强化学习（RLHF）中的复兴<sup>[9](https://aclanthology.org/2024.acl-long.662.pdf)</sup>。一项 2024 年 ACL 研究发现，RLOO（REINFORCE 留一法）和带移动平均基线的 REINFORCE 在整个训练过程中始终比 RAFT 和 PPO 获得更高的测试奖励<sup>[9](https://aclanthology.org/2024.acl-long.662.pdf)</sup>。对完整补全而非逐词元动作建模的方法，包括带基线的 REINFORCE、RLOO 和 RAFT，优于原始策略梯度和 PPO，并且更高效，因为它们不需要学习基线或价值网络<sup>[9](https://aclanthology.org/2024.acl-long.662.pdf)</sup>。在相同的采样预算 \( k \) 下，RLOO 始终优于 RAFT；在数据集和模型上，\( k = 2 \) 的 RLOO 与 \( k = 4 \) 的 RAFT 表现相当或更优，且仅使用一半的在线样本预算<sup>[9](https://aclanthology.org/2024.acl-long.662.pdf)</sup>。

RLOO 的机制是基于同伴计算的组基线：每个样本的基线是同一提示下其他 \( K - 1 \) 个样本的平均奖励。通过将当前样本的奖励排除在其自身基线之外，基线独立于被评估的动作，从而保持梯度估计器完全无偏；该方法需要为每个提示生成多个补全，这在 LLM 微调中很常见<sup>[20](https://rlhfbook.com/c/06-policy-gradients)</sup>。

组相对策略优化（GRPO）在 DeepSeekMath（Shao 等人，2024）中提出，用于数学推理，它为每个提示采样多个补全，并通过相对于整个组缩放奖励来推导优势，因此不需要价值函数；它保留了 PPO 的裁剪目标，同时消除了价值网络，此后已成为语言模型强化学习的首选方法<sup>[20](https://rlhfbook.com/c/06-policy-gradients)</sup><sup> • </sup><sup>[10](https://rlhfbook.com/teach/course/lec3-chap6-p1/)</sup>。

## 收敛保证

Williams 在 1992 年承认，没有一般收敛理论适用于 REINFORCE 算法类<sup>[5](https://link.springer.com/content/pdf/10.1007%2FBF00992696.pdf)</sup>。这一空白此后已大幅缩小。一项 2020 年的分析建立了 REINFORCE 的首批全局收敛结果：一个任意时间亚线性高概率遗憾界，以及平均遗憾的几乎必然全局收敛，显示出多项式而非指数样本复杂度<sup>[16](https://arxiv.org/pdf/2010.11364v2.pdf)</sup>。一篇 2025 年 NeurIPS 论文证明了经典 REINFORCE 随机策略梯度方法在有限时域 MDP 中以任意常数学习率收敛到全局最优策略，并识别出一种探索性质，即在线随机方法无限次采样每个动作<sup>[17](https://proceedings.neurips.cc/paper_files/paper/2025/file/17a84369cf6e2803101294b5d74dd92c-Paper-Conference.pdf)</sup>。对于赌博机情形，Mei 等人（2024）指出随机梯度赌博机算法的收敛速率为 \( O(\log(t)/t) \)<sup>[17](https://proceedings.neurips.cc/paper_files/paper/2025/file/17a84369cf6e2803101294b5d74dd92c-Paper-Conference.pdf)</sup>。

这些结果与较早的局部最优图景并存：Scholarpedia 关于表格价值函数方法达到全局最大值而策略梯度仅达到局部最大值的陈述<sup>[8](http://www.scholarpedia.org/article/Policy_gradient_methods)</sup>早于全局收敛分析，后者在其所述假设下适用于有限时域 MDP 中的 REINFORCE<sup>[16](https://arxiv.org/pdf/2010.11364v2.pdf)</sup><sup> • </sup><sup>[17](https://proceedings.neurips.cc/paper_files/paper/2025/file/17a84369cf6e2803101294b5d74dd92c-Paper-Conference.pdf)</sup>。

## References

1. [Reinforcement Learning. MIT 6.390 Intro to Machine Learning notes.](https://introml.mit.edu/notes/reinforcement_learning.html)
2. [Deep Reinforcement Learning: A Chronological Overview and Methods. MDPI.](https://www.mdpi.com/2673-2688/6/3/46)
3. [The Definitive Guide to Policy Gradients in Deep Reinforcement Learning (2024 survey). arXiv.](https://arxiv.org/abs/2401.13662)
4. [Algorithms for Reinforcement Learning (textbook chapter with REINFORCE pseudocode).](https://robert-moss.com/pdf/rl.pdf)
5. [Williams, R. J. (1992). Simple statistical gradient-following algorithms for connectionist reinforcement learning. Machine Learning.](https://link.springer.com/content/pdf/10.1007%2FBF00992696.pdf)
6. [Policy Gradient (REINFORCE). Stanford CS229 lecture notes.](https://cs229.stanford.edu/notes-spring2019/cs229-notes14.pdf)
7. [Hands-on: Value Baseline on CartPole. Hands-on Modern RL.](https://walkinglabs.github.io/hands-on-modern-rl/en/chapter08_policy_gradient/baseline-experiment)
8. [Policy gradient methods. Scholarpedia.](http://www.scholarpedia.org/article/Policy_gradient_methods)
9. [Back to Basics: Revisiting REINFORCE-Style Optimization for Learning from Human Feedback in LLMs. ACL 2024.](https://aclanthology.org/2024.acl-long.662.pdf)
10. [The RLHF Book, Lecture 3: Reinforcement Learning.](https://rlhfbook.com/teach/course/lec3-chap6-p1/)
11. [Reinforcement Learning: Policy Gradient Methods. University of Edinburgh lecture notes, 2024.](https://opencourse.inf.ed.ac.uk/sites/default/files/https/opencourse.inf.ed.ac.uk/rl/2024/rl11policygradientmethods.pdf)
12. [Chapter 3: Policy Gradient Methods. Optimal Control and Reinforcement Learning, Harvard.](https://hankyang.seas.harvard.edu/OptimalControlReinforcementLearning/policy-gradient.html)
13. [Sutton, R. S., et al. (1999). Policy Gradient Methods for Reinforcement Learning with Function Approximation. NIPS.](https://proceedings.nips.cc/paper_files/paper/1999/file/464d828b85b0bed98e80ade0a5c43b0f-Paper.pdf)
14. [Reinforcement Learning. Dive into Deep Learning.](https://d2l.smola.org/chapter_reinforcement-learning/)
15. [A Review of REINFORCE Algorithms. EE227C course report.](https://ryanpe05.github.io/EE227C_Final.pdf)
16. [Sample Efficient Reinforcement Learning with REINFORCE (global convergence theory). arXiv.](https://arxiv.org/pdf/2010.11364v2.pdf)
17. [REINFORCE Converges to Optimal Policies with Any Learning Rate. NeurIPS 2025.](https://proceedings.neurips.cc/paper_files/paper/2025/file/17a84369cf6e2803101294b5d74dd92c-Paper-Conference.pdf)
18. [From Reinforcement Learning to Deep Reinforcement Learning: An Overview.](https://cse.sc.edu/~foresta/assets/files/Agostinelli2018_Chapter_FromReinforcementLearningToDee.pdf)
19. [Agarwal, A., et al. On the Theory of Policy Gradient Methods: Optimality, Approximation, and Distribution Shift. JMLR.](https://www.jmlr.org/papers/volume22/19-736/19-736.pdf)
20. [The RLHF Book, Chapter 6: Policy Gradients (Nathan Lambert).](https://rlhfbook.com/c/06-policy-gradients)

---
*Initially written Oct 15, 2026*

Topic: 技术与人造世界 › 计算技术与数字系统 › 现代人工智能：基础模型、生成式人工智能与人工智能产业 › Foundation-model methods and training › Reinforcement learning and world models

Copyright 2026 Edgepedia

License: Edgepedia Community License 1.0, https://www.edgepedia.org/edgepedia/license

Source: https://www.edgepedia.org/zh/reinforce

English original: https://www.edgepedia.org/reinforce
