Search

Search papers and lessons

Deep Reinforcement Learning from Human Preferences

Paul Christiano, Jan Leike, Tom B. Brown et al. · 2017

The paper trains a reward model from short human comparisons of agent video clips, then optimises a deep RL policy against that learned reward, reaching strong results with a few hundred to a few thousand comparisons.

On this page

  • Colour = topic mix
  • Calculus
  • Probability
  • Reinforcement learning
  • Linear algebra
  • Neural network basics
  • Post-training
  • Sign in to see your progress

TL;DR

Writing a reward function for a complex task is hard, and a bad one gets exploited. This paper avoids writing one. A person compares two short video clips of the agent, and a reward model is fitted so that the clip the person prefers gets the higher predicted score. An ordinary deep RL algorithm then optimises the policy against that learned reward while the comparisons keep arriving. The authors report near-RL performance on robotics and substantial learning on Atari, from a few hundred to a few thousand human comparisons.

Where you'll see it: the reward-model step of reinforcement learning from human feedback, used to fine-tune chat and instruction-following language models.

The problem

Deep RL has done well where the reward is clear. Atari scores and game wins are written down. Many useful tasks have no such number. Cleaning a table or scrambling an egg is hard to score with a formula over sensor readings, and a hand-written proxy tends to be optimised in ways the designer did not intend. The paper frames this as misalignment between what we want and what the RL objective measures.

Two existing routes did not fit. Inverse reinforcement learning and imitation learning need demonstrations, and some behaviours are hard for a human to demonstrate, such as a robot with an unusual body. Direct human feedback as a reward is too expensive: deep RL needs hundreds or thousands of hours of experience, so a human would have to score every step. The paper's goal is to reduce the human effort by several orders of magnitude while still handling large problems. It also asks for four properties: the task can be recognised but not demonstrated, the teacher is a non-expert, the method scales, and it uses little feedback.

Key idea

Two ideas do the work. First, judge comparisons rather than scores. People find it easier to say which of two clips is better than to give each one an absolute number, and comparing short clips is nearly as fast as comparing single states. Second, learn the reward and the policy together. A reward predictor is fitted to the comparisons as they arrive, and the policy keeps optimising the current predictor. This online loop matters because a fixed learned reward gets exploited.

flowchart LR
  P[Policy acts in environment] --> T[Trajectory segments of 1 to 2 seconds]
  T --> Q[Human picks the better clip]
  Q --> D[Database of comparisons]
  D --> R[Reward model fitted to comparisons]
  R --> P

The three processes run asynchronously. Trajectories flow to the human, comparisons flow to the reward fitter, and reward parameters flow back to the policy's optimiser. The policy never waits for the human to finish labelling.

The method

Setting

At each step the agent sees an observation oto_t and sends an action ata_t. A normal RL problem would also deliver a reward rtr_t. Here the reward is hidden. A human can instead say which of two trajectory segments σ1\sigma^1 and σ2\sigma^2 they prefer, where a segment is a sequence of observations and actions of length kk. The notation σ1≻σ2\sigma^1 \succ \sigma^2 means the first segment was preferred.

The paper also defines when preferences are generated by a reward function rr: the preferred segment is the one with the larger sum of rewards. This gives a way to test the method on tasks where the true reward is known, even though the agent never sees it.

The reward model and the comparison likelihood

The learned reward is r^\hat{r}, a neural network over observation-action pairs. To connect it to the human, the paper treats r^\hat{r} as a latent score that explains the human's choices. The probability that the human prefers segment σ1\sigma^1 is

P^[σ1≻σ2]=exp⁡(∑tr^(ot1,at1))exp⁡(∑tr^(ot1,at1))+exp⁡(∑tr^(ot2,at2)).\hat{P}[\sigma^1 \succ \sigma^2] = \frac{\exp\big(\sum_t \hat{r}(o^1_t, a^1_t)\big)}{\exp\big(\sum_t \hat{r}(o^1_t, a^1_t)\big) + \exp\big(\sum_t \hat{r}(o^2_t, a^2_t)\big)}.

This is a softmax over the summed predicted rewards of the two segments, and it follows the Bradley-Terry model for pairwise preferences, with the same form as the Elo rating used in chess. The paper uses no discounting in this sum. It says the choice is a modelling decision and that discounting or inferring the human's discount would also be reasonable.

Training minimises the cross-entropy between this prediction and the human label. If the database holds triples (σ1,σ2,μ)(\sigma^1, \sigma^2, \mu), where μ\mu puts mass on the chosen segment and is uniform on a tie, then

