Secrets of RLHF in Large Language Models Part I: PPO

Rui Zheng, Shihan Dou, Songyang Gao, Yuan Hua, Wei Shen, Binghai Wang, Yan Liu, Senjie Jin, Qin Liu, Yuhao Zhou, Limao Xiong, Lu Chen, Zhiheng Xi, Nuo Xu, Wenbin Lai, Minghao Zhu, Cheng Chang, Zhangyue Yin, Rongxiang Weng, Wensen Cheng, Haoran Huang, Tianxiang Sun, Hang Yan, Tao Gui, Qi Zhang, Xipeng Qiu, Xuanjing HuangarXiv 2023 · DOI

TL;DR

This paper tackles the challenge of stably training large language models (LLMs) to align with human preferences using Reinforcement Learning from Human Feedback (RLHF). They introduce "PPO-max," an optimized Proximal Policy Optimization (PPO) algorithm that significantly improves training stability and enables better alignment, outperforming standard SFT models and showing promise against ChatGPT.

What Problem Does This Paper Address?

Large Language Models (LLMs) are rapidly advancing, but ensuring they are "helpful, honest, and harmless" (3H) remains a significant hurdle. Reinforcement Learning from Human Feedback (RLHF) is the leading paradigm for achieving this alignment. However, current RLHF methods, particularly those using Proximal Policy Optimization (PPO), are notoriously difficult to train stably. This is due to challenges in reward design, the complexity of coordinating multiple models (policy, value, reward, reference), and the high cost of experimentation with LLMs. This instability hinders the safe deployment and further development of aligned LLMs. This paper aims to demystify RLHF by dissecting PPO and proposing an improved algorithm, PPO-max, to overcome these training challenges.

Methods

The core of this paper is the deep dive into the Proximal Policy Optimization (PPO) algorithm and the development of an enhanced version, "PPO-max." The authors meticulously analyze the components of PPO, identifying "policy constraints" as a critical factor for effective implementation.

Key methodological contributions include:

  • Dissection of PPO: A thorough re-evaluation of PPO's inner workings and how its various parts impact policy agent training.
  • PPO-max Algorithm: An advanced PPO variant designed to improve training stability. This involves a combination of effective implementations and careful calibration. While the paper doesn't detail every single trick in PPO-max, it highlights the importance of policy constraints and the careful selection of various optimization techniques.
  • Informative Training Metrics: The paper emphasizes the use of metrics like perplexity, response length, and KL divergence between the policy and SFT models to monitor training stability, arguing they are more informative than just reward scores and loss functions.
  • Reward Modeling: The paper discusses the importance of reward models and their training, noting that their quality directly impacts the policy model's upper bound.

Datasets

  • English:
    • LLaMA-7B (base model)
    • HH-RLHF dataset (160k pairwise samples: 118k helpful, 42k harmless) for training and validation.
  • A subset of 1k samples (0.7k helpful, 0.3k harmless) for testing.
  • Chinese:
    • OpenChineseLLaMA (base model)
    • Manually labeled dataset (39k pairwise samples: 31k helpful, 8k harmless) for training and validation.
  • A subset of 3k samples (2.4k helpful, 0.6k harmless) for testing.
  • Pretraining Data: Used in some experiments to mitigate NLU decline.
  • C-Eval: A comprehensive Chinese evaluation suite for Natural Language Understanding (NLU) capabilities.

Key Insights and Ideas

  • Policy Constraints are Key: The paper strongly emphasizes that policy constraints are the most critical factor for achieving stable and effective RLHF training. Simply optimizing for reward alone can lead to undesirable behaviors or "pattern collapse."
  • Vanilla PPO is Fragile: The authors demonstrate that standard PPO implementations are highly sensitive to hyperparameters and prone to instability, making them unsuitable for large-scale LLM alignment without significant modifications.
  • Beyond Reward Scores: Relying solely on reward scores and loss functions for monitoring PPO training is insufficient. Metrics like perplexity and KL divergence provide a more nuanced view of training stability and potential issues like over-optimization.
  • PPO-max Offers Stability: The proposed PPO-max algorithm, by carefully selecting and combining various optimization tricks, significantly enhances training stability, allowing for longer training durations and better alignment.
  • RLHF Outperforms SFT: The RLHF-trained models consistently show superior performance in terms of helpfulness and harmlessness compared to supervised fine-tuned (SFT) models, especially in challenging scenarios.
  • NLU Decline is Real, But Mitigatable: While PPO can lead to a decline in NLU capabilities, incorporating pretraining data (PPO-ptx) effectively alleviates this issue.

Key Results

  • Human Preference: RLHF-trained models (using PPO-max) showed a strong preference from human annotators across both English and Chinese datasets, particularly in the "Harmless" category. For English, RLHF models achieved a 62% preference rate compared to 5% for SFT models on the Harmless dataset.
  • Comparison with ChatGPT: While not surpassing ChatGPT, the RLHF models significantly reduced the defeat rate against ChatGPT on "harmless" prompts. For English, the defeat rate dropped from 45% to 24% compared to SFT models.
  • NLU Performance: PPO training alone led to a decline in NLU capabilities on the C-Eval benchmark. However, PPO-ptx mitigated this decline, showing comparable or better performance than SFT models across various categories.
  • Training Stability: PPO-max demonstrated stable convergence in training loss and other informative metrics, avoiding the pattern collapse observed in vanilla PPO.

Limitations and Future Work

  • Scaling Law: The study primarily focused on a 7-billion-parameter model. The impact of model size and data scale on RLHF performance remains to be investigated.
  • Reward Model Quality: Experiments relied on available English datasets and a limited amount of self-constructed Chinese data. The quality and quantity of this data might not be sufficient for a comprehensive evaluation.
  • Evaluation Metrics: The evaluation relied heavily on manual and GPT-4 automated assessments. A more detailed assessment using numerous benchmarks and NLP tasks would be beneficial.
  • Focus on Stability vs. Performance: The PPO phase was more geared towards achieving stability rather than maximizing final performance. While stability is crucial, it doesn't guarantee optimal outcomes. A more suitable performance indicator for RLHF training needs to be sought.
  • Future Work: The paper hints at a "Part II" that will address scenarios where a good reward model might not be available, suggesting further research into robust reward modeling or alternative alignment strategies. They also express eagerness to release their technical reports, reward models, and PPO codes to contribute to the LLM community.

Summary updated

BibTeX
@misc{zheng2023secrets,
  author = {Rui Zheng and Shihan Dou and Songyang Gao and Yuan Hua and Wei Shen and Binghai Wang and Yan Liu and Senjie Jin and Qin Liu and Yuhao Zhou and Limao Xiong and Lu Chen and Zhiheng Xi and Nuo Xu and Wenbin Lai and Minghao Zhu and Cheng Chang and Zhangyue Yin and Rongxiang Weng and Wensen Cheng and Haoran Huang and Tianxiang Sun and Hang Yan and Tao Gui and Qi Zhang and Xipeng Qiu and Xuanjing Huang},
  title = {{Secrets of RLHF in Large Language Models Part I: PPO}},
  year = {2023},
  eprint = {2307.04964},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2307.04964},
}
Figure