RLHF
Definition
Reinforcement learning from human feedback: training a model with a reward signal learned from people's preferences between two outputs.
In more detail
Classic RLHF trains a reward model on human comparisons, then optimises the language model against it. It was central to making chat assistants helpful, and simpler methods such as DPO now cover some of the same ground.
The usual sequence has three steps. First, supervised fine-tuning on example conversations. Second, people compare pairs of model answers to the same prompt, and a reward model learns to predict which one they prefer. Third, the language model is trained with reinforcement learning, historically PPO, to produce answers the reward model scores highly, with a penalty for drifting too far from the starting model.
RLHF is expensive because it needs many human judgements and a fragile training loop. Variants replace human raters with AI feedback, or replace the learned reward with checkable rewards such as passing tests.
Related terms
Constitutional AI
A training method in which a model learns to be harmless by critiquing and revising its own answers against a written list of principles.
DPO
Direct Preference Optimization: training a model directly on pairs of preferred and rejected outputs, with no separate reward model needed.
GRPO
Group Relative Policy Optimization: an RL method that samples a group of answers to one prompt and learns from their relative rewards.
Post-training
Training after pretraining that shapes a model's behaviour, including instruction tuning and preference or reinforcement learning.
Supervised fine-tuning (SFT)
Fine-tuning on labelled input and output pairs so the model learns to produce the target output for each input.
AI alignment
The work of making AI systems pursue the goals and values their developers and users intend, and avoid harmful behaviour nobody asked for.
Read more about RLHF
- Fine-tuning
Further training a model on task-specific examples, and knowing when RAG is enough.
- TRL
Hugging Face's post-training library: supervised fine-tuning, DPO, GRPO and reward models.
- Fine-tune a small model with LoRA
Fine-tune a small open model with LoRA using TRL and PEFT, measure it on a held-out set before and after, and decide whether the gain is worth keeping.