loss(r^)=−∑(σ1,σ2,μ)∈D[μ(1)log⁡P^[σ1≻σ2]+μ(2)log⁡P^[σ2≻σ1]].\mathrm{loss}(\hat{r}) = -\sum_{(\sigma^1, \sigma^2, \mu) \in \mathcal{D}} \Big[\mu(1) \log \hat{P}[\sigma^1 \succ \sigma^2] + \mu(2) \log \hat{P}[\sigma^2 \succ \sigma^1]\Big].

Comparisons the human marks as incomparable are dropped from the database.

Example
One comparison, worked by hand

Suppose the summed predicted rewards are 3.0 for segment one and 1.0 for segment two.

  1. The gap is 3.0−1.0=2.03.0 - 1.0 = 2.0. The prediction is P^[σ1≻σ2]=e3/(e3+e1)≈20.09/22.80≈0.881\hat{P}[\sigma^1 \succ \sigma^2] = e^{3} / (e^{3} + e^{1}) \approx 20.09 / 22.80 \approx 0.881. This equals the sigmoid of the gap, σ(2)≈0.881\sigma(2) \approx 0.881.
  2. If the human picked segment one, the loss for this comparison is −log⁡(0.881)≈0.127-\log(0.881) \approx 0.127. The model agrees with the human, so the loss is small.
  3. If the human picked segment two, the loss is −log⁡(1−0.881)=−log⁡(0.119)≈2.13-\log(1 - 0.881) = -\log(0.119) \approx 2.13. The model disagrees strongly, so the gradient pushes the two sums toward each other.

Interpretation: the loss depends only on the difference of the two sums, not on their absolute level. That is why the learned reward has no fixed scale, a point the paper returns to when it normalises the reward. These numbers are analytic values for this example, not output from the paper.

Refinements to the basic model

The paper reports several changes that its early experiments found helpful. Each is analysed in the ablations.

  • Ensemble. Several reward predictors are trained, each on a bootstrap sample of the comparisons, meaning the same size drawn with replacement. Each predictor is normalised separately, and then their outputs are averaged. The paper cites Ensemble Learning as the general idea.
  • Validation and regularisation. One part of the data, a fraction of 1/e1/e, is held out for validation. The ℓ2\ell_2 coefficient is adjusted so the validation loss stays between 1.1 and 1.5 times the training loss. Some domains also use Dropout. The regulariser is L2 Regularization.
  • Random errors. The model is not a pure softmax. The paper assumes the human answers uniformly at random 10 percent of the time. Human error has a roughly constant rate, and a pure softmax would push the predicted probability toward zero or one no matter how close the rewards are. Here the choice is 90 percent the softmax prediction and 10 percent a coin flip.

Choosing which clips to ask about

Asking about random pairs wastes the human's time when the reward model is already confident. The paper samples many pairs of segments of length kk, asks every ensemble member to predict the winner of each pair, and keeps the pairs on which the members disagree most. Disagreement is used as a rough stand-in for uncertainty. The paper calls this a crude approximation and notes that in some tasks it hurts performance. The principled alternative, choosing queries by their expected value of information, is left to future work.

Policy optimisation

The policy is trained with a standard RL algorithm, using the learned reward in place of the true one. The paper uses advantage actor-critic (A2C) for Atari and trust region policy optimisation (TRPO) for robotics. Both are policy gradient methods. The authors chose this family because the learned reward is non-stationary, and they wanted methods robust to that kind of change. Trust Region Policy Optimization (TRPO) and Advantage Function are the relevant background. The learned reward is normalised to zero mean and constant standard deviation before it reaches the policy. The text says the position of a learned reward is underdetermined, so normalisation is a typical and sensible step. The only hyperparameter the authors tuned for these algorithms is the entropy bonus for TRPO, because the trust region can under-explore when the reward keeps changing.

Length of the clips

Each comparison shows a clip of 1 to 2 seconds. The authors found that comparing longer clips was more helpful per clip but less helpful per frame, because a short clip takes a while just to understand. Evaluation time grows roughly linearly with clip length beyond a point, and they chose the shortest length where that holds.

Results

