Abstract
基于人类反馈的强化学习(RLHF)已经成为一种将大型语言模型与人类偏好相匹配的关键方法,通过 Proximal Policy Optimization(PPO)、Direct Preference Optimization(DPO)、REINFORCE Leave One-Out(RLOO)、ReMax 和 Group Relative Policy Optimization(GRPO)等方法实现了快速的算法进化。我们提出了REINFORCE++,这是经典REINFORCE算法的增强变体,它结合了PPO的关键优化技术,同时消除了对critic网络的需要 。REINFORCE++实现了三个主要目标:(1)简单性;(2)增强训练稳定性;(3)减少计算开销。通过广泛的实证评估,我们证明了与GRPO相比,REINFORCE++具有更好的稳定性,并且在保持相当性能的同时实现了比PPO更高的计算效率 。该实现可从 https://github.com/OpenRLHF/OpenRLHF获得。
Introduction
大型语言模型(llm)的快速发展显著增强了它们在生成连贯、上下文相关和类人文本方面的能力。然而,使这些模型与人类偏好保持一致仍然是一个关键的挑战,因为模型可能产生与用户意图或道德准则不一致的输出。基于人类反馈的强化学习(RLHF)通过将人类偏好纳入训练过程,成为解决这一挑战的领先方法。
该领域见证了重大的算法创新,从基础的 Proximal Policy Optimization(PPO)[5]到最近的方法,包括Direct Preference Optimization(DPO)[4],REINFORCE Leave One-Out(RLOO) [7], ReMax[2]和Group Relative Policy Optimization(GRPO)[6]。PPO虽然有效,但需要一个critic网络,这会带来额外的计算开销 。与此同时,较新的方法,如GRPO,解决了优化挑战的特定方面,但可能会引入复杂性和不稳定性 。
在本文中,我们介绍了一种经典REINFORCE算法的新变体,它集成了PPO的关键优化技术,同时消除了对critic网络的需要。我们的方法设计有三个主要目标:
- • Simplicity: 通过在直接的REINFORCE框架上构建,REINFORCE++最大限度地降低了实现的复杂性。
- • Training Stability: The integration of token-level KL penalties , PPO-clip loss and normalized advantage updates ensures robust training dynamics.
- • Efficiency: critic 网络的移除减少了计算开销,使REINFORCE++非常适合大规模应用程序。
通过广泛的实证评估,我们证明了与最先进的方法相比,REINFORCE++在显著减少计算需求的情况下实现了具有竞争力的对齐性能。我们的贡献包括:
- • 将ppo启发的技术新颖地集成到REINFORCE框架中。
- • 对一般和特定领域数据集的综合评估,展示了其在将llm与人类偏好对齐方面的有效性。
- • 一个开源的实现,以促进进一步的研究和应用。
Background
Reinforcement Learning from Human Feedback
基于人类反馈的强化学习(RLHF)是一个框架,它利用人类提供的反馈来训练能够产生与人类偏好一致的输出的模型。这个过程通常包括以下几个部分:
• Supervised Fine-Tuning (SFT) : The model is initially fine-tuned on a dataset of human-labeled prompts and responses to establish a baseline policy.
• Reward Modeling : A reward model is trained to predict human preferences based on a dataset of ranked model outputs.
• Policy Optimization : Using reinforcement learning, the model policy is optimized to maximize the rewards predicted by the reward model.
虽然RLHF已被证明在改善模型对齐方面是有效的,但它也带来了独特的挑战。值得注意的是,优化过程对策略模型和奖励模型之间的相互作用很敏感,这可能导致不稳定和低效率 。
The REINFORCE Algorithm
REINFORCE是强化学习中的一种基本的策略梯度方法,它通过梯度上升直接优化策略的预期收益。算法操作如下:
- • Trajectory Sampling : The agent interacts with the environment to generate trajectories consisting of states, actions, and rewards.
- • Return Calculation : The discounted cumulative rewards for each trajectory are computed as:
where
is the discount factor.
-
• Policy Gradient Estimation : The gradient of the expected return with respect to the policy parameters is estimated using:
-
• Policy Update : The policy parameters are updated via gradient ascent:
where α is the learning rate.
尽管它很简单,但在梯度估计中存在很大的方差 ,这可能会阻碍它对复杂任务(如对齐llm)的可扩展性。
Challenges in RLHF
RLHF的实现经常遇到以下挑战:
- • Computational Overhead: 像PPO这样的方法需要一个critic网络,增加内存和计算需求。
- • Training Instability: PPO中策略网络和价值网络之间的相互依赖可能导致收敛问题,特别是对于大型和复杂的模型[3]。
- • Scalability: 许多高级方法引入了额外的超参数和体系结构组件,使它们的大规模部署变得复杂。
REINFORCE++设计上讲,通过其简单和高效解决了这些挑战,使其成为RLHF任务的一个引人注目的替代方案。
REINFORCE++ Enhancements
REINFORCE++包含几个关键的优化,以提高训练的稳定性和效率:
Token-Level KL Penalty
我们在RL模型和监督微调(SFT)模型分布之间实现了一个token-level Kullback-Leibler (KL)散度惩罚。这种惩罚被纳入奖励函数中,如下:
其中:
- •
represents the input prompt
- •
denotes the generated response
- •
indicates whether
is the final token
- •
is the KL penalty coefficient
这种方法促进了更好的credit分配和与 process reward models (PRM)的无缝集成。
PPO-Clip Integration
我们采用PPO的clipping机制来约束策略更新:
其中:
- •
is the probability ratio of taking action
in state
under the new policy versus the old policy.
- •
is the estimated advantage for token
.
- •
restricts the probability ratio to be within the range of
, where
is a small hyperparameter (commonly set to around 0.2).
This formulation effectively allows the algorithm to take advantage of positive advantages while preventing excessively large updates that could destabilize training. The use of the minimum function ensures that if the ratio moves too far from 1 (either above or below) , it does not contribute positively to the objective, thus maintaining a form of trust region for policy updates .
Mini-Batch Updates
为了提高训练效率,我们实施了以下特点的小批量更新:
- • Batch Processing : Data is processed in smaller, manageable chunks rather than full-batch updates.
- • Multiple Updates : Each mini-batch allows for multiple parameter updates, improving convergence rates.
- • Stochastic Optimization : Introduces beneficial randomness for better generalization.
感觉是Batch拆多个mini-batch,然后处理更新。拆分方法可能多种。
Reward Normalization and Clipping
我们实行全面的奖励处理,稳定训练;
- • Normalization : Standardizes rewards using z-score normalization to mitigate outliers.
- • Clipping : Constrains reward values within predefined bounds to avoid instability.
- • Scaling : Applies appropriate scaling factors for numerical stability during updates.
Advantage Normalization
REINFORCE++中的优势函数定义为:
我们使用z-score归一化对这些优势进行归一化:
其中
和
分别为批均值和标准差。归一化确保梯度稳定,防止训练过程中出现分歧。
Experimental Setup
Overview of Experimental Design
使用多种测试场景对REINFORCE++进行了实证评估,以确保全面了解其在不同环境下的性能。我们专注于主要目标:使用OpenRLHF[1]评估PPO和GRPO的训练稳定性和计算效率。
Base Models
我们的实验利用了:
• Llama3.1-8B-SFT
• Qwen2.5-7B-Instruct 2
Hyper-Parameter Configuration
超参数的选择是为了平衡训练效率和模型性能。关键设置总结如下:
在这里插入图片描述
Dataset Details
我们使用了两个不同的数据集进行评估:
- • General Domain: 不同提示和偏好数据集的集合,涵盖一般知识和会话主题。
- • Mathematics Domain: 一个专门的数据集和一个封闭的数学奖励模型,旨在测试模型在数学环境中的推理和解决问题的能力。
Results and Analysis
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
Training Stability
我们的实验结果证明了几个关键发现:
- • General scenarios with Bradley-Terry Reward Models : REINFORCE++ exhibits superior stability compared to GRPO, particularly in preventing reward and output length hacking (Figure 1).
- • Rule-Based Reward Model : Under rule-based reward scenarios, REINFORCE++ achieves comparable performance to GRPO with group normalization (Figure 2).
- • Mathematical Reward Model : In mathematical problem-solving scenarios, REINFORCE++ demonstrates a better reward increase per unit KL divergence
compared to GRPO (Figure 3).
Computational Efficiency
表2提供了在NVIDIA H100上使用LLaMA3 8b模型的70k个样本的计算成本摘要。与PPO相比,REINFORCE++在内存使用和训练时间方面有所减少,突出了其计算效率。
在这里插入图片描述
Conclusion
实验结果验证了REINFORCE++作为一种更简单、更有效的RLHF替代PPO和GRPO的有效性。未来的工作将探索将该方法扩展到更大的数据集,并研究其在更复杂的对齐场景中的性能。
