Practical overview
When it fits
Use Beaver when you need an open-source code pipeline for training and researching LLM alignment methods, especially experiments that connect SFT, preference learning and safety-constrained RLHF.
Who it is for
- Researchers studying LLM alignment and constrained alignment.
- ML engineers building or adapting SFT, RLHF and Safe RLHF training experiments.
- Teams working with supported pretrained model families such as LLaMA, OPT and Baichuan.
Documented uses
- Fine-tune a supported pretrained model with supervised data.
- Train preference, reward and cost models for alignment experiments.
- Run RLHF or Safe RLHF training to study reward optimization with safety-cost constraints.
- Adapt datasets and training parameters for experiments.
- Evaluate and compare trained models using the documented evaluation workflows and interactive arena.
Requirements & limits
The repository identifies Beaver as open source and lists the Apache-2.0 license. Its documented use involves cloning and running the Python project; the training workflow uses a Weights & Biases API key.
- The repository supports SFT, RLHF and Safe RLHF for model families including LLaMA, OPT and Baichuan.
- The project describes human-labeled preference data of up to one million pairs and support for customized datasets.
- Training can be compute-intensive: the README’s listed training processes were tested with LLaMA-7B on eight NVIDIA A800-80GB GPUs.
- Documented options include DeepSpeed ZeRO-Offload for reducing peak GPU memory use and multi-node training.
- The framework includes reward and cost model training, with evaluation examples that include BIG-bench and GPT-4 Evaluation.
Check current requirements in the official documentation. Source-based guidance does not mean OpenViST has run or independently tested this project.
Set up Beaver’s training environment
Prepare the repository and dependencies using the documented native Conda or Mamba setup.
Before you start
- A machine with Git and Conda or Mamba available.
- Access to the safe-rlhf GitHub repository.
Steps
Clone https://github.com/PKU-Alignment/safe-rlhf.git and change into the repository directory.
Create the environment with
conda env create --file conda-recipe.yamlormamba env create --file conda-recipe.yaml.Activate the environment with
conda activate safe-rlhf.
Expected outcome
The repository’s documented Conda environment is created and activated.
Guide limitations
- This guide covers environment setup only, not a completed training run.
- The repository also documents a container route, which requires NVIDIA Container Toolkit and NVIDIA Docker setup.
Run the documented SFT-to-Safe-RLHF training stages
Use Beaver’s documented scripts to fine-tune a model, train reward and cost models, and proceed through RLHF stages.
Before you start
- A configured Beaver environment or the documented Docker runner.
- A supported pretrained model or checkpoint and sufficient compute for the chosen model and settings.
- A Weights & Biases API key, exported as
WANDB_API_KEY. - For the README’s listed LLaMA-7B training processes, the stated test setup used eight NVIDIA A800-80GB GPUs; the repository also describes ZeRO-Offload and multi-node options.
Steps
Activate the
safe-rlhfenvironment or start the documented Docker runner, then exportWANDB_API_KEY.Run the command below.
bash scripts/sft.sh --model_name_or_path --output_dir output/sftTrain value models with the command below and the documented cost-model script using
output/sftas its model path.bash scripts/reward-model.sh --model_name_or_path output/sft --output_dir output/rmContinue with Beaver’s documented RLHF and Safe RLHF training scripts, adjusting script parameters such as GPU count and batch size for the machine.
Expected outcome
The documented workflow progresses from SFT to reward and cost model training, followed by RLHF alignment stages and their output checkpoints.
Guide limitations
- The README notes that training parameters may need adjustment for the machine setup.
- The supplied training instructions are partial for later stages; consult the repository README for the complete commands and options.
- ZeRO-Offload can alleviate peak GPU memory usage but does not remove the need to provision compute.
Sources & review
Source record details
- Source availability
- Active
- Sources checked
- 11 October 2026
- Original website title
- PKU-Alignment/safe-rlhf · Official homepage title · retained in its source language

