⌂ Contents
Session 6
Note: This page's design and content were created and enhanced using Claude (Anthropic's AI assistant); the reading list has been reference-checked. Spot an error? Email jonathan.shock@uct.ac.za.
Week 3 • Session 6.1

From demonstrations to preferences

Why learning from human comparisons breaks through the ceiling that supervised fine-tuning hits

Session 6 — RLHF & RL fine-tuning

Session 5 left us at a wall: supervised fine-tuning can imitate a good answer but cannot express "this answer is better than that one", and so caps out at demonstration quality. This session is about the technique that broke through it, reinforcement learning from human feedback, and the price it charges: we now optimise a learned proxy for human approval, with all the Goodhart hazards of Session 3.1.

This session's sub-sessions: 6.1 from demonstrations to preferences · 6.2 the reward model · 6.3 policy optimisation: PPO & the KL leash · 6.4 the limits of RLHF · 6.5 lab (Colab).

What we'll cover

This sub-session motivates the RLHF pipeline. We recall why SFT stalls, introduce the central idea (learn from preferences, not demonstrations), trace its short but consequential history (from Atari to InstructGPT), and lay out the three-step pipeline the next sub-sessions unpack. Throughout, keep one question live: what does optimising a model of what humans approve of incentivise, as opposed to optimising for what is actually good?

Mandatory readings

Christiano et al. (2017), "Deep Reinforcement Learning from Human Preferences" (NeurIPS 2017; arXiv:1706.03741): read §2 (Preliminaries and Method), which sets up the problem and gives the comparison-based method in full. Skim the experiments for the Atari and simulated-robotics results. ≈1,700 words.

Total mandatory load: ≈1,700 words.

Optional readings

Stiennon et al. (2020), "Learning to summarize from human feedback" (arXiv:2009.01325): the bridge from control tasks to language, with unusually careful data-collection detail.

Bai et al. (2022), "Training a Helpful and Harmless Assistant with RLHF" (arXiv:2204.05862): RLHF as actually deployed, at length.

Judging is easier than producing

Recall the asymmetry from Session 5.2: for most of what we want from an assistant, judging is far easier than producing.

You may not be able to write the ideal answer to an open-ended question, or the perfectly calibrated, honest response. But shown two attempts, you can usually say which is better. SFT cannot use that ability: its loss, "make this target more likely", needs a single demonstration to imitate and has no way to encode "A > B". So SFT inherits three limits: it caps at demonstration quality, it can't express comparative judgement, and it has no negative signal (Session 5.2). The opening is obvious in hindsight: build the training signal out of the comparisons humans can reliably give, not the demonstrations they struggle to author.

A short primer on reinforcement learning

If you have not met reinforcement learning before, this is what the rest of Session 6 assumes. Nothing in this box is about language models. The translation to them comes at the end.

In supervised learning every training example carries the right answer and the model is asked to reproduce it. Reinforcement learning has no right answers. An agent observes the state of its environment, chooses an action, and the environment responds with a new state and a number, the reward. Nothing says what the agent should have done. It learns by trying things and doing more of whatever scores well. Session 3.2 set this up formally as a Markov decision process.

Take a program learning to play a board game. The state is the position, the actions are the legal moves, and the reward is \(+1\) for a win and \(-1\) for a loss, delivered once, at the end. Two difficulties appear immediately. The reward is sparse and delayed: fifty moves produce a single number, long after most of them were played. And that number has to be shared out among those fifty moves, which is the problem of credit assignment. The game was lost; nothing tells you which move lost it.

The vocabulary is small.

  • Policy: the rule that picks an action in a given state, usually as a probability spread over the available actions. This is the thing being learned.
  • Episode: one complete run from start to finish. One game.
  • Return: the total reward collected over an episode.
  • Value, and the advantage built from it. Value is how well the agent does from a given position on average, under its current policy. Value matters because "was that good?" is the wrong question: winning from a position you were already expected to win from teaches nothing. The useful question is whether the outcome beat expectation, and the gap between what happened and what was expected is the advantage. A second model, the critic, is trained to supply the expectation.

The update follows from that: make actions that turned out better than expected more likely, and actions that turned out worse less likely. Because "better than expected" is itself estimated from a handful of episodes, a large step on that estimate can wreck a policy that was working. Keeping each step small is the problem PPO solves in 6.3.

Now the translation. This session is that same loop with the board game swapped out.

In reinforcement learningIn this session
agentthe language model being trained
statethe prompt, plus whatever has been generated so far
actionemitting the next token
episodeone prompt and one complete response
rewarda single number for the finished response, from the reward model of 6.2

Both difficulties transfer intact. A response of two hundred tokens earns one score, arriving only at the end, with nothing to say which token earned it. And the reason to take on that trouble, when supervised fine-tuning is so much simpler, is the asymmetry above: reinforcement learning needs only to score an answer, where supervised learning needs someone to have produced one.

The idea: optimise for what humans prefer

The idea

Instead of "imitate this answer", RLHF says: collect human judgements of which of two model outputs is better, distil those judgements into a learned reward model, and then use reinforcement learning to push the model toward outputs the reward model scores highly. Comparisons are cheaper and more reliable than demonstrations; the reward model turns a pile of "A > B" judgements into a signal you can optimise against at scale; and the result can exceed the quality of any single human demonstration, because it is chasing "better" rather than "copy this".

That last point matters most. SFT is bounded above by its demonstrators. A preference-trained model can, in principle, climb past them: as long as humans can recognise improvements, the model can be pushed toward them even if no human wrote the ideal answer. The same property is also the danger: "push toward what humans recognise as better" quietly becomes "push toward what looks better to a rater", and those diverge (we will see this as sycophancy in 6.4).

