What Is RLHF? Aligning LLMs with Human Feedback
Reinforcement Learning from Human Feedback
Short version: if your company wants an LLM to answer "in our voice" or "never like that", you will almost never run RLHF yourself. The structure is still worth knowing. After this post you will know what RLHF does in its three stages and be able to pick between SFT, DPO and RLHF for your own work.
In one line
RLHF (Reinforcement Learning from Human Feedback) pushes a model using records of people saying "B is better than A". OpenAI's InstructGPT paper (2022) made it famous, and ChatGPT was tuned this way.
In that paper, human raters preferred answers from the 1.3B InstructGPT over answers from the 175B GPT-3. A model with 100x fewer parameters won. Tuning toward what people want mattered more than size.
Three stages
1. SFT (supervised fine-tuning): train on answers people wrote by hand. This alone gets you decent instruction following.
2. Reward model: the model writes several answers to the same prompt and people rank them. A separate model learns to score answers from those rankings.
3. PPO: the model answers → the reward model scores it → weights move toward higher scores. Repeat. A KL penalty (a measure of how far two probability distributions are apart) keeps the model from drifting too far from where it started.
The two dashed boxes are what only RLHF has. While PPO runs you hold four models in memory: the one being trained, a frozen copy, the reward model and a value model (the critic PPO uses). That is where "RLHF is expensive" comes from.
What the reward model learns
The loss is simple. It gets smaller as the chosen answer's score pulls ahead of the rejected one.
loss = -log σ(r(chosen) - r(rejected))
I ran a few lines of Ruby while rewriting this. The loss on the first step is always 0.693 (= log 2), because both scores are still equal and σ(0) = 0.5. So a log that starts near 0.69 and goes down is normal. If it sits at 0.69, nothing is being learned.
Gaming the score (reward hacking)
PPO chases the reward model's score, not the humans' actual judgment. If the reward model happens to like long, polite answers, the model learns to write longer instead of better. That is reward hacking. The KL penalty slows it down. It does not stop it.
SFT vs DPO vs RLHF vs Constitutional AI
Method Needs When
SFT example answers Fixing tone and format. Most projects stop here
DPO chosen / rejected pairs You have thumbs-up / thumbs-down logs
RLHF (PPO) pairs + reward model + GPUs You keep reusing the reward model. Model-lab scale
Constitutional AI a list of principles + AI You want AI to replace human raters
Constitutional AI is Anthropic's 2022 method: an AI reads a list of principles and picks the better answer instead of a human (also called RLAIF). The pairs still feed RLHF or DPO.
For an internal chatbot I'd start with SFT. If a "don't answer like that" survives prompting and RAG, then DPO. Going all the way to PPO is for teams with spare GPUs and raters. I ran DPO separately in the DPO post.
If you want your service to answer "like this" and can't decide between SFT and DPO, feel free to ask negabaro. We can start by looking at how far the data you already have will take you.
Key Concepts
Stage 1 SFT: learn instruction following from answers people wrote
Stage 2 reward model: people rank several answers to the same prompt, and a model learns to score from those ranks
The reward model loss starts at 0.693 (log 2) and should go down
Stage 3 PPO: generate → score with the reward model → move weights toward higher scores, repeat
A KL penalty keeps the model close to the original (it slows reward hacking, it does not stop it)
PPO keeps four models in memory: policy, reference, reward and value
Pros
- ✓ Learns a hard-to-write-down idea of a "good answer" from human choices
- ✓ InstructGPT 1.3B answers were preferred over GPT-3 175B (original paper)
- ✓ The reward model can be reused to pick or grade answers later
Cons
- ✗ Human ranking is expensive
- ✗ Reward hacking — learns to raise the score (e.g. by getting longer) instead of getting better
- ✗ PPO juggles four models, needs lots of GPU memory and is unstable
- ✗ Raters' biases flow straight into the model