AI system design

Preference learning: RLHF and DPO

By Anup RaiReviewed

Reinforcement learning from human feedback (RLHF) uses human feedback to guide a model through reinforcement learning. A common language-model recipe trains a reward model from human preferences and then optimizes a policy against that reward. Direct Preference Optimization (DPO) instead trains the policy directly on chosen/rejected response pairs using a preference objective relative to a reference policy.

Both methods learn from the behavior represented in the feedback. Define the outcome the product needs, such as answering from supplied evidence and abstaining when evidence is missing. Measure that outcome independently from the feedback score, and include checks for factual accuracy and safety.

1. Define the desired behavior

Consider a support assistant that confidently invents refund exceptions. The target is not “sound friendlier.” It is to answer supported questions accurately and abstain when the supplied policy is insufficient. Reviewers need a rubric that prefers grounded answers over fluent inventions.

  1. Specify which responses count as correct, unsupported, unsafe, or unhelpfully refused.
  2. Collect representative prompts, including ambiguous and adversarial cases.
  3. Obtain preference labels using that rubric; allow ties and disagreements.
  4. Keep a held-out evaluation that measures business behavior, not only a learned reward score.
  5. Compare against a prompting and supervised fine-tuning baseline.

2. Trace a common RLHF pipeline

Architecture / visual model
flowchart LR A[Instruction examples] --> B[Supervised policy] B --> C[Sample responses] C --> D[Human comparisons] D --> E[Train reward model] E --> F[RL policy optimization] F --> G[Independent evaluation]
Read diagram source
flowchart LR
  A[Instruction examples] --> B[Supervised policy]
  B --> C[Sample responses]
  C --> D[Human comparisons]
  D --> E[Train reward model]
  E --> F[RL policy optimization]
  F --> G[Independent evaluation]

In the refund example, reviewers prefer a response that cites the policy over a plausible promise of a refund. The team uses many such comparisons to train a reward model to give preferred responses higher scores. The policy is the language model that generates the responses. During reinforcement learning, the policy samples fresh responses and the reward model scores them. An optimizer such as Proximal Policy Optimization (PPO) uses the scores to adjust the policy's token probabilities. A learned value estimate can help judge whether a sample did better than expected. That estimate takes extra training and memory.

A team can also keep a frozen copy of the starting policy as a reference policy. A penalty for moving far from that copy discourages the generator from chasing high scores at the expense of its other behavior. The reward model supplies the score and the reference supplies the comparison probabilities. Different algorithms need different components. The InstructGPT paper documents one implementation.

A policy may learn to exploit reward-model errors. For example, a judge that rewards length may prefer a long, unsupported refund explanation. Track independent correctness, refusal quality, response length, and human evaluation alongside reward.

3. What DPO changes

For each prompt, Direct Preference Optimization (DPO) trains from a labeled pair of responses. Return to the refund question. The reviewer chose the response that cites the policy and rejected the response that promises a refund without evidence.

  1. The trainer scores both saved responses with the model being trained and with a frozen reference model. To score a response, each model measures the probability of its tokens in order given the prompt and the preceding tokens. Implementations add token log-probabilities to score a whole response.
  2. Suppose the reference gives the chosen and rejected responses probabilities of 0.30 and 0.20. Its chosen-to-rejected ratio is 1.5. Suppose the training model assigns 0.45 and 0.25. Its ratio is 1.8. The training model favors the chosen response more strongly than the reference does.
  3. The DPO loss rewards a larger gap in log-probability between the chosen and rejected responses relative to the reference gap. In this toy comparison, both absolute probabilities rose, yet the preference still strengthened.

Offline DPO can repeat these steps over stored pairs without a separate reward model or fresh generation during each update. It still depends on label quality and on whether the stored pairs cover the errors the deployed model makes. DPO paper.

Choice What it buys What it costs or misses
SFT on desired answers A direct target behavior to imitate Does not directly learn the chosen/rejected comparison
Offline DPO A comparatively simple training loop over preference pairs Static data may poorly represent the policy's current mistakes
Reward-model RL Optimizes responses sampled from the evolving policy More components, rollout cost, and reward-model exploitation risk
Online preference training Refreshes comparisons near current behavior Repeated generation, judging, labeling, and quality control

4. Online feedback and verifiable rewards

“Online” means training data or feedback is refreshed from the evolving policy. It does not mean a production chatbot should update weights after every customer message. Keep model versions, evaluation gates, and rollback decisions explicit.

REINFORCE Leave-One-Out (RLOO) samples several responses to the same prompt. To judge how well one sample did, it subtracts the average reward of the other samples from that sample's reward. With rewards 1, 1, and 0, the last sample gets 0 − (1 + 1)/2 = −1. RLOO uses this difference to weight the update for that sample. DPO instead uses labeled chosen and rejected pairs. A judge model can supply preference labels, but measure its errors against human-reviewed decisions. RLOO study.

For code or mathematics, a verifier may score the outcome directly. RLVR can use passing tests or a checked answer as reward. This does not imply that reasoning models necessarily reward their intermediate reasoning rather than their final answer. Outcome supervision and process supervision are distinct choices.

5. Work through the failure and repair

Suppose 1,000 held-out support prompts produce these illustrative results:

Model Supported correct answers Unsupported answers Excessive refusals
Baseline 850 100 50
Candidate 870 30 100

The candidate gives 70 fewer unsupported answers and 50 more unnecessary refusals. Compare both counts with the release criteria. Break the results down by task, language, and policy ambiguity to find which users are affected. Inspect label disagreements, revise the training data if needed, and use a protected evaluation to check the revised candidate.

An alignment tax is a reduction in some capabilities associated with behavioral adaptation. It is an observed tradeoff to measure, not an inevitable fixed penalty. A smaller update, broader training coverage, and better rubrics may help, but none replaces testing.

Interview practice

  1. How does DPO differ from SFT? SFT imitates target responses. DPO learns a preference comparison between chosen and rejected responses relative to a reference.
  2. Why not use the reward score as the launch criterion? The policy is trained to optimize it and may exploit it. Use independent measures of the desired behavior.
  3. What makes a useful preference pair? A clear difference under a stated rubric, relevant prompts, and consistent context—not merely one longer answer.
  4. Does DPO remove all alignment complexity? It simplifies the optimization pipeline; it does not fix poor feedback, distribution shift, or missing safety evaluation.
  5. When would online data help? When the improving policy produces failure modes poorly covered by the static pair set, provided the extra collection cost is justified.
  6. Do passing code tests prove faithful reasoning? No. Tests check selected observable outcomes. They may be incomplete and do not establish every intermediate claim.

Recall card and closing

The rubric defines which response reviewers prefer. The objective turns those preferences into training updates. An independent evaluation checks whether those updates improve the behavior users need. The application still enforces access and validates actions after the model is trained. Authorization, Guardrails.

Your notes

Write the decision you would make and the uncertainty you would investigate next. Saved only in this browser.

Explore the diagram