Safe RLHF: Safe Reinforcement Learning from Human Feedback

Josef Dai, Xuehai Pan, Ruiyang Sun, Jiaming Ji, Xinbo Xu +3 more
2/12/2026

Official code: PKU-Alignment/safe-rlhf (1,611 stars, Apache-2.0, last commit 2025-11-24).

Abstract

With the development of large language models (LLMs), striking a balance between the performance and safety of AI systems has never been more critical. However, the inherent tension between the objectives of helpfulness and harmlessness presents a significant challenge during LLM training. To address this issue, we propose Safe Reinforcement Learning from Human Feedback (Safe RLHF), a novel algorithm for human value alignment. Safe RLHF explicitly decouples human preferences regarding helpfulness and harmlessness, effectively avoiding the crowdworkers' confusion about the tension and allowing us to train separate reward and cost models. We formalize the safety concern of LLMs as an optimization task of maximizing the reward function while satisfying specified cost constraints. Leveraging the Lagrangian method to solve this constrained problem, Safe RLHF dynamically adjusts the balance between the two objectives during fine-tuning. Through a three-round fine-tuning using Safe RLHF, we demonstrate a superior ability to mitigate harmful responses while enhancing model performance compared to existing value-aligned algorithms. Experimentally, we fine-tuned the Alpaca-7B using Safe RLHF and aligned it with collected human preferences, significantly improving its helpfulness and harmlessness according to human evaluations.

View on arXivView PDF

Code Implementations(1)

Apache-2.0

Safe RLHF: Constrained Value Alignment via Safe Reinforcement Learning from Human Feedback

1,611133Shell, PythonMay 15, 202311 months agoApache-2.0
ai-safetyalpacabeaverdatasetsdeepspeed+15 more

Cite this paper

@article{dai2026safe,
  title  = {Safe RLHF: Safe Reinforcement Learning from Human Feedback},
  author = {Josef Dai and Xuehai Pan and Ruiyang Sun and Jiaming Ji and Xinbo Xu and Mickel Liu and Yizhou Wang and Yaodong Yang},
  year   = {2026},
  eprint = {2310.12773},
  archivePrefix = {arXiv},
  url    = {https://arxiv.org/abs/2310.12773},
  journal = {ICLR 2023 2023}
}

Add a badge to your README

Shows whether official code is linked for this paper.

Code of Paper badge
[![Code of Paper](https://codeofpaper.com/badge/2310.12773.svg)](https://codeofpaper.com/paper/2310.12773)

Discussion