---
title: "RLHF Explained: Reward Models, PPO and InstructGPT"
description: "RLHF trains a reward model on human preference comparisons, then optimizes an LLM against it. The 3 steps, what the papers measured, and TRL code."
url: https://launchkudos.com/news/llm-fine-tuning-rlhf
section: AI
author: "Arnab Gupta"
published: 2026-12-05T02:20:30.346Z
updated: 2026-12-05T02:20:30.346Z
tags: [llm-fine-tuning, rlhf, alignment, reward-model, ppo]
---

# RLHF Explained: Reward Models, PPO and InstructGPT

*RLHF trains a reward model on human preference comparisons, then optimizes an LLM against it. The 3 steps, what the papers measured, and TRL code.*

*Part 11 of 15 in [LLM fine-tuning techniques](https://launchkudos.com/news/llm-fine-tuning-techniques)*

Reinforcement learning from human feedback (RLHF) fine-tunes a language model in three steps: humans compare model outputs, a reward model learns to predict their choices, and reinforcement learning pushes the model toward outputs that reward model scores highly. It was developed at OpenAI and DeepMind from 2017 and was the method behind OpenAI's InstructGPT in 2022.

- 1.3B > 175B · InstructGPT outputs preferred to GPT-3's · Ouyang et al., 2022, Sec. 4.1
- 85 ± 3% · labelers preferring 175B InstructGPT over GPT-3 · Ouyang et al., 2022
- < 1% · of agent interactions needed human feedback · Christiano et al., 2017
## What is RLHF?

RLHF is a way to fine-tune a model toward what people prefer when that preference is hard to write down as a rule. Humans compare pairs or rankings of outputs; a reward model is trained on those comparisons; and the language model is then trained with reinforcement learning to maximize the learned reward, with a penalty for drifting too far from where it started ([Ouyang et al., 2022, Sec. 3.1](https://arxiv.org/abs/2203.02155)).

The motivation in the InstructGPT paper: "Making language models bigger does not inherently make them better at following a user's intent", because the next-token objective is not the same as being helpful, honest and harmless ([abstract](https://arxiv.org/abs/2203.02155)).

## How does RLHF work?

RLHF works as a three-stage pipeline: supervised fine-tuning on human demonstrations, reward-model training on human rankings, then policy optimization with PPO against the reward model under a KL penalty. This is the setup InstructGPT used, following Stiennon et al. (2020) ([Ouyang et al., 2022, Sec. 3.1 and 3.5](https://arxiv.org/abs/2203.02155)).

![Diagram: three RLHF stages from InstructGPT. Step 1 supervised fine-tuning on labeler demonstrations (about 13k prompts), step 2 reward model from rankings of 4 to 9 outputs (about 33k prompts), step 3 PPO against the reward model with a KL penalty (about 31k prompts)](https://launchkudos.com/media/e098e13bcf333613aaae.webp)

### Step 1: supervised fine-tuning (SFT)

Labelers write the answers they want for a set of prompts, and the pretrained model (GPT-3 in InstructGPT) is fine-tuned on them with ordinary supervised learning. InstructGPT's SFT dataset had about 13k training prompts from the OpenAI API and from labelers ([Sec. 3.2](https://arxiv.org/abs/2203.02155)). The demonstrations came from a team of about 40 contractors hired through Upwork and Scale AI ([Sec. 3.4](https://arxiv.org/abs/2203.02155)).

### Step 2: train a reward model on comparisons

The model generates several answers per prompt and labelers rank them. InstructGPT showed labelers 4 to 9 responses at once, which yields K-choose-2 comparisons per prompt; its reward-model set had 33k training prompts ([Sec. 3.2, 3.5](https://arxiv.org/abs/2203.02155)). The reward model is the SFT model with its final unembedding layer replaced by a scalar output, trained with:

`loss(θ) = −1/(K choose 2) · E[ log σ( r_θ(x, y_w) − r_θ(x, y_l) ) ]`

where `y_w` is the preferred completion and `y_l` the other one ([Eq. 1](https://arxiv.org/abs/2203.02155)). This is the Bradley-Terry model that Christiano et al. used in 2017: the probability a human prefers one output "depends exponentially on the value of the latent reward" ([Christiano et al., Sec. 2.2.3](https://arxiv.org/abs/1706.03741)).

**Worked example (our arithmetic).** If the reward model scores answer A at 2.0 and answer B at 0.5, it predicts P(A preferred) = σ(2.0 − 0.5) = σ(1.5) ≈ 0.82. If the labeler did prefer A, the loss for that pair is −log(0.82) ≈ 0.20; if the labeler preferred B, it is −log(0.18) ≈ 1.70, so the gradient pushes the scores apart in the right direction. With K = 9 ranked answers, one prompt gives 9 × 8 / 2 = 36 comparisons.

### Step 3: optimize the policy with PPO and a KL penalty

The SFT model becomes the policy. For each prompt it writes a response, the reward model scores it, and PPO updates the policy. The reward includes a penalty for moving away from the SFT model ([Stiennon et al., 2020, Sec. 3.4](https://arxiv.org/abs/2009.01325)):

`R(x, y) = r_θ(x, y) − β · log[ π_RL(y|x) / π_SFT(y|x) ]`

Stiennon et al. give the KL term two jobs: it "acts as an entropy bonus" that stops the policy collapsing to a single mode, and it keeps the policy from producing outputs "too different from those that the reward model has seen during training". InstructGPT adds a third term in its PPO-ptx variant, `γ · E[log π_RL(x)]` over pretraining data, to reduce performance regressions on public NLP benchmarks ([Ouyang et al., Eq. 2](https://arxiv.org/abs/2203.02155)). Its PPO set had 31k training prompts, all from the API.

## When was RLHF introduced, and by whom?

RLHF for deep RL was introduced in 2017 by researchers at OpenAI and DeepMind, applied to summarization in 2020 and to general instruction following with InstructGPT in 2022:

| Paper | Authors | First on arXiv | Venue | What it added |
|---|---|---|---|---|
| [Deep Reinforcement Learning from Human Preferences](https://arxiv.org/abs/1706.03741) | Paul F. Christiano, Jan Leike, Tom B. Brown, Miljan Martic, Shane Legg, Dario Amodei | June 12, 2017 | NIPS 2017 | Reward learning from human comparisons of 1-2 second clips, for Atari and robot control |
| [Learning to summarize from human feedback](https://arxiv.org/abs/2009.01325) | Nisan Stiennon, Long Ouyang, Jeff Wu, Daniel M. Ziegler, Ryan Lowe, Chelsea Voss, Alec Radford, Dario Amodei, Paul Christiano | Sept. 2, 2020 | NeurIPS 2020 | RM + PPO with a KL penalty on a pretrained language model |
| [Training language models to follow instructions with human feedback](https://arxiv.org/abs/2203.02155) | Long Ouyang, Jeff Wu, Xu Jiang, and 17 co-authors, ending with Jan Leike and Ryan Lowe | March 4, 2022 | NeurIPS 2022 | SFT + RM + PPO(-ptx) for general instructions: InstructGPT |

The NIPS 2017 and NeurIPS 2022 venues are listed in the [NeurIPS proceedings](https://papers.neurips.cc/paper_files/paper/2017/file/d5e2c0adad503c91f91df240d0cd4e49-Paper.pdf) and on the [NeurIPS 2022 poster page](https://neurips.cc/virtual/2022/poster/52886); Stiennon et al. list NeurIPS 2020 on arXiv.

## What results did the RLHF papers report?

**Christiano et al. (2017): complex behavior from little feedback.** The method solved Atari games and simulated robot tasks "without access to the reward function", with human feedback on less than 1% of the agent's interactions ([abstract](https://arxiv.org/abs/1706.03741)). With 700 labels it nearly matched RL on the true reward in MuJoCo tasks ([Sec. 3.1.1](https://arxiv.org/abs/1706.03741)). A Hopper robot learned backflips from 900 queries in under an hour of human time ([Sec. 3.2](https://arxiv.org/abs/1706.03741)). For Atari, the authors estimate 5k labels at about 5 hours of human work, about $36 at US minimum wage.

**Stiennon et al. (2020): a 1.3B model beat a 10x larger supervised one.** On Reddit TL;DR summaries, the 1.3B human-feedback model was preferred over reference summaries 61% of the time, against 43% for a supervised model 10 times its size ([Sec. 4.1](https://arxiv.org/abs/2009.01325)). After controlling for summary length, preference dropped by about 5%, and the 6.7B model's summaries were still preferred to the human references about 65% of the time. The released dataset has 64,832 summary comparisons.

**Ouyang et al. (2022): InstructGPT.** Main results ([Sec. 1 and 4](https://arxiv.org/abs/2203.02155)):

| Result | Number |
|---|---|
| 1.3B InstructGPT vs 175B GPT-3, labeler preference | 1.3B preferred, "despite having over 100x fewer parameters" |
| 175B InstructGPT preferred over 175B GPT-3 | 85 ± 3% of the time |
| 175B InstructGPT preferred over few-shot 175B GPT-3 | 71 ± 4% of the time |
| TruthfulQA | truthful and informative answers "about twice as often as GPT-3" |
| Compute to train 175B PPO-ptx | 60 petaflop/s-days, vs 3,640 for GPT-3 pretraining |
| Reward model used for all PPO runs | one 6B model |
| Labeler agreement | 72.6 ± 1.5% (training labelers), 77.3 ± 1.3% (held-out labelers) |

## How is RLHF different from RLAIF, DPO and GRPO?

RLHF uses human comparisons, a separate reward model and an online RL step. Its successors each change one of those pieces:

| Method | Who labels preferences | Separate reward model? | RL step? | Series page |
|---|---|---|---|---|
| RLHF | Humans | Yes | Yes (PPO in the original papers) | this page |
| RLAIF | An AI model, guided by written principles or prompts | Yes in canonical RLAIF; no in d-RLAIF | Yes | [RLAIF](https://launchkudos.com/news/llm-fine-tuning-rlaif) |
| DPO | Humans (or AI), offline preference pairs | No | No, a classification-style loss | [DPO](https://launchkudos.com/news/llm-fine-tuning-dpo) |
| GRPO | Any reward function or model | Optional | Yes, with group-relative advantages instead of a value model | [GRPO](https://launchkudos.com/news/llm-fine-tuning-grpo) |
| RLVR | A program that checks answers (math, code) | No, rule-based | Yes | [RLVR](https://launchkudos.com/news/llm-fine-tuning-rlvr) |

## Which libraries support RLHF?

Hugging Face TRL covers the reward-model step and online RL, but **TRL no longer includes PPO**. Its v1.13.0 release notes (Sept. 10, 2026) say "`PPOTrainer`, `PPOConfig`, and `modeling_value_head.py` ... are gone", after PPO had first been moved to `trl.experimental.ppo` ([TRL releases](https://github.com/huggingface/trl/releases/tag/v1.13.0); [PR #7020](https://github.com/huggingface/trl/pull/7020)). In TRL v1.19.0, the current release on PyPI:

- **[`RewardTrainer`](https://huggingface.co/docs/trl/reward_trainer)** trains a reward model with the Bradley-Terry loss on preference data (`chosen` / `rejected`, with an implicit or explicit `prompt`). `RewardConfig` has an optional `center_rewards_coefficient` (recommended `0.01`) to keep rewards near zero.
- **[`RLOOTrainer`](https://huggingface.co/docs/trl/rloo_trainer)** is an online RL trainer that implements RLOO, a REINFORCE-style method for learning from human feedback, from [Ahmadian et al., 2024](https://huggingface.co/papers/2402.14740), whose abstract argues that "many components of PPO are unnecessary in an RLHF context". `reward_funcs` accepts a trained reward model's path, and `RLOOConfig.beta` (default `0.05`) is the KL coefficient.
- **[`GRPOTrainer`](https://huggingface.co/docs/trl/grpo_trainer)** also accepts a reward model; see [GRPO](https://launchkudos.com/news/llm-fine-tuning-grpo).

Older TRL releases with PPO still install; the PR notes that tools such as ms-swift pin `trl>=0.15,<1.0`.

## How do you use RLHF in code?

Step 2 and step 3 with current TRL. All names are checked against the [RewardTrainer](https://huggingface.co/docs/trl/reward_trainer) and [RLOOTrainer](https://huggingface.co/docs/trl/rloo_trainer) pages for TRL v1.19.0. Step 1 is a plain [`SFTTrainer`](https://huggingface.co/docs/trl/sft_trainer) run.

```python
from datasets import load_dataset
from trl import RewardConfig, RewardTrainer, RLOOConfig, RLOOTrainer

# Step 2: reward model from human preference pairs (chosen / rejected)
rm = RewardTrainer(
    model="Qwen/Qwen3-0.6B",
    args=RewardConfig(output_dir="qwen3-rm", center_rewards_coefficient=0.01),
    train_dataset=load_dataset("trl-lib/ultrafeedback_binarized", split="train"),
)
rm.train()
rm.save_model("qwen3-rm")

# Step 3: online RL against that reward model, with a KL penalty (beta)
rl = RLOOTrainer(
    model="Qwen/Qwen3-0.6B",                  # your SFT model from step 1
    reward_funcs="qwen3-rm",                  # path to the trained reward model
    args=RLOOConfig(output_dir="qwen3-rloo", beta=0.05),
    train_dataset=load_dataset("trl-lib/ultrafeedback-prompt", split="train"),
)
rl.train()
```

This swaps PPO for RLOO in step 3, because PPO is no longer in TRL. The InstructGPT recipe used PPO with a separate value model; RLOO uses several samples per prompt as a baseline instead (`num_generations`, default 2).

## Common pitfalls

- **Reward over-optimization.** Optimizing too hard against a reward model makes outputs worse: "eventually the reward model becomes anti-correlated with human preferences" ([Stiennon et al., Sec. 4.3](https://arxiv.org/abs/2009.01325)). The KL penalty is the standard guard.
- **Alignment tax.** PPO-only InstructGPT lost performance on public NLP datasets; mixing in pretraining gradients (PPO-ptx) reduced the regressions "without compromising labeler preference scores" ([Ouyang et al., Sec. 1, 4.2](https://arxiv.org/abs/2203.02155)).
- **Reward-model overfitting from correlated pairs.** Shuffling all K-choose-2 comparisons into one dataset made the RM overfit in a single pass; InstructGPT trains all comparisons from a prompt as one batch element instead ([Sec. 3.5](https://arxiv.org/abs/2203.02155)).
- **Length bias.** RLHF policies wrote longer summaries, and length "could account for much of our quality improvements"; controlling for it cut preference by about 5% ([Stiennon et al., Sec. 4.1](https://arxiv.org/abs/2009.01325)).
- **Large reward models can be unstable.** InstructGPT used only 6B reward models because 175B RM training "could be unstable" ([Sec. 3.5](https://arxiv.org/abs/2203.02155)).
- **Whose preferences?** InstructGPT aligns to its labelers and researchers, about 40 contractors mostly in the United States or Southeast Asia, not to people in general, as the authors discuss ([Sec. 5.2](https://arxiv.org/abs/2203.02155)).

> **How we checked this**
> We read the full text of Christiano et al. (arXiv 1706.03741 v4), Stiennon et al. (2009.01325 v3) and Ouyang et al. (2203.02155 v1) on Dec. 4, 2026, and took every number from the sections cited; venues were checked on arXiv and the NeurIPS proceedings site. TRL class and argument names come from the v1.19.0 docs for RewardTrainer, RLOOTrainer and SFTTrainer. PPO's removal was confirmed in TRL's GitHub repository (no `ppo` module in the v1.19.0 or main source trees), PR #7020 and the v1.13.0 release notes. The worked example is our arithmetic. We did not run the code.

## FAQ

### What are the three steps of RLHF?
Supervised fine-tuning on human-written demonstrations, training a reward model on human rankings of model outputs, and reinforcement learning (PPO in InstructGPT) against that reward model with a KL penalty to the SFT model.

### Why does RLHF need a reward model?
Humans can't score every output the policy produces during RL. The reward model learns to predict human comparisons and then scores millions of samples. Christiano et al. needed feedback on under 1% of agent interactions this way.

### What does the KL penalty do in RLHF?
It subtracts β times the log-ratio between the RL policy and the SFT model from the reward. Stiennon et al. say it acts as an entropy bonus and keeps outputs close to what the reward model saw in training.

### Is RLHF better than supervised fine-tuning?
In the papers, yes on human preference: a 1.3B RLHF summarizer beat a 10x larger supervised model (61% vs 43%), and 175B InstructGPT was preferred over few-shot GPT-3 71 ± 4% of the time.

### Does TRL still have a PPOTrainer?
No. TRL removed PPOTrainer and PPOConfig in v1.13.0 (Sept. 2026). The current release, v1.19.0, offers RewardTrainer for reward models and RLOOTrainer or GRPOTrainer for the online RL step.

### How much does RLHF cost compared with pretraining?
For InstructGPT, training the 175B PPO-ptx model took 60 petaflop/s-days, compared with 3,640 for GPT-3's pretraining, according to Ouyang et al. Human labeling came from about 40 contractors.

### What is the difference between RLHF and DPO?
RLHF trains a separate reward model and then runs online RL. DPO skips both and optimizes the policy directly on preference pairs with a classification-style loss. See Part 13 of this series.

## Related techniques

- [RLAIF](https://launchkudos.com/news/llm-fine-tuning-rlaif): the same pipeline with AI-written preference labels (Part 12)
- [DPO](https://launchkudos.com/news/llm-fine-tuning-dpo): preference tuning without a reward model or RL (Part 13)
- [GRPO](https://launchkudos.com/news/llm-fine-tuning-grpo): RL with group-relative advantages and no value model (Part 14)
- [RLVR](https://launchkudos.com/news/llm-fine-tuning-rlvr): RL against verifiable rewards (Part 15)
- [All 15 LLM fine-tuning techniques](https://launchkudos.com/news/llm-fine-tuning-techniques)
- [Distillation, LoRA and GRPO explained](https://launchkudos.com/news/distillation-lora-grpo-explained)

## Sources

- Christiano, P. F., Leike, J., Brown, T. B., Martic, M., Legg, S., Amodei, D. (2017). [Deep Reinforcement Learning from Human Preferences](https://arxiv.org/abs/1706.03741). arXiv:1706.03741, v1 June 12, 2017; NIPS 2017. Read Dec. 4, 2026.
- Stiennon, N., Ouyang, L., Wu, J., Ziegler, D. M., Lowe, R., Voss, C., Radford, A., Amodei, D., Christiano, P. (2020). [Learning to summarize from human feedback](https://arxiv.org/abs/2009.01325). arXiv:2009.01325, v1 Sept. 2, 2020; NeurIPS 2020. Read Dec. 4, 2026.
- Ouyang, L., Wu, J., Jiang, X., et al. (2022). [Training language models to follow instructions with human feedback](https://arxiv.org/abs/2203.02155). arXiv:2203.02155, March 4, 2022; NeurIPS 2022. Read Dec. 4, 2026.
- Hugging Face. [TRL Reward Trainer](https://huggingface.co/docs/trl/reward_trainer), [RLOO Trainer](https://huggingface.co/docs/trl/rloo_trainer), [SFT Trainer](https://huggingface.co/docs/trl/sft_trainer), v1.19.0. Checked Dec. 4, 2026.
- Hugging Face. [TRL v1.13.0 release notes](https://github.com/huggingface/trl/releases/tag/v1.13.0) and [PR #7020, "Remove PPOTrainer"](https://github.com/huggingface/trl/pull/7020), merged Sept. 4, 2026. Checked Dec. 4, 2026.
- Ahmadian, A., et al. (2024). [Back to Basics: Revisiting REINFORCE Style Optimization for Learning from Human Feedback in LLMs](https://huggingface.co/papers/2402.14740). arXiv:2402.14740. Abstract checked via the TRL docs, Dec. 4, 2026.

**Series:** [← Prev: Federated Tuning](https://launchkudos.com/news/llm-fine-tuning-federated-tuning) · [All 15 techniques](https://launchkudos.com/news/llm-fine-tuning-techniques) · [Next: RLAIF →](https://launchkudos.com/news/llm-fine-tuning-rlaif)
