Skip to main content
L8.9

RLHF: Human Preferences and Reward Models

About 48 min

Goal

By the end of this lesson, you can trace an RLHF-style pipeline from human preference comparisons to a reward signal and policy update, and explain why reward optimization still needs independent quality and safety evaluation.

Suppose a pretrained assistant can answer questions, but its responses are often unhelpful or poorly aligned with the behavior people want.

One practical route is to collect comparisons between candidate responses and use those comparisons to shape a training signal. This family of methods is commonly called reinforcement learning from human feedback (RLHF).

Build the pipeline from concrete artifacts​

A simplified pipeline is:

pretrained model
-> supervised fine-tuning
-> collect human preference comparisons
-> train or use a preference/reward signal
-> optimize the policy toward higher reward
-> evaluate regressions, quality, and safety

The model being optimized is the policy. Human comparisons provide evidence about which outputs are preferred under a rubric.

Preference pairs do not directly become truth​

A pair might contain:

prompt: explain the refund rule
chosen: cites the supplied 30-day policy
rejected: invents a 90-day exception

The pair says that the chosen response was preferred under the annotation criterion. It does not prove that every chosen response in the dataset is factually correct or safe.

The annotation rubric, annotator disagreement, data coverage, and shortcuts such as length all affect what the preference signal means.

What a reward model does​

A reward model or preference model can be trained to assign a scalar score that tends to rank preferred responses above rejected ones.

Conceptually:

prompt + response -> reward score

A common pairwise model turns two scalar scores into a preference probability:

P(A preferred over B) = sigmoid(r_A - r_B)

If r_A is much larger than r_B, the probability moves toward 1. If the scores are equal, the probability is 0.5. Training adjusts the reward model so observed human preferences become more likely under this pairwise rule. The score itself is still a learned proxy; it is not a truth score.

Notice that this pairwise probability depends on the difference r_A - r_B. Adding the same constant to both scores leaves that probability unchanged. That means the absolute zero point of this toy pairwise score should not be treated as if it were a universal amount of “goodness.”

The policy can then be optimized to produce responses that receive higher predicted reward. Real RLHF pipelines may transform rewards into advantages, normalize them, compare them with a baseline, and add terms such as KL penalties. The Browser Lab uses a much smaller centered signal only to preserve the relative preference direction without pretending the raw reward-model score has a meaningful absolute origin.

PPO (Proximal Policy Optimization) was a prominent policy-optimization method in early LLM RLHF pipelines and remains an important reference point. You do not need to implement PPO here. The important idea is that the policy is updated using a reward-like signal rather than a single supervised target sentence.

Verifiable rewards are a different modern RL route​

Human preferences are not the only possible reward source. Some tasks have answers that a program can check directly:

math answer -> exact-answer checker
code -> unit tests
proof -> formal verifier

Using reinforcement learning with this kind of automatically checkable signal is often called reinforcement learning with/from verifiable rewards (RLVR). It is especially relevant to recent reasoning-model training because many mathematics and coding tasks provide cheap, repeatable correctness checks.

DeepSeekMath introduced GRPO (Group Relative Policy Optimization), a PPO-related method, for mathematical reasoning. DeepSeek-R1 later demonstrated large-scale reinforcement learning for reasoning and used rule-based rewards for verifiable tasks in its training recipe. These examples do not mean every reasoning model uses GRPO or the same reward design.

Keep the two routes separate:

human preference route:
comparisons -> learned preference/reward signal -> policy optimization

verifiable-reward route:
checkable task outcome -> programmatic reward -> policy optimization

Both are reinforcement-learning-style post-training ideas, but their reward evidence comes from different places.

Why keep a reference or base constraint​

If optimization pushes only toward higher learned reward, the policy may move too far from useful pretrained behavior. RLHF systems therefore commonly use constraints or penalties that discourage excessive deviation from a reference/base policy.

The exact algorithm can differ, but the engineering question is stable: how do we improve the measured preference signal without allowing uncontrolled drift?

Reward optimization can exploit mistakes in the reward​

