Overview

8 Preference optimization: Teaching your model to judge

Preference optimization fills the gap left by supervised fine-tuning: instead of showing the model only good examples, it teaches the model to prefer one answer over another when both are plausible. That matters when quality is subjective, such as style, helpfulness, conciseness, or safety boundaries, because SFT tends to converge on an average behavior and cannot distinguish between merely correct and clearly better responses. The chapter positions preference tuning as the natural next step after SFT, while also warning that alignment work can introduce forgetting or safety regressions, so every new stage must be evaluated carefully.

The hands-on workflow centers on Direct Preference Optimization, which trains on prompt-level pairs labeled as chosen and rejected. The chapter shows how to reformat real human-graded support answers into the expected schema, then train a DPO model from the previous SFT checkpoint using TRL’s trainer. DPO is presented as practical because it removes the need for a separate reward model and reinforcement-learning loop, while still using a frozen reference model to constrain drift. Training is relatively lightweight, but the chapter emphasizes that good preference data, sensible hyperparameters, and enough GPU memory are essential for stable results.

Evaluation shows the key lesson: DPO does not necessarily improve objective correctness on factual help-desk tasks, but it can improve the subjective qualities that Token-F1 cannot see. In the example run, the DPO model roughly matched the SFT model on held-out correctness while learning the preferred style more clearly in a separate conciseness test. The chapter then broadens the view by comparing DPO with GRPO, RLHF, and RFT, explaining that GRPO and RFT are best when rewards are verifiable, RLHF is powerful but expensive and complex, and DPO is the default choice for most enterprise preference tuning. The final guidance is to choose the simplest method that matches the task, measure the right axis, and always rerun safety checks before shipping.

The progressive adaptation pipeline: each chapter’s output is the next chapter’s starting checkpoint.
DPO training dashboard: loss falls while reward margin and held-out reward accuracy rise.
The DPO training mechanism: raise the chosen response, lower the rejected one, stay near the frozen reference.
Per-category Token-F1 for the base, SFT, and DPO models: DPO and SFT track each other on every category.
One GRPO training step: sample a group of G responses, score them, normalize within the group, update toward the above-average ones.
RLHF’s three stages and four models versus DPO’s single supervised step.
The RFT loop: a rule-based verifier scores each output, and the policy is reinforced toward verified-correct answers.
Choosing among DPO, GRPO, RLHF, and RFT, entered only after the SFT-data-quality gate.

Summary

  • SFT teaches a model what to output, while preference optimization teaches it to distinguish good responses from better ones.
  • DPO collapses RLHF’s three-model pipeline into a single supervised training step on preference pairs, eliminating the need for a separate reward model.
  • Preference data can come from human-graded pairs, as in this chapter’s run, or be generated automatically by contrasting a stronger model’s outputs against a weaker one’s at near-zero annotation cost.
  • DPO does not move objective correctness (Token-F1 was flat on the IT eval, 0.168 to 0.166); it earns its place on subjective dimensions, where a conciseness-tuned DPO model produced answers 21% shorter, which a blinded judge preferred 61% of the time, while correctness held.
  • The beta parameter (default 0.1) controls how closely DPO stays to the reference policy; values below 0.05 risk mode collapse, and values above 0.3 produce minimal change.
  • GRPO eliminates PPO’s critic network by normalizing rewards within a group of sampled responses and excels when verifiable reward functions are available.
  • RLHF remains the most capable alignment technique, but DPO achieves 80 to 90% of its benefit at roughly one-tenth the cost.
  • Reinforcement fine-tuning with verifiable rewards replaces human preferences with code-based reward functions and is most applicable to domains like code generation, math, and structured extraction.
  • The DeepSeek-R1 cold-start pattern combines light SFT for output format with large-scale GRPO for reasoning incentive, producing emergent self-verification behaviors.
  • Known DPO failure modes include length and verboseness bias and likelihood displacement, both of which require monitoring after deployment.
  • Safety regression testing must follow every preference optimization step because optimizing for helpfulness can erode refusal boundaries.
  • Most enterprises (roughly 95%) need only DPO or better training data; reserve GRPO, RFT, RLHF, and frontier SFT+RL for specialized requirements.

FAQ