Every number here is the paper's report, not a rerun. The paper evaluates on MuJoCo robotics tasks and seven Atari games, using the true reward only to measure results, never to train.

  • Robotics, 700 labels. With 700 comparisons the method nearly matches RL on the true reward across the simulated tasks. Learned rewards gave less stable learning with higher variance and a similar mean. With 1,400 synthetic labels the method was slightly better than RL on the true reward on some tasks. The authors say the learned reward may be better shaped.
  • Real human feedback. Human labels were typically somewhat less effective than synthetic ones. Depending on the task, humans ranged from half as efficient as ground truth to equally efficient. On the Ant task, human feedback clearly beat synthetic feedback, apparently because the humans rewarded standing upright.
  • Atari, 5,500 labels. The method learns substantially on most games and matches or exceeds RL on some. On BeamRider and Pong, synthetic labels come close to RL with about 3,300 labels. Qbert with real humans failed to clear the first level, which the authors attribute to short clips being hard to judge in that game.
  • Novel behaviours. About an hour of feedback, from 800 to 1,300 queries depending on the task, taught a backflip with landing, a half-cheetah moving forward on one leg, and keeping pace with traffic in Enduro. The behaviours were labelled by the authors, not by contractors.
  • Human time. The paper reports that the experiments with real human feedback needed between 30 minutes and 5 hours of human time. The headline claim is that the method reduced interaction complexity by roughly three orders of magnitude relative to direct feedback.

The ablations clarify which parts matter. The paper compares random queries, a single predictor instead of an ensemble, no online queries, no ℓ2\ell_2 regularisation, length-1 segments, and training on the true total reward of each segment. Two findings stand out. Training the reward model offline, with all its comparisons collected at the start, performs poorly. The authors trace this to the non-stationary state distribution, where the predictor learns only part of the true reward and the policy finds strange ways to maximise that part, such as endless volleys in Pong. Second, predicting comparisons worked much better than predicting absolute scores on continuous control, probably because the scale of rewards varies and makes regression harder.

Why it mattered

The paper's own claim is that it provides the first evidence that reward learning from human preferences can be scaled economically to state-of-the-art deep RL. It also observes that the cost of compute was already comparable to the cost of non-expert feedback, so further savings in sample complexity would bring diminishing returns.

The recipe it set out is the one that later work reused: collect pairwise human comparisons, fit a reward model with a Bradley-Terry likelihood, and optimise a policy against that model. This pattern was applied to fine-tuning language models with human feedback, for example in Ouyang et al. (2022), listed in the sources. The details of that later work belong in the Reinforcement Learning from Human Feedback (RLHF) lesson.

Reading guide

Read the paper in this order. Each prerequisite is linked where it first matters.

Check yourself

QuestionWhy does the method ask humans to compare clips rather than give each clip an absolute score?Show answer

The paper found that humans give more consistent comparisons than absolute scores, especially on continuous control tasks and on qualitative goals. Absolute scores also have a scale that varies across tasks, which makes the regression harder. Predicting comparisons only requires the reward model to get the order right, so the problem is smoother. The paper confirms that predicting comparisons worked much better than predicting scores on continuous control.

QuestionTwo segments have summed predicted rewards of 1.0 and 3.0. What is the predicted probability that the human prefers the segment with sum 3.0, and what is the loss if the human actually chose the other segment?Show answer

The probability is e3/(e1+e3)≈0.881e^{3} / (e^{1} + e^{3}) \approx 0.881. If the human chose the segment with sum 1.0, the predicted probability for that choice is 1−0.881=0.1191 - 0.881 = 0.119, and the cross-entropy loss is −log⁡(0.119)≈2.13-\log(0.119) \approx 2.13. The loss is large because the model is confident and wrong.

QuestionWhy does the paper train the reward model online, alongside the policy, rather than fitting it once on a fixed set of comparisons?Show answer

Offline training performed poorly in the ablations. The state distribution changes as the policy improves, so a reward model fitted to early comparisons captures only part of the true reward. The policy then finds strange behaviours that maximise that partial reward, such as avoiding point losses in Pong without scoring. Gathering comparisons from the current policy's clips keeps the reward model accurate where the policy goes.

QuestionYou want to apply this method to a task where each human comparison costs much more time than in the paper. Which design choices in the paper would you revisit first, and why?Show answer

Start with the query selection and the clip length. The paper chooses queries by ensemble disagreement, which the authors call a crude approximation, and notes it can hurt in some tasks. Better query choice could reduce the number of comparisons needed. Clip length is a trade-off the paper measured: longer clips give more information per comparison but take longer to evaluate, and the shortest length where evaluation time is linear is a reasonable default. Check both against the paper's ablations before changing anything else.

Sources

Read the full paper

Paul Christiano, Jan Leike, Tom B. Brown et al., 2017. arXiv:1706.03741