Unit 9 of 10 · about 6 hours · measure
External evaluation and the versioned sampling, labeling and optimization loop
Preference accuracy is an internal diagnostic. The section's result is a bounded claim about a language model's external behavior, supported by controls that separate training from longer answers, sampling changes and judge preferences.
You'll be able to
- Compare untouched SFT, chosen-only SFT and DPO under matched or explicitly disclosed training and generation budgets.
- Evaluate capability, safety, calibration and diversity on held-out prompts never used for preference training or selection.
- Version a sampling, labeling, optimization and rollback loop while retaining failed runs and inconclusive results.
Covers
Read
In this order, only the parts listed
0 of 3 done
- DPO: evaluation contracts and judge validationDirect Preference Optimization
arXiv:2305.18290v3, Section 6, Tasks, Evaluation and Methods; Sections 6.3, Generalization to a new input distribution, and 6.4, Validating GPT-4 judgments with human judgments
Read the controls and evaluator comparison. Paid judge calls and the paper's model sizes are not required; use your frozen local task scorer and blinded manual review.
- Tulu 3: preference-data and recipe ablationsTulu 3, Section 5 (Preference Finetuning)
arXiv:2411.15124v5, Sections 5.2 to 5.4: Tülu 3 Preference Data (5.2.1, From Prompts to Preference Data), Key Findings of Data Ablations, and Preference Tuning Recipe and Analyses; Figure 7 and Table 18
Trace one data-source ablation and one objective comparison. Do not reproduce the model pool, proprietary annotation or distributed training. Its final recipe uses length-normalized DPO, not the original summed loss.
- CS336 supplement: after-training behavior checksCS336 Assignment 5 Supplement - Preference Data and DPO
Section 6.4, Problem
dpo_training, parts (b) to (d): preference, safety and capability comparisonReplace hosted judging with manual review and small local capability/safety subsets. In 6.4's preceding paragraph, raw chosen likelihood exceeding rejected likelihood is not implicit reward accuracy: use the reference-adjusted margin instead.
Focus on
- Freeze the evaluator from the Language-Model Evaluation section, prompt groups, parser, decoding, output budget, tie/failure policy and selection rule before training. Final prompts and labels must not enter preference collection, calibration or checkpoint selection.
- Keep an untouched SFT control and a chosen-only SFT control trained on the same audited data. Match update-token or compute budgets where possible; disclose reference-scoring, labeling, candidate generation and any mismatch rather than calling equal steps equal compute.
- Report independent task correctness, harmful compliance and benign refusal separately, probability calibration on a defined labeled task, and diversity/repetition at matched sampling settings. Every preference win rate includes both response-length distributions, item counts, tie handling and prompt-group uncertainty.
- Use development-only interventions for label noise, , data size, length/style controls and judge swaps. Archive failed/inconclusive runs, then freeze one candidate for untouched final evaluation and a clean-state repeat. A changed judge or rubric starts a new version of the loop.
Common mistakes · 3
- Selecting a checkpoint or a rubric on the final held-out scores. That set becomes development data; reserve a new untouched set for the final claim.
- Dropping invalid generations or failed attempts from the denominator. Keep them under the predeclared scoring rule and report their counts.
- Calling a small positive win-rate difference a gain without uncertainty or length/style controls. A failed control or broad interval supports a narrower or inconclusive claim.
Try it yourself
Closed-book, before checking anything
[20, 30, 40, 50, 60, 70] and baseline lengths are [30, 30, 30, 30, 30, 30]. With ties counted as half-wins and all six prompts retained, obtain win rate , candidate mean length 45 and baseline mean length 30. The token counts use one declared tokenizer; this arithmetic fixture is not model evidence. Explain why the result alone cannot establish a length-independent gain, then use the same raw-record accounting on your bounded study.Quiz yourself
Answer first, then mark it. Missed ones go to Review.
0 got · 0 missed
1.Preference accuracy rose while held-out task accuracy fell. Which result decides the claim?Answer
The external outcome and predeclared gates. Rising preference accuracy cannot override a capability or safety regression; preserve the negative result and diagnose the mechanism.
2.Why keep chosen-only SFT when you already have untouched SFT?Answer
It tests whether gains come from extra exposure to the preferred responses rather than the contrastive objective. Account for its different token and reference-scoring cost.
3.What must be versioned to roll back a labeling round?Answer
The generating and reference checkpoints, sampling config, prompt split, raw outputs/votes, rubric or judge, filters, training settings, evaluator and selected artifact. Roll back to a complete accepted manifest, not just a weight file.
Practice
- RLHF Book Chapter 8 Suggested Experiments: small DPO run and data intervention
Suggested Experiments items 1 and 4: Train a small DPO run on UltraFeedback; Change the data before changing the loss
Adapt to your audited preference subset and immutable small-decoder SFT checkpoint from the Adaptation and Distillation section: at most 1,000 pairs, context at most 256, batch 1 and at most 100 updates per trained arm. Use your GPU or the smaller CPU decoder, with precomputed frozen reference scores if needed. Pin PyTorch 2.14.1; for a TRL implementation also pin TRL 1.15.0, Transformers 5.19.0 and datasets 5.1.0. Compare at least two fixed seeds, keep the objective unchanged for the noise intervention, and state the reduced-scale limits. The section mini-project retains the baselines, held-out behavior, length/style/judge controls and rollback record.
You're done when
A clean-state repeat reconstructs your selected comparison from manifests and raw held-out outputs, and your report states whether the gain survives length, style, judge and failure controls or remains inconclusive.
Only when you can do this without notes.
Leads to
Notes
Resources · 3 for this unit, 17 more in the section
- Direct Preference OptimizationStanford University · required
Read Section 4 and Appendix A: derive the objective from the KL-constrained reward formulation, implement it from policy and reference log probabilities summed over response tokens, and gradient-check , sign, masking and identical-pair cases. TRL's
sigmoid_normvariant normalizes by length, which the paper does not. - Tulu 3, Section 5 (Preference Finetuning)Allen Institute for AI · support
Read Sections 5.2 to 5.4: building on-policy preference data, the data ablations and the DPO recipe. Use the ablations as the model for your own one-variable comparison.
- CS336 Assignment 5 Supplement - Preference Data and DPOStanford University · required
Do supplement Section 6: inspect the HH preference data (
look_at_hh) and implementdpo_lossuntil its test passes. Run a bounded DPO comparison only after the baseline and evaluator are frozen, with a small open model in place of the Llama 3.1 8B B200 run.
Also in this section
- RLHF Book - Reward Models, Direct Alignment and PreferencesNathan Lambert · primary
Read Chapter 5 (reward models), Chapter 8 (direct alignment), Chapters 10 and 11 (preferences and preference data) and Chapters 14 and 15 (over-optimization and regularization) at
rlhfbook.com/c/NN-slug.html. Only Chapters 5 and 8 have Suggested Experiments; do those. Trace preference data through reward modeling or DPO and list each distribution and evaluator assumption before training. - Training Language Models to Follow Instructions with Human Feedback (Ouyang et al., 2022)OpenAI · required
Read Sections 1 to 3: demonstrations, comparisons, the reward model and PPO with a pretraining mix, then the human-preference results. The 1.3B-beats-175B headline is a preference win rate, not capability.
- Scaling Laws for Reward Model Overoptimization (Gao et al., 2022)OpenAI · required
Read Sections 2 to 4: a gold reward model stands in for humans, and gold score against optimization pressure takes different forms for best-of-n and RL. The lesson is the shape, not a universal KL threshold.
- A Long Way to Go: Investigating Length Correlations in RLHF (Singhal et al., 2023)UT Austin · required
Read Sections 2 to 5: reward correlates with length, PPO lengthens outputs, and a length-only reward reproduces much of the gain. Report length beside every preference result.
- Disentangling Length from Quality in Direct Preference Optimization (Park et al., 2024)Stanford University · support
Read Sections 2 and 3: add a length penalty to the reward and derive length-regularized DPO, then check its length-controlled results in Section 4.
- A General Theoretical Paradigm to Understand Learning from Human Preferences (Azar et al., 2023)Google DeepMind · support
Read Sections 3 to 5: why DPO can overfit deterministic preferences and how IPO's squared loss avoids it. Its tau is DPO's beta under another name.
- SimPO: Simple Preference Optimization with a Reference-Free Reward (Meng et al., 2024)Princeton University · support
Read Section 2 (length-normalized average log probability as the reward plus a target margin, with no reference model) and Sections 4.2 and 4.3 (the length-normalization and margin ablations). Without the reference there is no KL anchor, so watch for drift.
- ORPO: Monolithic Preference Optimization without Reference Model (Hong et al., 2024)KAIST AI · support
Read Sections 3 and 4: an odds-ratio penalty added to the SFT loss in one stage. Merging the stages makes an SFT-versus-preference ablation harder, so evaluate them apart.
- KTO: Model Alignment as Prospect Theoretic Optimization (Ethayarajh et al., 2024)Stanford and Contextual AI · support
Read Section 3.2 (human-aware losses) and Section 4 (a loss for unpaired desirable and undesirable examples with a reference point). Unpaired data still needs label-noise and reference-drift checks.
- RewardBench: Evaluating Reward Models for Language Modeling (Lambert et al., 2024)Allen Institute for AI · support
Read Section 4 (the chat, chat-hard, safety and reasoning splits, detailed in Appendix F), Section 5 and Appendix H.2 (length bias). Pin the benchmark version; reward accuracy is not policy quality.
- RLAIF vs. RLHF: Scaling Reinforcement Learning from Human Feedback with AI Feedback (Lee et al., 2023)Google Research · support
Read Sections 2 to 5: AI-labeled versus human-labeled preferences on summarization and dialogue, and direct RLAIF without a distilled reward model. The parity holds for their tasks and labelers.
- RLHF Book Code - Reward Models and Direct AlignmentNathan Lambert · support
Run the preference reward model with a frozen backbone (only the head trains) and the DPO, IPO and length-normalized DPO configs with smaller models and contexts than the defaults. The final partial accumulation window is under-weighted, so fix or avoid it. Explain margins, accuracy and rewards rather than raw loss.
- TensorTonic - Preference Optimization SetTensorTonic · support
Solve Canonicalize Pairwise Preference Data (
cs336-l15-canonical-preference-pairs), Score a KL-Regularized Policy Batch (cs336-l15-kl-regularized-policy-objective) and Implement the DPO Loss (cs336-l15-direct-preference-optimization-loss). The DPO problem takes sequence log probabilities, so add your own swapped-label, duplicate, length and reference-mismatch cases. Public test cases check the listed edge cases, not gradients or the hidden grader, so keep your own tests beside each solution. - TRL DPO TrainerHugging Face · support
After the scratch loss passes, map dataset format, reference model, and loss variants into TRL 1.15.0: the default
loss_typeis["sigmoid"]withbeta=0.1, log probabilities are summed over the completion, and the trainer refuses a policy that is the same object as the reference. Confirm the library loss matches your scratch objective on one frozen batch. - Modern LLM Notebook - RLHF AlignmentWalking Labs · optional
Use
notebooks-en/part2-training/19-rlhf-alignment.ipynbas a compact end-to-end orientation. Do not substitute its overview for the RLHF Book derivations or the CS336 objective tests. - Build a Large Language Model (From Scratch) - DPO Bonus NotebookSebastian Raschka · reference
Use
ch07/04_preference-tuning-with-dpo/only as a gentle starter before the DPO paper and CS336 tests. - Constitutional AI: Harmlessness from AI FeedbackAnthropic · support
arXiv:2212.08073v1, Sections 3.1 and 4.1 and Appendix C.2: distinguish critique/revision data from constitution-conditioned comparison labels and trace the principle into label provenance. Read and audit the examples; no large-model RL reproduction is required.