Deep Reinforcement Learning from Human Preferences

RLHF (Human Prefs) banner Kaggle

Summary

Many tasks have goals that are hard to write as a reward function. This paper trains an agent without the reward: a person watches pairs of short clips of the agent and says which one is better. A neural network learns a reward function that agrees with these choices, and a normal reinforcement learning algorithm trains the policy on that learned reward (Sections 1 and 2.2).

The paper shows this can solve Atari games and simulated robot tasks with feedback on less than 1% of the agent’s interactions with the environment. It also teaches new behaviours, such as a Hopper robot doing backflips, with about an hour of human time (Abstract, Section 3.2).

What Problem Does It Solve

Imagine teaching a dog a trick. You cannot write down a formula for “good trick”, but you can easily say which of two attempts was better. If you do this often enough, the dog learns what you want.

Writing a reward function for “do a backflip” or “drive politely” is hard, and a wrong reward can lead to strange behaviour. Showing the task (imitation) needs an expert who can do it. Comparing two short clips is easy for a non-expert, so the paper asks people only for comparisons (Section 1).

Core Idea

  • Three processes: the policy acts in the environment and is trained to maximise the predicted reward; pairs of trajectory segments are sent to a human; the reward model is fitted to all comparisons so far. In the paper they run asynchronously (Section 2.2).
  • Preference model: the chance that segment 1 is preferred is exp(Σ r̂₁) / (exp(Σ r̂₁) + exp(Σ r̂₂)), where Σ r̂ is the predicted reward summed over the segment (Section 2.2.3, Eq. 1). This is the Bradley-Terry model, like Elo ratings in chess.
  • Loss: cross-entropy between these predictions and the human labels. If the human says the clips are equally good, the label is split 50/50 (Sections 2.2.2 and 2.2.3).
  • Normalised reward: the learned reward is shifted and scaled to zero mean and constant standard deviation before the policy uses it (Section 2.2.1).

Key Method Details

  • Policy learning: A2C for Atari and TRPO for the robotics tasks, with standard settings (Section 2.2.1).
  • Clips: 1 to 2 seconds long (Section 2.2.2).
  • Reward model fitting: an ensemble of predictors, 1/e of the data held out for validation, ℓ2 regularization, and an assumed 10% chance that the human answers at random (Section 2.2.3).
  • Choosing queries: pairs where the ensemble members disagree most (Section 2.2.4). The ablations show this sometimes hurts (Section 3.3).
  • No termination signal: episode ends would leak task information, so the paper removes them; for synthetic feedback in Atari, episode ends are replaced by a penalty in the oracle (Appendix A).
  • Scale: 700 human queries for the robotics tasks and 5,500 for Atari (Section 3.1); the backflip used 900 queries in less than an hour (Section 3.2).

Simplifications in This Notebook

  • Task: CartPole-v1 instead of Atari or MuJoCo; PPO instead of A2C or TRPO.
  • Synthetic oracle: prefers the segment with the higher CartPole reward, with a penalty of −10 for the step where the pole falls (as in Appendix A). Equal scores are ties with label 0.5. No real human labels.
  • One reward model on states only, trained every 5 iterations on random pairs; no ensemble, no regularization tuning, no query selection by disagreement.
  • Scale: 50 iterations of 2048 steps, 1,000 preferences, one seed.

What the Notebook Result Shows

  • The first version failed: CartPole gives +1 per step, so every 20-step segment tied and all labels were coin flips. That run reached only 25.8% of the baseline.
  • After the fix, RLHF matched the baseline: over 20 evaluation episodes the RLHF agent scored 190.4 ± 66.4 and PPO on the true reward scored 167.7 ± 49.2 (113.6% of the baseline mean). The ranges overlap and this is one seed, so it does not show RLHF is better. Neither agent solved the task (maximum 500).
  • The reward model predicted new pairs well: its accuracy on each round’s new pairs, before training on them, was between 0.778 and 1.0, and 1.0 in the last four rounds (round 0 is before any training).
  • Ties grew from 40% to 88% of new pairs, because a good policy rarely falls inside a segment, so the late accuracy numbers rest on few pairs.

Influence

OpenAI announced the work as “Learning from human preferences” (OpenAI blog, 13 June 2017), and co-author Tom Brown released an open implementation, rl-teacher. InstructGPT writes: “we use reinforcement learning from human feedback (RLHF; Christiano et al., 2017; Stiennon et al., 2020) to fine-tune GPT-3” (Ouyang et al., 2022, Section 1). OpenAlex lists about 7,600 citations (7,628 when checked on 3 December 2026).


Resources

File Description
README.md This overview — a 5-minute read covering the paper’s summary, core idea, key method details, influence, and a plain-English explanation of the problem it solves
solution.ipynb From-scratch PyTorch RLHF on CartPole-v1: synthetic preference oracle, Bradley-Terry reward model, PPO on the learned reward, and a PPO baseline on the true reward
CODE_ARCHITECTURE.md Section-by-section breakdown of the notebook — what each cell does, data flow, tensor shapes, and key design decisions
TALK.md Press coverage, Q&A (answers from the paper), citations, and common misconceptions about the paper

Table of contents