RLHF — How LLMs Learn from Feedback

P9.policy-methods-rlhf.03 · Audience: guest, it-ml, language-pro · Prerequisites: Reward Models & Preferences

Everything in this pillar has been quietly assembling one machine. You have a policy that improves by chasing reward, and a reward model that manufactures a reward from human preferences. Put those two together, point them at a language model, and you have RLHF — reinforcement learning from human feedback, the step that turns a raw next-token predictor into an assistant that is helpful, honest, and hard to provoke. This is the bridge module: it does not teach transformers (that is the LLM pillar's job) and it does not re-teach RL (you already have it). It shows how the RL machinery you built clicks into the LLM training pipeline — and, just as importantly, what that machinery can and cannot change.

Step 1 / 5Three stages: pretraining, SFT, RLHF

A modern language model is built in stages, and RLHF is the last of them. It helps to see all three before zooming in, because each stage does a different job and RLHF only makes sense as the finishing touch on top of the other two.

StageWhat it doesWhat it produces
PretrainingPredict the next token over a vast text corpus — learn language, facts, and patterns.A fluent but unsteered next-token predictor.
SFT (supervised fine-tuning)Imitate curated example answers, so the model learns the shape of a helpful reply.A model that follows instructions in the right format.
RLHFOptimise a reward model built from human preferences — steer which good-shaped answer to prefer.An assistant tuned toward human-preferred behaviour.

This module lives entirely in the third box. How the base model is built — the transformer, attention, tokenisation, and what pretraining and fine-tuning actually do — is the subject of the LLM pillar. Meet the base model in What an LLM actually is, and the pretraining-then-fine-tuning story in Prompting & fine-tuning. Here we take the base model as given and add the RL.

Ask the mentor about this module

Ask a question about this content. The mentor explains and grounds its answer in what you are studying; asking is recorded as a learning signal, not a grade.

Ctrl/Cmd + Enter to send

Try it yourself

A scratch console for this page's ideas — ungraded, nothing you run here is recorded.

Scratch console

A scratch console with the scientific stack (pandas, numpy, scikit-learn). Runs on the server — no network, resource-limited and measured.

Output appears here.

Where next?

Continue

What is a model? What is an algorithm?

Orientation — concepts before the maths · P10