Enhancing Safety in Reinforcement Learning with Human Feedback via Rectified Policy Optimization
Xiyue Peng, Hengquan Guo, Jiawei Zhang, Dongqing Zou, Ziyu Shao, Honghao Wei, Xin Liu
TL;DR
The paper tackles safety alignment in RLHF, identifying safety compensation as a risk when safety is enforced via an expected constraint. It introduces Rectified Policy Optimization (RePO), which imposes a per-prompt critical safety constraint $C(x,y) \le 0$ and uses a rectified policy gradient with a rectified penalty $\{C(x,y)\}^+$ to guide updates, forming a min–max objective $L(\pi_\theta, \lambda)$ that preserves helpfulness when safety is guaranteed. Core contributions include a formal rectified reformulation, token-level decomposition of rewards and costs, PPO-style clipped objectives with safe/unsafe batching, and an empirical demonstration that RePO delivers stronger safety alignment than methods optimizing expected safety, on Alpaca-7B and Llama3.2-3B. The results suggest that enforcing per-prompt safety can yield safer, more reliable LLMs without sacrificing performance, with potential broad impact for safer deployment of RLHF systems.
Abstract
Balancing helpfulness and safety (harmlessness) is a critical challenge in aligning large language models (LLMs). Current approaches often decouple these two objectives, training separate preference models for helpfulness and safety, while framing safety as a constraint within a constrained Markov Decision Process (CMDP) framework. This paper identifies a potential issue when using the widely adopted expected safety constraints for LLM safety alignment, termed "safety compensation", where the constraints are satisfied on expectation, but individual prompts may trade off safety, resulting in some responses being overly restrictive while others remain unsafe. To address this issue, we propose Rectified Policy Optimization (RePO), which replaces the expected safety constraint with critical safety constraints imposed on every prompt. At the core of RePO is a policy update mechanism driven by rectified policy gradients, which penalizes the strict safety violation of every prompt, thereby enhancing safety across nearly all prompts. Our experiments demonstrate that RePO outperforms strong baseline methods and significantly enhances LLM safety alignment.