Comparisons versus demonstrations

Take the task "write a clear, honest two-sentence summary of this paper." A demonstration asks an annotator to produce the ideal summary, which is slow and capped by that person's own writing; two good annotators will write different "ideal" answers, so the target is noisy. A comparison asks only whether summary A is better than summary B, which is quick and far more reproducible: annotators who could never agree on the perfect summary will readily agree that the fluent, faithful one beats the rambling, inaccurate one. The same human hour yields more signal, and signal that is less arbitrary. And because the model is being told which of its own samples is better, it climbs its own gradient of quality rather than aiming at one fixed human answer, which is how it can end up better than any single demonstration in the data.

The preference-collection loop

The collection loop is where human values quietly enter the system. For a prompt \(x\), sample two or more responses from the current model; show them to a human annotator with a set of instructions ("prefer helpful, honest, harmless answers; penalise confident falsehoods…"); record which they pick. Repeat across tens of thousands of prompts to build a dataset of triples \((x, y_w, y_l)\): a prompt, a preferred ("winning") response, and a dispreferred ("losing") one. Two choices here do a great deal of work, and both return in 6.2 and Session 8: who the annotators are (their language, context and training), and what the instructions told them to value. A reward model can only learn the preferences these choices wrote into the data.

The people in the loop

The paragraph above asks who the annotators are and answers in terms of what that does to the data. There is a second answer, about what the work does to them.

Much of this labelling is outsourced. In January 2023 TIME reported that OpenAI had contracted Sama, a San Francisco firm, to help build a filter for detecting toxic content, and that the work was done by employees in Kenya taking home between $1.32 and $2 an hour while OpenAI paid Sama $12.50 an hour for it (Perrigo, 2023). They read and categorised tens of thousands of passages describing violence, hate speech and sexual abuse. All four workers interviewed described being mentally scarred by it; counselling was available and they reported it was not usable under the productivity targets. Sama ended the contract eight months early.

The labelling existed to build the filter. This is not a general cost of building AI systems that happened to land on someone: the dataset existed to make the model safer, so the harm was incurred in the production of safety itself.

Hold both halves of that when 7.1 costs the same labour out, at roughly 830 hours per 100,000 comparisons, and treats it as a reason to move from human feedback to AI feedback. Fewer people having to read this material is a real argument for RLAIF. It is also an argument for removing the humans whose judgement the method exists to capture. Session 8.3 gives a framework for holding both at once, and 20.2 puts it in the wider critique of what "safety" is taken to cover.

A short history

From game-playing to chatbots

  • Christiano et al. (2017), "Deep RL from Human Preferences". The foundational paper: learn a reward function from human preferences between short trajectory segments, then optimise it with RL. It taught simulated robots and Atari agents complex behaviours from feedback on under 1% of their interactions; sometimes these were behaviours no one could easily hand-specify a reward for.
  • Stiennon et al. (2020), "Learning to summarize from human feedback". The first big language application: a reward model trained on human comparisons of summaries, then RL. The summaries were preferred by humans over the reference (human-written) summaries and over much larger supervised models. Optimising the learned reward beat optimising ROUGE, a hand-coded proxy.
  • Ouyang et al. (2022), InstructGPT. RLHF applied to general instruction-following, the recipe behind ChatGPT-style assistants. The central result: outputs from the 1.3B-parameter InstructGPT were preferred to those of the 175B-parameter GPT-3, a 100× smaller model made more useful by alignment rather than scale.
  • Bai et al. (2022), Anthropic's "Helpful and Harmless" assistant. RLHF for helpfulness and harmlessness together, with iterated (weekly) online data collection; found the "alignment tax" on raw capability to be small at scale.

RLHF as deployed alignment

RLHF is the technique that turned capable-but-unusable base models into the assistants now deployed to hundreds of millions of people. Its successes (InstructGPT) and its failure modes (6.4) therefore carry real stakes: they belong to the alignment method in production. Understanding what it optimises is understanding what today's "aligned" models are aligned to.

A common misconception: RLHF makes the model "smarter"

It mostly does not. The knowledge, the reasoning, the language: all of that capability is laid down in pre-training (Session 5.1). Preference-based RLHF, the pipeline this session covers, largely elicits and reshapes what is already there: it changes which behaviours surface, the format of answers, the willingness to follow instructions and to refuse. That is why a 1.3B InstructGPT could be preferred to the 175B GPT-3 it was built from: the smaller model gained no raw ability, it was made to use its ability the way people wanted. Keep this straight, because it bounds what alignment-by-RLHF can do: it is a powerful lever on behaviour and disposition, and a weak one on competence. Whether RL on verifiable rewards, the neighbouring stage in 5.3, extends competence or only elicits it is a separate and contested question.

The three-step pipeline

The three steps

  1. Supervised fine-tuning: start from an SFT model (Session 5.2); this is the policy we will refine and the anchor we will stay close to.
  2. Reward modelling (6.2): collect human comparisons of model outputs and fit a reward model \(r_\phi\) that scores a response, via the Bradley–Terry model.
  3. RL fine-tuning (6.3): optimise the policy to maximise \(r_\phi\), penalised for drifting too far from the SFT model (the KL "leash"), typically with PPO, or skip the explicit RL with DPO.

Each step is an opportunity and a hazard. Step 2 compresses the entirety of "what humans want" into a single learned number: a proxy. Step 3 then optimises hard against that proxy, which (Session 3.1) is the recipe for specification gaming unless something holds it back. The KL leash is that something; whether it is enough is the question of 6.4.

Questions to bring to class

Next

Step 2 is where human judgements become a number. Sub-session 6.2 builds the reward model (the Bradley–Terry preference model and its loss) and names the proxy we are about to optimise.