Home Knowledge Base Reinforcement Learning from Human Feedback (RLHF)

Reinforcement Learning from Human Feedback (RLHF) is the alignment technique that turned raw language models into usable assistants. A pretrained model is fluent but aimless — it predicts plausible next tokens without any sense of which responses are helpful, honest, or safe. RLHF fixes that by learning a model of human preference and then optimizing the language model against it. It is the method behind the "instruct" and "chat" versions of most frontier models, and the reason they follow instructions and refuse harmful requests instead of merely autocompleting.\n\n``svg\n\n \n RLHF — Turning Human Preference into a Training Signal\n a base model knows how to predict text; RLHF teaches it which answers people actually want\n \n Pretrained\n base LLM\n \n 1. SFT\n demo answers\n \n 2. Reward Model\n learns human taste\n \n 3. RL / PPO\n optimize reward\n \n \n \n \n \n \n \n \n \n Aligned model\n helpful + harmless\n \n How the reward model learns\n Same prompt, two answers — a human picks the better one.\n \n prompt\n \n answer A ✓ chosen\n \n answer B ✕ rejected\n \n \n \n \n loss = -log σ( r(A) − r(B) )\n score the chosen answer above the rejected one\n \n The RL loop, on a leash\n \n policy (LLM)\n \n reward model\n \n \n answer\n \n \n \n reward signal → update policy\n anti-drift leash\n \n − β · KL( policy ‖ frozen reference )\n \n DPO shortcut:\n skip the separate reward model and RL loop — train the language model\n directly on the chosen/rejected pairs with one classification-style loss.\n\n``\n\nStage one is supervised fine-tuning (SFT). Human contractors write high-quality example answers to a range of prompts, and the base model is fine-tuned to imitate them. This alone gets the model into the neighborhood of helpful behavior — it now answers questions rather than continuing them — but imitation has a ceiling: humans cannot demonstrate the best possible answer to every prompt, and writing demonstrations is slow and expensive.\n\nStage two trains a reward model from comparisons, not demonstrations. Instead of writing ideal answers, humans are shown two model outputs for the same prompt and simply pick the better one. Preference judgments are far cheaper and more reliable than authored answers. A separate reward model is trained on these pairs to output a scalar score, using a loss that pushes the chosen answer's score above the rejected one. The reward model becomes a learned, automatable stand-in for human taste.\n\nStage three optimizes the policy with reinforcement learning, usually PPO. The language model (now the "policy") generates answers, the reward model scores them, and the score is used as a reward signal to update the policy toward higher-scoring outputs. Crucially, a KL-divergence penalty tethers the policy to the original reference model so it cannot drift into degenerate text that games the reward. This leash is what keeps RLHF stable.\n\nReward hacking is the central failure mode. Because the policy optimizes the reward model rather than true human preference, it will exploit any gap between them — becoming sycophantic, verbose, or confidently wrong in ways the reward model happens to score highly. Managing this trade-off, sometimes called the alignment tax (aligned models can lose a little raw capability), is much of the practical craft of RLHF.\n\nDPO and its relatives simplify the pipeline. Direct Preference Optimization skips the separate reward model and RL loop entirely, deriving a loss that trains the language model directly on the chosen/rejected pairs. It is far simpler and cheaper to run and has become a popular default, though PPO-style RLHF still tends to reach the highest quality at the frontier. RLAIF replaces human labels with AI-generated preferences to scale the data further.\n\n| Stage | Data it needs | What it produces | Main risk |\n|---|---|---|---|\n| SFT | human-written answers | a model that follows instructions | limited by demonstration quality |\n| Reward model | human A-vs-B preferences | a scalar "human taste" scorer | mislabeled or noisy preferences |\n| PPO / RL | prompts + reward model | a preference-optimized policy | reward hacking, drift |\n| DPO (alt.) | the preference pairs directly | aligned model, no RM or RL loop | slightly lower ceiling than PPO |\n\nRead RLHF through a preference-signal lens rather than a teach-it-the-answer lens: the breakthrough is not that humans show the model what to say, but that humans only have to say which of two answers is better, and that cheap comparative signal is amplified — first into a reward model, then into a full optimization objective — until it reshapes a fluent-but-aimless predictor into an assistant that reliably does what people want.\n

reinforcement learning from human feedbackRLHF advancedPPO alignmentreward hackingalignment tax

Explore 500+ Semiconductor & AI Topics

From EUV lithography to CUDA optimization — search the full knowledge base or chat with our AI assistant.