Back to Glossary
LLM

RLHF (Reinforcement Learning from Human Feedback)

Definition

RLHF is a training technique that aligns language model outputs with human preferences by training a reward model on human comparisons and using reinforcement learning to optimize the LLM toward higher-scoring responses.

Why It Matters

RLHF is why ChatGPT feels helpful instead of weird. Raw language models trained only on internet text tend to produce outputs that are technically coherent but often unhelpful, offensive, or misaligned with user intent. RLHF bridges that gap.

The core insight: humans can compare outputs more easily than they can write perfect examples. Instead of collecting ideal responses (expensive, slow), collect comparisons, “which response is better?” A reward model learns these preferences, then the LLM optimizes to maximize that reward.

For AI engineers, RLHF matters because it explains model behavior. When a model refuses certain requests, that’s RLHF. When it gives helpful structure to responses, that’s RLHF. Understanding this helps you work with (not against) the model’s training, and explains why prompt engineering techniques work.

Implementation Basics

RLHF has three stages that build on each other:

1. Supervised Fine-Tuning (SFT) Start with a pre-trained model and fine-tune it on high-quality demonstrations of desired behavior. This gives the model a foundation of helpful, honest, harmless responses before preference learning begins.

2. Reward Model Training Collect human comparisons: given a prompt, show two responses and ask “which is better?” Train a separate model (the reward model) to predict these preferences. The reward model takes a (prompt, response) pair and outputs a scalar score.

3. Reinforcement Learning Use PPO (Proximal Policy Optimization) or similar algorithms to fine-tune the SFT model. The reward model provides training signal, generate a response, score it, update the model to increase scores. A KL divergence penalty prevents the model from drifting too far from the SFT baseline.

RLHF is complex and expensive. Collecting human preferences requires significant labeling infrastructure, and RL training is notoriously unstable. Most practitioners use pre-RLHF’d base models from providers and apply additional fine-tuning on top.

For custom alignment work, consider DPO (Direct Preference Optimization) instead. It achieves similar results without the reward model and RL complexity. RLHF is increasingly a technique for frontier labs rather than application developers.

Source

InstructGPT, trained with RLHF, produces outputs that human labelers significantly prefer over GPT-3 outputs despite being 100x smaller in parameters.

https://arxiv.org/abs/2203.02155