1. What problem does preference optimization solve that supervised fine-tuning (SFT) cannot?SFT teaches a model what to output by showing only correct examples, but it cannot distinguish between two responses that are both correct yet differ in helpfulness, style, structure, or detail. Preference optimization fills that gap by training on chosen/rejected pairs so the model learns which response is better.
2. What is Direct Preference Optimization (DPO) in simple terms?DPO is a post-SFT training method that learns from preference pairs: a prompt, a chosen response, and a rejected response. It increases the likelihood of the chosen response and decreases the likelihood of the rejected one, while keeping the model close to a frozen reference checkpoint.
3. Why does the chapter recommend starting from an SFT checkpoint before DPO?DPO is meant to refine an already capable model, not teach basic task behavior from scratch. Starting from SFT gives the model a strong baseline, and DPO then nudges it toward better style, helpfulness, and safety boundaries without disturbing what it already knows.
4. What kinds of preference data can be used for DPO?The chapter describes four main sources: model-model pairs, human-model pairs, log-derived pairs, and judge-model pairs. For the hands-on run, it uses real human-graded Stack Exchange answer pairs, where the better community answer is labeled chosen and the weaker one rejected.
5. Why does the chapter say DPO is often cheaper and simpler than RLHF?RLHF usually needs three stages: collect preference annotations, train a reward model, and then run PPO with a reference and value network. DPO removes the reward model and RL loop, so it is much simpler to implement, cheaper to run, and easier for enterprise teams to adopt.
6. Which hyperparameters matter most in the chapter’s DPO run?The chapter highlights a low learning rate, beta, one epoch, and gradient checkpointing. Beta controls how tightly the model stays near the frozen reference, the learning rate should be small to avoid drifting too far, and one epoch is usually enough for a small preference dataset.
7. How should you interpret DPO training metrics like reward accuracy and reward margin?Reward accuracy tells you how often the model scores the chosen response above the rejected one, and reward margin tells you how much higher that score is. Held-out values matter more than training values, and small positive margins on real human data are a healthy sign that the model learned a genuine preference signal.
8. Why didn’t DPO improve Token-F1 much in the chapter’s evaluation?Token-F1 measures lexical overlap with a reference answer, so it is good for objective correctness but blind to subjective improvements like conciseness, tone, or formatting. DPO changed those subjective dimensions more than it changed factual overlap, so Token-F1 barely moved even though the model learned useful preferences.
9. When does DPO add the most value, and when should you consider alternatives like GRPO, RLHF, or RFT?DPO is best for subjective preference tuning such as style, helpfulness calibration, and safety boundary refinement. GRPO or RFT are better when the task has verifiable rewards like code, math, or structured extraction, while RLHF is mainly for more complex preference generalization but is much more expensive and operationally heavy.
10. What safety issue should you check after DPO training?You should rerun the safety regression suite after preference tuning to make sure the model did not become less willing to refuse harmful prompts or less careful on uncertain prompts. The chapter emphasizes that any safety regression is a blocker, and for safety-critical domains it recommends dual-objective optimization or safety-specific preference data.

pro $24.99 per month

  • access to all Manning books, MEAPs, liveVideos, liveProjects, and audiobooks!
  • choose one free eBook per month to keep
  • exclusive 50% discount on all purchases
  • renews monthly, pause or cancel renewal anytime

lite $19.99 per month

  • access to all Manning books, including MEAPs!

team

5, 10 or 20 seats+ for your team - learn more


choose your plan

team

monthly
annual
$49.99
$499.99
only $41.67 per month
  • five seats for your team
  • access to all Manning books, MEAPs, liveVideos, liveProjects, and audiobooks!
  • choose another free product every time you renew
  • choose twelve free products per year
  • exclusive 50% discount on all purchases
  • renews monthly, pause or cancel renewal anytime
  • renews annually, pause or cancel renewal anytime
  • LLM Customization and Fine-Tuning ebook for free
choose your plan

team

monthly
annual
$49.99
$499.99
only $41.67 per month
  • five seats for your team
  • access to all Manning books, MEAPs, liveVideos, liveProjects, and audiobooks!
  • choose another free product every time you renew
  • choose twelve free products per year
  • exclusive 50% discount on all purchases
  • renews monthly, pause or cancel renewal anytime
  • renews annually, pause or cancel renewal anytime
  • LLM Customization and Fine-Tuning ebook for free