A reward model is imperfect. If it accidentally gives extra points to long confident answers, the policy can learn to produce longer, more confident answers even when they are wrong.

This is sometimes described as reward hacking or exploiting a proxy.

The core lesson is broader than the name:

better measured reward != guaranteed better real-world behavior

Independent evaluation is still required for factuality, task success, safety, and retention.

The bridge to DPO​

An RLHF-style route can be summarized as:

preferences -> reward model/signal -> RL policy optimization

A DPO-style route uses the preference pairs more directly:

preferences -> direct preference objective

DPO was designed to avoid an explicit reward-model-plus-RL optimization loop for this setting. That does not make DPO and RLHF universally identical or interchangeable. They are different optimization routes built from related preference evidence.

Predict

A reward model gives high scores to confident answers, including confident false answers. What should the team conclude?

Run the Browser Lab​

The deterministic Lab shows:

  • two candidate responses;
  • two scores treated as outputs from an already-trained toy reward model;
  • the pairwise probability sigmoid(r_A - r_B);
  • a centered toy reward signal made by subtracting the two-candidate mean score;
  • a toy policy update driven by that centered signal;
  • a second case where a flawed relative reward signal favors a false response.

The Lab does not train the reward model itself and does not implement PPO. It starts from illustrative reward-model outputs so you can inspect the next boundary in the pipeline.

First inspect the printed reward-model scores, preference probability, and centered reward signals. With the default scores 1.2 and -0.4, the mean is 0.4, so the centered signals are +0.8 and -0.8.

The toy policy update in this Lab is deliberately simple:

new policy score = old policy score + learning rate × reward signal

The default learning rate is 0.25. For the supported response, the first update is therefore:

0 + 0.25 × 0.8 = 0.20

This arithmetic is only a teaching step; it is not PPO. Use it to complete policy_score_update(score, reward, learning_rate) in the starter.

Now add 10 to both reward-model scores. Predict before running: the pairwise preference probability should stay the same, and the centered policy reward signals should also stay the same. This demonstrates why a shared score offset should not change the toy update.

Then change the difference between the two scores and observe how both the preference probability and centered signals change. Inspect how those signals now move the toy policy scores.

Finally inspect the proxy-failure pair. The false response receives the higher toy reward-model score, so its centered signal is positive and the toy policy update moves toward it even though truth_ok remains false. This isolates the real lesson: relative reward can guide optimization while still being a bad proxy for an independent requirement.

Loading lab…

Quick Check

1. What role does a reward model play in an RLHF-style pipeline?
2. Why use a reference/base constraint during policy optimization?
3. What is the high-level difference between the RLHF-style route and DPO-style route taught here?

0 of 3 questions answered.

Explain it back​

Trace the pipeline from a pretrained model to SFT, preference collection, reward modeling, policy optimization, and independent evaluation. Then explain one way a policy could improve reward while becoming worse on a real requirement.

Check your explanation

A strong answer mentions:

  • Trace pretrained model → supervised fine-tuning (SFT) → fixed-context preference pairs → reward model → policy optimization → independent evaluation.
  • A policy may learn to score well on the reward model by exploiting superficial preferences while increasing unsupported answers or breaking another requirement.
  • Reward improvement alone is insufficient; verify target performance and regressions on an independent suite.

Key Takeaways

  • RLHF uses human preference evidence to shape a reward-like training signal.
  • A reward model predicts preference; it does not guarantee truth or safety.
  • Policy optimization can exploit weaknesses in an imperfect reward signal.
  • Reference/base constraints help limit uncontrolled drift.
  • Independent evaluation remains necessary.
  • DPO uses a different, more direct preference-optimization route rather than an explicit reward-model-plus-RL loop.
  • RLVR uses automatically checkable outcomes such as exact answers or tests instead of human preference labels, and has become important in reasoning-model post-training.
  • GRPO is one policy-optimization method used in published verifiable-reward reasoning work; it is not a universal recipe for every reasoning model.

Next Lesson

Next, study the DPO-style direct preference objective and compare its chosen-versus-rejected scoring with the RLHF-style route you just traced.

References

Lesson actions

Completion is stored locally on this device.

View progress