SuperAPIAI Directory

Online-RLHF

github.com · AI developer platforms

A recipe for online RLHF and online iterative DPO.

Open website Alternatives
PricingOpen source开源项目(可免费自部署)

About this tool

Purpose

Online-RLHF was developed by the RLHFlow team and is an open-source recipe for aligning large language models (LLMs), focusing on online iterative RLHF (online iterative reinforcement learning from human feedback) and online iterative DPO (direct preference optimization). Recent LLM literature has widely reported that online iterative RLHF significantly outperforms its offline version; however, most existing open-source RLHF projects are limited to the offline learning setting. This repository aims to fill this gap by providing a detailed and easy-to-reproduce online iterative RLHF recipe.

Main Capabilities

  • Complete online iterative training pipeline: Includes steps such as supervised fine-tuning (SFT), reward modeling (RM), data generation, data annotation, and iterative training.
  • Pretrained models and datasets: Provides multiple SFT checkpoints (such as RLHFlow/LLaMA3-SFT, RLHFlow/LLaMA3-SFT-v2, etc.), reward models (such as the Bradley-Terry model, generative pairwise preference model, and multi-head reward model with multi-expert aggregation), as well as RLHF models (multiple iterative versions). It also provides an SFT dataset and prompt sets.
  • Achieves excellent results using only open-source data: With this recipe, results comparable to or even better than LLaMA3-8B-instruct can be achieved using only open-source data.
  • Supports VLLM-accelerated inference: The data generation stage uses VLLM acceleration and provides two inference methods (direct inference and API server).

Usage

The repository provides step-by-step guidance:

  1. Environment installation: It is recommended to create separate environments for inference and training. Note that the numpy version must be less than 2.0. The SFT environment also requires installing wandb and logging into a Hugging Face account (to access Gemma); the training environment requires installing wandb and logging into a Hugging Face account (to access the LLaMA3 model).
  2. Step 1: Supervised fine-tuning (SFT): Process the SFT data into the standard format (refer to RLHFlow/RLHFlow-SFT-Dataset-ver2). The learning rate, batch size, etc. can be adjusted via commands or by modifying the yaml configuration file. If out-of-memory issues occur, Gemma-2b-it can be used with deepspeed stage 3 and gradient checkpointing.
  3. Step 2: Reward modeling: Train reward/preferencemodels. The repository provides multiple SOTA open-source reward models (such as sfairXC/FsfairX-LLaMA3-RM-v0.1, RLHFlow/pair-preference-model-LLaMA3-8B, RLHFlow/ArmoRM-Llama3-8B-v0.1).
  4. Step 3.1: Data generation: Use the prepared prompt sets (such as the UltraFeedback series and iterative prompt sets) to generate responses through VLLM. You can create test_gen.sh and run it, or use the API server.
  5. Step 3.2: Data annotation: Call the reward/preference model trained in Step 2 to rank the generated responses.
  6. Step 3.3: Training: Run iterative training. If CUDA errors occur, adjust num_of_process in the configuration file according to the GPU.
  7. Automated iteration: The repository integrates all steps and can automatically run iterative training (note that sleep 1m waits for API registration and needs to be adjusted according to the environment).

Applicable Scenarios

Suitable for researchers and developers who want to reproduce or improve online iterative RLHF, especially those working on directions such as large language model alignment, preference learning, and reinforcement learning from human feedback. It is also suitable as a reference implementation for online RLHF teaching and experiments.

Limitations

  • Requires relatively strong computational resources (training and inference environments are separate; optimizations such as deepspeed are recommended).
  • Depends on specific software versions (numpy<2.0), and some errors require adjusting the transformer version or configuration.
  • Currently, the repository mainly targets models such as LLaMA3-8B; other models may require adaptation.
  • Detailed technical reports and the Hugging Face repository can be consulted for further reference.
Up/Down to navigate · Enter to open · ESC to closeBrowse all tools