Safe-RLHF (Beaver)
Open-source modular framework for SFT, RLHF and Safe RLHF training of language models, with datasets and evaluation tools.
At a Glance
Safe-RLHF framework released under the Apache License 2.0; free to use, modify and distribute.
Engagement
Available On
Listed Nov 2026
About Safe-RLHF (Beaver)
Beaver (the safe-rlhf repository) is an open-source RLHF framework developed by the PKU-Alignment team at Peking University. It provides training code and human-labeled preference data for alignment research, with a focus on constrained value alignment through Safe RLHF. The code is released under the Apache License 2.0.
What It Is
Safe-RLHF is a training pipeline for aligning large language models. It covers supervised fine-tuning (SFT), reward and cost model training, standard RLHF with PPO, and Safe RLHF with a Lagrangian PPO variant that maximizes reward subject to a cost constraint. The goal is a model that is both helpful (high reward) and harmless (low cost). The project's own comparison table lists DeepSpeed as the backend.
Workflow and Outputs
Users clone the repository and set up a conda environment or a Docker container. Shell scripts then run each stage in order: SFT, reward model, cost model, PPO, and PPO-Lag. The outputs are fine-tuned checkpoints plus reward and cost models. The README documents tests with LLaMA-7B on 8 NVIDIA A800-80GB GPUs, and describes DeepSpeed ZeRO-Offload and multi-node options for setups with less GPU memory. Other supported base models include OPT, Baichuan and InternLM, and custom datasets can be added through a RawDataset abstraction.
Datasets, Models and Evaluation
The project publishes the PKU-SafeRLHF dataset on Hugging Face. It is a human-labeled set of helpfulness and harmlessness preferences covering more than ten constraint dimensions. The README also lists released Beaver-7B models with matching reward and cost model checkpoints. For evaluation, the repository includes an interactive CLI demo, an arena comparing two models, reward/cost-model arena evaluation, BIG-bench tasks and GPT-4 evaluation. The authors say Beaver improves harmlessness over Alpaca in their GPT-4 evaluation.
Community Discussions
Be the first to start a conversation about Safe-RLHF (Beaver)
Share your experience with Safe-RLHF (Beaver), ask questions, or help others learn from your insights.
Pricing
Open Source (Apache-2.0)
Safe-RLHF framework released under the Apache License 2.0; free to use, modify and distribute.
- Supports SFT, RLHF and Safe RLHF training for pre-trained models such as LLaMA and OPT
- Reward Model and Cost Model training with pre-trained checkpoints
- Multi-scale safety evaluation metrics (BIG-bench, GPT-4 Evaluation)
- Code licensed under Apache-2.0; the full PKU-SafeRLHF-1M dataset requires an application form
Capabilities
Key Features
- SFT, RLHF and Safe RLHF training pipelines
- Reward model and cost model training with pre-trained checkpoints
- PKU-SafeRLHF human-labeled preference dataset
- Custom dataset abstraction for SFT, preference and RL stages
- DeepSpeed backend with ZeRO-Offload and multi-node training
- Support for LLaMA, OPT, Baichuan and InternLM models
- Interactive CLI demo and arena
- Evaluation via BIG-bench, GPT-4 and reward/cost arena
