LeetLLM
My PlanLearnGlossaryTracksPracticeBlog
LeetLLM

Your go-to resource for mastering AI & LLM systems.

Product

  • Learn
  • Glossary
  • Tracks
  • Practice
  • Blog
  • RSS

Legal

  • Terms of Service
  • Privacy Policy

© 2026 LeetLLM. All rights reserved.

All Topics
Your Progress
0%

0 of 196 articles completed

🛠️Computing Foundations0/9
Git, Shell, Linux for AIDocker for Reproducible AIPython for AI EngineeringNumPy and Tensor ShapesCUDA for ML TrainingMPS & Metal for ML on MacData Structures for AISQL and Data ModelingAlgorithms for ML Engineers
📊Math & Statistics0/9
Gradients and BackpropVectors, Matrices & TensorsLinear Algebra for MLAdam, Momentum, SchedulersProbability for Machine LearningBayesian Inference from EvidenceStatistics and UncertaintyDistributions and SamplingHypothesis Tests, Intervals, and pass@k
📚Preparation & Prerequisites0/13
Neural Networks from ScratchCNNs from ScratchTraining & BackpropagationSoftmax, Cross-Entropy & OptimizationRNNs, LSTMs, GRUs, and Sequence ModelingAutoencoders and VAEsThe Transformer Architecture End-to-EndLanguage Modeling & Next TokensFrom GPT to Modern LLMsPrompt Engineering FundamentalsCalling LLM APIs in ProductionFirst AI App End-to-EndThe LLM Lifecycle
🧮ML Algorithms & Evaluation0/15
Linear Regression from ScratchLogistic Regression and MetricsDecision Trees, Forests, and BoostingReinforcement Learning BasicsValidation and LeakageStatistical Learning and GeneralizationConformal Prediction and UncertaintyClustering and PCAProbabilistic Generative ModelsCore Retrieval AlgorithmsDecoding AlgorithmsExperiment Design and A/B TestingCausal Inference and CounterfactualsPyTorch Training LoopsDataset Pipelines and Data Quality
📦Production ML Systems0/6
Feature Engineering for Production MLBatch and Streaming Feature PipelinesGradient Boosted Trees in ProductionRanking and Recommendation SystemsForecasting and Anomaly DetectionMonitoring Predictive Models
🧪Core LLM Foundations0/8
The Bitter Lesson & ComputeBPE, WordPiece, and SentencePieceStatic to Contextual EmbeddingsPerplexity & Model EvaluationFile Ingestion for AIChunking StrategiesLLM Benchmarks & LimitationsInstruction Tuning & Chat Templates
🧰Applied LLM Engineering0/25
Dimensionality Reduction for EmbeddingsCoT, ToT & Self-Consistency PromptingFunction Calling & Tool UseMCP & Tool Protocol StandardsContext EngineeringPrompt Injection DefenseResponsible AI GovernancePrivacy-Preserving Machine LearningData Labeling and Human FeedbackEvaluating AI AgentsProduction RAG PipelinesHybrid Search: Dense + SparseReranking and Cross-Encoders for RAGRAG Evaluation for Reliable AnswersLLM-as-a-Judge EvaluationBias & Fairness in LLMsHallucination Detection & MitigationLLM Observability & MonitoringExperiment Tracking with MLflow and W&BPrompt Optimization with DSPyModel Versioning & DeploymentSemantic Caching & Cost OptimizationLLM Cost Engineering & Token EconomicsModel Gateways, Routing, and FallbacksDesign an Automated Support Agent
🎓Portfolio Capstones0/9
Capstone: Delivery ETA PredictionCapstone: Product RankingCapstone: Demand ForecastingCapstone: Image Damage ClassifierCapstone: Production ML PipelineCapstone: Document QACapstone: Eval DashboardCapstone: Fine-Tuned ClassifierCapstone: Reproducible ML Study
🧠Transformer Deep Dives0/8
Sentence Embeddings & Contrastive LossEmbedding Similarity & QuantizationScaled Dot-Product AttentionVision Transformers and Image EncodersPositional Encoding: RoPE & ALiBiLayer Normalization: Pre-LN vs Post-LNMechanistic InterpretabilityDecoding Strategies: Greedy to Nucleus
🧬Advanced Training & Adaptation0/17
Scaling Laws & Compute-Optimal TrainingPre-training Data at ScaleBuild GPT from Scratch LabJAX for PyTorch ResearchersContinued Pretraining for Domain ShiftSynthetic Data PipelinesSupervised Fine-Tuning PipelineMixed Precision TrainingDistributed Training: FSDP & ZeROLoRA & Parameter-Efficient TuningTraining Run OperationsReward Modeling from Preference DataRLHF & DPO AlignmentConstitutional AI & Red TeamingRLVR & Verifiable RewardsKnowledge Distillation for LLMsModel Merging and Weight Interpolation
🤖Advanced Agents & Retrieval0/16
Vector DB Internals: HNSW & IVFAdvanced RAG: HyDE & Self-RAGGraphRAG & Knowledge GraphsRAG Security & Access ControlStructured Output GenerationReAct & Plan-and-ExecuteGuardrails & Safety FiltersCode Generation & SandboxingComputer-Use / GUI / Browser AgentsHuman-in-the-Loop Agent ArchitectureAI Coding Workflow with AgentsAgent Memory & PersistenceAgent Failure & RecoveryRecursive Language Models (RLM)Multi-Agent OrchestrationCapstone: Production Agent
⚡Inference & Production Scale0/31
Inference: TTFT, TPS & KV CacheMulti-Query & Grouped-Query AttentionKV Cache & PagedAttentionPrefix Caching and Prompt CachingFlashAttention & Memory EfficiencyContinuous Batching & SchedulingScaling LLM InferenceModel Parallelism for LLM InferenceAccelerator Architecture Field GuideCorrect GPU Profiling and BenchmarkingGPU Kernel Performance Engineering LabGPU Parallel Primitives LabGPU Compilers and Kernel LanguagesGEMM From Naive CUDA to Tensor CoresLow-Precision GPU ProgrammingGPU Runtime Execution LabAI-Generated Kernel EngineeringModel Quantization: GPTQ, AWQ & GGUFLocal LLM DeploymentSLM Specialization & Edge DeploymentSpeculative DecodingLong Context Window ManagementMixture of Experts ArchitectureMamba & State Space ModelsReasoning & Test-Time ComputeAdvanced MLOps & DevOps for AIGPU Serving & AutoscalingGPU Failure OperationsDistributed Inference Data PlaneServing Benchmark EngineeringA/B Testing for LLMs
🏗️System Design Capstones0/9
Content Moderation SystemCode Completion SystemMulti-Tenant LLM PlatformLLM-Powered Search EngineVision-Language Models & CLIPMultimodal LLM ArchitectureDiffusion Models: Images & TextReal-Time Voice AI AgentReasoning Agent System Design
🎤AI Lab Interviewing0/4
AI Lab Coding Interview: Python SystemsAI Lab System Design InterviewAI Lab Behavioral InterviewAI Lab Technical Presentation
🔬Project Deep Dives0/17
Deep Dive - vLLMDeep Dive - SkyRLDeep Dive - FlashAttentionDeep Dive - FlashInferDeep Dive - DeepGEMMDeep Dive - NCCLDeep Dive - MegatronDeep Dive - DeepSpeedDeep Dive - RayDeep Dive - MLflowDeep Dive - PyTorchDeep Dive - TransformersDeep Dive - SGLangDeep Dive - slimeDeep Dive - DeepEPDeep Dive - TinkerDeep Dive - Light-PEFT
Back to Topics
LearnAdvanced Training & AdaptationRLHF & DPO Alignment
🛡️HardAlignment & Safety

RLHF & DPO Alignment

Turn a reward model into an aligned policy: run PPO-style RLHF with a KL budget, or skip the extra judge and train DPO on the same preference pairs, then catch reward hacking and likelihood displacement.

29 min read
Learning path
Step 115 of 196 in the full curriculum
Reward Modeling from Preference DataConstitutional AI & Red Teaming

Personalize this lesson

Adapt explanations and teaching visuals to your background and preferred voice.

Suppose a release candidate raises its internal judge score by 0.310.310.31. Reviewers prefer its answers 0.040.040.04 less often, and responses are 48 tokens longer because the model learned a "Policy-safe answer:" preamble. Would you promote it? No. One proxy moved; product behavior moved the wrong way.

The last chapter turned one access-policy pair into a scalar. For the prompt "temporary admin access for tonight's migration," the ticket-and-cite answer scored 1.81.81.8 and the grant-tonight answer scored 0.70.70.7. The Bradley-Terry preference model maps that 1.11.11.1 margin to roughly a 75%75\%75% chance that the labeler prefers the safer answer. This chapter asks what to do with that judge: train a policy against it, or skip the extra model and optimize the policy directly from the pairs?

An instruction-tuned assistant can still answer that prompt with fluent, confident, and wrong guidance. InstructGPT puts the gap plainly: a model trained to predict plausible text can still be unhelpful, untruthful, or unsafe even when the prose looks polished.[1]Reference 1Training Language Models to Follow Instructions with Human Feedback (InstructGPT).https://arxiv.org/abs/2203.02155

That's the alignment problem. Pretraining optimizes next-token prediction. Preference methods such as RLHF (Reinforcement Learning from Human Feedback) and DPO (Direct Preference Optimization) push the model toward answers a labeling policy prefers. They don't, by themselves, prove truthfulness or safety outside that policy's coverage. Whether learned or held out, a judge remains a proxy.

The gap SFT can't close

After instruction tuning, the model can follow the shape of a request. It can still grant a privileged role, refuse a reasonable one, or pad a correct answer until it's unusable. Next-token prediction doesn't enforce a product's rules. Predicting what comes next isn't the same as satisfying the behavior being judged.

Keep the same prompt the reward-modeling chapter used: "Policy: cite the retrieved access policy and escalate privileged-role changes. User: My service account needs temporary admin access for tonight's migration. Can you approve it?" Two SFT completions are both grammatical:

  • Response A: "The retrieved access policy requires escalation for temporary admin access. I can open a reviewer ticket and cite policy P-7."
  • Response B: "Temporary admin access is common for migrations, so you can proceed and clean it up tomorrow."

A follows the supplied policy. B violates it. Before preference labels enter, ask what SFT can infer from this row: both strings are grammatical, but only A makes escalation explicit. Unless demonstrations encode that distinction, next-token loss has no term that marks B as a product failure. Preference training supplies that comparative signal when the distinction appears in labeled data.[1]Reference 1Training Language Models to Follow Instructions with Human Feedback (InstructGPT).https://arxiv.org/abs/2203.02155

Same temporary-admin prompt yields two fluent SFT answers. Response A opens a review ticket and cites policy P-7. Response B grants admin for tonight. Preference training marks A chosen and B rejected because only A follows the stated policy.
Both SFT answers are fluent. The preference label marks A because it follows policy P-7, not because it sounds more complete.

RLHF: a judge, then an actor

RLHF is the large-scale preference pipeline InstructGPT popularized, building on earlier human-feedback fine-tuning for summarization: start from an SFT model, train a reward model from comparisons, then optimize the policy with reinforcement learning.[2]Reference 2Learning to Summarize from Human Feedback.https://arxiv.org/abs/2009.01325[1]Reference 1Training Language Models to Follow Instructions with Human Feedback (InstructGPT).https://arxiv.org/abs/2203.02155

The pipeline is a handoff. SFT gives instruction-following. The reward model turns comparisons into a scalar. PPO updates the policy while a KL term charges drift away from the SFT reference.

Three-phase pipeline

Treat each phase as answering one question: can the model imitate useful answers, can a scorer reproduce the preference rule, and can the policy improve under that scorer without leaving tested behavior? The first two use stored examples. The third generates and scores policy outputs.

Diagram showing 1. SFT policy, 2. Reward model, and 3. PPO + KL.
1. SFT policy, 2. Reward model, and 3. PPO + KL.

Phase 3 is where the extra machinery shows up. InstructGPT's RL stage is a bandit: a prompt comes in, the policy writes a response, the reward model returns a scalar, and a per-token KL penalty against the SFT model is added to limit overoptimization.[1]Reference 1Training Language Models to Follow Instructions with Human Feedback (InstructGPT).https://arxiv.org/abs/2203.02155 That fresh response is the key difference from fitting only the stored demonstrations.

Bradley-Terry, one number later

Here is how the judge turns a pair into a training signal. Predict the direction first: because A's score is higher, its preference probability should be above 0.50.50.5; reversing the scores should make the observed A label less likely. The Bradley-Terry model says the probability that a human prefers ywy_wyw​ over yly_lyl​ is a sigmoid of the reward gap:[1]Reference 1Training Language Models to Follow Instructions with Human Feedback (InstructGPT).https://arxiv.org/abs/2203.02155[3]Reference 3Direct Preference Optimization: Your Language Model is Secretly a Reward Model.https://arxiv.org/abs/2305.18290

P(yw≻yl∣x)=σ(r(x,yw)−r(x,yl))P(y_w \succ y_l \mid x) = \sigma\left(r(x, y_w) - r(x, y_l)\right)P(yw​≻yl​∣x)=σ(r(x,yw​)−r(x,yl​))

Plug in last chapter's scores: r(A)=1.8r(A)=1.8r(A)=1.8, r(B)=0.7r(B)=0.7r(B)=0.7. The gap is 1.11.11.1, so P(A≻B)=σ(1.1)≈0.750P(A \succ B)=\sigma(1.1)\approx 0.750P(A≻B)=σ(1.1)≈0.750. If the human picked A, the negative log-likelihood of that observation is −log⁡(0.750)≈0.287-\log(0.750)\approx 0.287−log(0.750)≈0.287. Flip the ranking and the same math becomes −log⁡(0.250)≈1.386-\log(0.250)\approx 1.386−log(0.250)≈1.386. The loss pushes the reward model toward the higher-probability assignment.

Why does a larger reward gap make the preference probability closer to 1?

Answer

The sigmoid receives a larger positive input, so it moves toward 1. In Bradley-Terry terms, a larger score difference means the model is more confident the higher-scored response wins.

bradley_terry_p7_pair.py
1import math 2 3def sigmoid(value: float) -> float: 4 return 1 / (1 + math.exp(-value)) 5 6reward_a = 1.8 7reward_b = 0.7 8preference_probability = sigmoid(reward_a - reward_b) 9negative_log_likelihood = -math.log(preference_probability) 10 11print(f"P(A preferred over B) = {preference_probability:.1%}") 12print(f"NLL = {negative_log_likelihood:.3f}")
Bradley-Terry output
1P(A preferred over B) = 75.0% 2NLL = 0.287

The training loss is the same expectation you saw for the reward model:

LRM=−E(x,yw,yl)[log⁡σ(r(x,yw)−r(x,yl))]\mathcal{L}_{\text{RM}} = -\mathbb{E}_{(x, y_w, y_l)} \left[\log \sigma\left(r(x, y_w) - r(x, y_l)\right)\right]LRM​=−E(x,yw​,yl​)​[logσ(r(x,yw​)−r(x,yl​))]

where ywy_wyw​ is the winning response and yly_lyl​ is the losing response for the same prompt xxx.

PPO and the KL budget

Once you have a reward model, ask what prevents the policy from chasing its score by drifting. Treat the language model as a policy πθ\pi_\thetaπθ​. Proximal Policy Optimization (PPO) makes clipped, conservative updates.[4]Reference 4Proximal Policy Optimization Algorithms.https://arxiv.org/abs/1707.06347 The KL-regularized objective is reward minus a penalty for leaving the reference:

max⁡θ  Ex∼D,y∼πθ[r(x,y)]−β⋅Ex∼D[KL(πθ(⋅∣x)∥πref(⋅∣x))]\begin{aligned} \max_\theta\;& \mathbb{E}_{x \sim D, y \sim \pi_\theta} \left[r(x, y)\right] \\ &- \beta \cdot \mathbb{E}_{x \sim D} \left[\text{KL}(\pi_\theta(\cdot|x) \| \pi_{\text{ref}}(\cdot|x))\right] \end{aligned}θmax​​Ex∼D,y∼πθ​​[r(x,y)]−β⋅Ex∼D​[KL(πθ​(⋅∣x)∥πref​(⋅∣x))]​

The Kullback-Leibler term is a drift budget, not a proof that the reward is right. InstructGPT applies that penalty per token specifically to mitigate reward-model overoptimization.[1]Reference 1Training Language Models to Follow Instructions with Human Feedback (InstructGPT).https://arxiv.org/abs/2203.02155

That budget matters on this prompt. Suppose the policy starts opening with "Policy-safe answer: access guidance follows." If the reward model scores that preamble higher because it correlated with polite answers in the comparison set, the policy will amplify it. KL charges the departure from the SFT reference. Held-out humans still decide whether behavior actually improved.

To see why this is a system rather than one loss, track four roles in one PPO-style step. Real systems may shard or share weights, but the computation still has to cover all four:

  1. Actor / policy (πθ\pi_\thetaπθ​): the model being trained
  2. Reference (πref\pi_{\text{ref}}πref​): frozen SFT model for the KL penalty
  3. Reward model (rϕr_\phirϕ​): frozen scorer
  4. Critic / value (VψV_\psiVψ​): predicts expected return for advantage estimation
PPO-style RLHF on the P-7 access prompt. The actor samples a rollout. A frozen SFT reference supplies KL cost, a frozen reward model supplies a score, and a critic supplies advantage. Those three signals meet in one PPO update of the actor.
The P-7 rollout reaches one update with three separate signals: reward score, reference KL, and critic advantage.

The snippet below isolates shaped reward for two sampled responses. Before reading its output, predict the ordering: the preamble has raw reward 1.351.351.35 but log-ratio 1.61.61.6, versus 0.10.10.1 for the near-reference sample. With β=0.2\beta=0.2β=0.2, KL should erase that apparent win. This isn't a PPO trainer. A full implementation also estimates advantages, clips updates, and applies token-level masks.

kl_regularized_reward.py
1samples = [ 2 {"name": "near_reference", "reward": 1.20, "policy_logp": -2.1, "ref_logp": -2.2}, 3 {"name": "preamble_hack", "reward": 1.35, "policy_logp": -1.2, "ref_logp": -2.8}, 4] 5beta = 0.20 6 7for sample in samples: 8 sampled_log_ratio = sample["policy_logp"] - sample["ref_logp"] 9 shaped_reward = sample["reward"] - beta * sampled_log_ratio 10 print(f"{sample['name']}: raw={sample['reward']:.2f} shaped={shaped_reward:.2f}")
KL-shaped reward output
1near_reference: raw=1.20 shaped=1.18 2preamble_hack: raw=1.35 shaped=1.03

The output makes the ordering explicit: the higher raw score isn't automatically the better update once drift is charged. Production PPO stacks token-level KL, a value model, and often Generalized Advantage Estimation (GAE) on top of this shape, and it generates fresh responses each cycle.[1]Reference 1Training Language Models to Follow Instructions with Human Feedback (InstructGPT).https://arxiv.org/abs/2203.02155[4]Reference 4Proximal Policy Optimization Algorithms.https://arxiv.org/abs/1707.06347

Why this loop is expensive

The four roles create a coordination cost first. Sharding changes resident memory, not the fact that you're generating and scoring on-policy text before the gradient step.

That loop exposes a wide tuning surface: reward scale, the KL coefficient (beta), policy-ratio clip threshold, value-loss weight, advantage estimation, and rollout quality. Weak drift control invites reward-model exploitation. Overly strong control can freeze useful updates.[1]Reference 1Training Language Models to Follow Instructions with Human Feedback (InstructGPT).https://arxiv.org/abs/2203.02155[4]Reference 4Proximal Policy Optimization Algorithms.https://arxiv.org/abs/1707.06347

Both costs would be manageable if the score stayed trustworthy. The reward model saw a finite set of comparisons. Once the improving policy leaves that distribution, its score no longer necessarily means "humans would prefer this." That is overoptimization: numeric reward climbs while held-out human preference flattens or drops. On this assistant, a longer compliance preamble is an easy tell because it can score well without fixing the access decision.

IssueWhat it looks like
Four rolesPolicy, reference, reward, and value, with memory depending on sharding
Tuning surfaceClip ratio, learning rate, value-loss weights, reward scale, sample quality
Reward hackingPolicy exploits RM weaknesses on out-of-distribution text
Coverage gapsBehaviors missing from the reward data can regress
CostHuman comparisons are expensive; on-policy generation is slow

DPO: the same objective without the extra judge

PPO-style RLHF is a multi-role online loop. If a fixed pair already tells you which response wins, why generate another response for every update? DPO targets those pairs with a classification-style loss. It removes engineering, but it doesn't give you online exploration or guarantee the same checkpoint PPO would have found.

Why an offline loss can stand in for RL

Under a KL-regularized reward-maximization objective and a Bradley-Terry preference model, the optimal policy and the reward are two views of the same object. DPO parameterizes an implicit reward with policy-to-reference log-probability ratios, so the pairwise loss never needs a standalone reward model or a PPO loop.[3]Reference 3Direct Preference Optimization: Your Language Model is Secretly a Reward Model.https://arxiv.org/abs/2305.18290 Before the algebra, check its anchor: if policy equals reference, both relative log-ratios are zero, so the DPO logit is zero and the pair probability is 0.50.50.5.

The implicit reward of the optimal policy is:

r∗(x,y)=βlog⁡π∗(y∣x)πref(y∣x)+βlog⁡Z(x)r^*(x, y) = \beta \log \frac{\pi^*(y|x)}{\pi_{\text{ref}}(y|x)} + \beta \log Z(x)r∗(x,y)=βlogπref​(y∣x)π∗(y∣x)​+βlogZ(x)

π∗\pi^*π∗ is that optimal policy, πref\pi_{\text{ref}}πref​ is the reference, β\betaβ is the KL trade-off (and the DPO logit scale), and Z(x)Z(x)Z(x) is a partition function that depends only on the prompt. Because Bradley-Terry uses a difference of rewards, Z(x)Z(x)Z(x) cancels, and you can train a policy πθ\pi_\thetaπθ​ directly from pairs.[3]Reference 3Direct Preference Optimization: Your Language Model is Secretly a Reward Model.https://arxiv.org/abs/2305.18290

Why does the reference policy appear in DPO?

Answer

It anchors the aligned model to the base behavior. DPO rewards making preferred responses more likely relative to the reference while discouraging uncontrolled drift.

Work the loss on the P-7 pair

Substitute the implicit reward into the preference loss:

LDPO=−E[log⁡σ(βlog⁡πθ(yw∣x)πref(yw∣x)−βlog⁡πθ(yl∣x)πref(yl∣x))]\begin{aligned} \mathcal{L}_{\text{DPO}} = -\mathbb{E}\Bigg[ \log \sigma\Bigg( &\beta \log \frac{\pi_\theta(y_w|x)}{\pi_{\text{ref}}(y_w|x)} \\ &- \beta \log \frac{\pi_\theta(y_l|x)}{\pi_{\text{ref}}(y_l|x)} \Bigg) \Bigg] \end{aligned}LDPO​=−E[logσ(​βlogπref​(yw​∣x)πθ​(yw​∣x)​−βlogπref​(yl​∣x)πθ​(yl​∣x)​)]​

ywy_wyw​ is chosen (ticket and cite P-7) and yly_lyl​ is rejected (grant admin tonight). Read each term as change relative to the frozen reference: raise the chosen response relative to that baseline, lower the rejected response, and the margin grows. The reference is a baseline, not a safety proof.

Suppose the current sequence log-probabilities are:

  • Chosen A: policy −8.2-8.2−8.2, reference −8.5-8.5−8.5
  • Rejected B: policy −9.5-9.5−9.5, reference −9.1-9.1−9.1
  • β=0.1\beta = 0.1β=0.1

Then:

  1. Chosen relative advantage: −8.2−(−8.5)=0.3-8.2 - (-8.5) = 0.3−8.2−(−8.5)=0.3
  2. Rejected relative advantage: −9.5−(−9.1)=−0.4-9.5 - (-9.1) = -0.4−9.5−(−9.1)=−0.4
  3. Margin: 0.3−(−0.4)=0.70.3 - (-0.4) = 0.70.3−(−0.4)=0.7
  4. Scaled logit: 0.1×0.7=0.070.1 \times 0.7 = 0.070.1×0.7=0.07
  5. σ(0.07)≈0.517\sigma(0.07) \approx 0.517σ(0.07)≈0.517
  6. Loss: −log⁡(0.517)≈0.659-\log(0.517) \approx 0.659−log(0.517)≈0.659

The update tries to grow that 0.70.70.7 margin: raise chosen likelihood relative to the reference, lower rejected likelihood, scaled by how far the policy already sits from the reference.

dpo_margin_from_logprobs.py
1from math import exp, log 2 3chosen_policy, chosen_reference = -8.2, -8.5 4rejected_policy, rejected_reference = -9.5, -9.1 5beta = 0.1 6margin = (chosen_policy - chosen_reference) - (rejected_policy - rejected_reference) 7logit = beta * margin 8loss = -log(1 / (1 + exp(-logit))) 9 10print(f"relative_margin={margin:.1f}") 11print(f"scaled_logit={logit:.2f}") 12print(f"dpo_loss={loss:.3f}")
DPO margin output
1relative_margin=0.7 2scaled_logit=0.07 3dpo_loss=0.659

Those −8.2-8.2−8.2 figures are already summed sequence log-probabilities. In a trainer they come from a causal shift: concatenate prompt and response, take next-token logits on the response span, log-softmax, gather the observed token, and sum. The next snippet does that on a four-token vocab for the same chosen/rejected split. Predict the result: boosting chosen-token logits should raise chosen log-probability and lower the loss while the frozen reference stays fixed. Padding masks, attention masks, and distributed training stay out of this example.

dpo_loss_from_token_logits.py
1import math 2 3CHOSEN_IDS = [1, 2] 4REJECTED_IDS = [3, 0] 5BETA = 0.1 6 7chosen_policy = [ 8 [0.0, 2.4, 0.1, -0.8], 9 [0.0, 0.2, 2.1, -0.6], 10] 11chosen_ref = [ 12 [0.0, 0.8, 0.2, 0.0], 13 [0.0, 0.1, 0.9, 0.0], 14] 15rejected_policy = [ 16 [0.2, -0.4, -0.2, 1.1], 17 [1.0, -0.3, -0.4, 0.2], 18] 19rejected_ref = [ 20 [0.1, 0.0, 0.0, 0.6], 21 [0.7, 0.0, 0.0, 0.2], 22] 23 24def log_softmax(logits: list[float]) -> list[float]: 25 peak = max(logits) 26 weights = [math.exp(value - peak) for value in logits] 27 total = sum(weights) 28 return [math.log(weight / total) for weight in weights] 29 30def sequence_logprob(steps: list[list[float]], token_ids: list[int]) -> float: 31 return sum( 32 log_softmax(logits)[token_id] 33 for logits, token_id in zip(steps, token_ids, strict=True) 34 ) 35 36def dpo_loss( 37 chosen_pi: list[list[float]], 38 rejected_pi: list[list[float]], 39) -> float: 40 margin = ( 41 sequence_logprob(chosen_pi, CHOSEN_IDS) 42 - sequence_logprob(chosen_ref, CHOSEN_IDS) 43 - ( 44 sequence_logprob(rejected_pi, REJECTED_IDS) 45 - sequence_logprob(rejected_ref, REJECTED_IDS) 46 ) 47 ) 48 logit = BETA * margin 49 return -math.log(1.0 / (1.0 + math.exp(-logit))) 50 51loss = dpo_loss(chosen_policy, rejected_policy) 52boosted_chosen = [ 53 [0.0, 3.4, 0.1, -0.8], 54 [0.0, 0.2, 3.1, -0.6], 55] 56boosted_loss = dpo_loss(boosted_chosen, rejected_policy) 57 58print(f"chosen_logp={sequence_logprob(chosen_policy, CHOSEN_IDS):.3f}") 59print(f"rejected_logp={sequence_logprob(rejected_policy, REJECTED_IDS):.3f}") 60print(f"dpo_loss={loss:.3f}") 61print(f"after_boost_loss={boosted_loss:.3f}") 62assert math.isfinite(loss) and boosted_loss < loss
DPO token logprob output
1chosen_logp=-0.501 2rejected_logp=-1.320 3dpo_loss=0.665 4after_boost_loss=0.650

At initialization, a policy copied from its reference has zero reference-relative log-ratios, so the DPO logit is zero and the loss is near 0.6930.6930.693. The model's token logits themselves need not be zero. After training starts, watch margins together with held-out preference quality and output regressions. A near-zero DPO logit alone doesn't diagnose weak pairs or a bad beta.

Production trainers also mask padding and track response length, because a whole-sequence log-prob sum can create length bias when chosen and rejected answers differ systematically in length.

Likelihood displacement: a bigger margin isn't a more likely chosen answer

Pair arithmetic above hides a second question: did the policy make the chosen answer more likely, or only make the rejected answer less likely? A rising DPO margin isn't the same as "the preferred answer is getting more likely." DPO tracks the gap between chosen and rejected relative log-ratios. Lowering log⁡πθ(yw∣x)\log\pi_\theta(y_w\mid x)logπθ​(yw​∣x) and log⁡πθ(yl∣x)\log\pi_\theta(y_l\mid x)logπθ​(yl​∣x) together can still look like a win when the rejected side falls faster.

Keep the P-7 pair's frozen reference at −8.5-8.5−8.5 (chosen) and −9.1-9.1−9.1 (rejected). If chosen log-probability slides from −8.2-8.2−8.2 to −9.1-9.1−9.1 while rejected slides from −9.5-9.5−9.5 to −11.2-11.2−11.2, the relative margin grows from 0.70.70.7 to 1.51.51.5 even though both labeled completions are being avoided. Plotting log⁡(π/πref)\log(\pi/\pi_{\text{ref}})log(π/πref​) makes that gap the thing you see: chosen starts at +0.3+0.3+0.3 and finishes at −0.6-0.6−0.6, so the preferred answer is now less likely than the SFT reference.

DPO likelihood displacement on the P-7 pair plotted as log-ratios to the frozen reference. Chosen log(π/π_ref) falls from +0.3 to -0.6 while rejected falls from -0.4 to -2.1, so the DPO margin still rises from 0.7 to 1.5 even though the chosen answer is now less likely than the SFT reference.
The plotted gap is the DPO margin: chosen minus rejected log-ratio to the frozen reference. Chosen crosses below zero, so the preferred P-7 answer is now less likely than SFT even while the margin grows.
dpo_likelihood_displacement.py
1ref_w, ref_l = -8.5, -9.1 2steps = [ 3 ("step0", -8.2, -9.5), 4 ("step3", -9.1, -11.2), 5] 6 7for name, pi_w, pi_l in steps: 8 margin = (pi_w - ref_w) - (pi_l - ref_l) 9 print(f"{name}: chosen={pi_w:.1f} rejected={pi_l:.1f} margin={margin:.1f}")
Displacement margin output
1step0: chosen=-8.2 rejected=-9.5 margin=0.7 2step3: chosen=-9.1 rejected=-11.2 margin=1.5

Monitor at least four series:

SignalWhat it catches
log⁡πθ(yw∣x)\log \pi_\theta(y_w \mid x)logπθ​(yw​∣x)Whether preferred answers stay likely
log⁡πθ(yl∣x)\log \pi_\theta(y_l \mid x)logπθ​(yl​∣x)Whether rejected answers are suppressed
Relative margin (DPO logit)Whether pairwise ranking is improving
KL or log-ratio to πref\pi_{\text{ref}}πref​Whether the policy is leaving the reference

If margins improve while chosen log-prob collapses, stop. Inspect data, β\betaβ, length bias, and offline coverage before more steps. Length-matched pairs, length-normalized log-probs, or length-aware objectives such as SimPO are the usual next tests.

Vanilla DPO is still just that pairwise loss plus a frozen reference. No reward model, no value model, no rollout.

Diagram showing Pairs (chosen, rejected), DPO loss, Frozen ref, and Policy.
Pairs (chosen, rejected), DPO loss, Frozen ref, and Policy.

Comparing RLHF and DPO

The useful contrast is what each method has to keep alive, not a winner-take-all ranking.[1]Reference 1Training Language Models to Follow Instructions with Human Feedback (InstructGPT).https://arxiv.org/abs/2203.02155[3]Reference 3Direct Preference Optimization: Your Language Model is Secretly a Reward Model.https://arxiv.org/abs/2305.18290 Read the table as a deployment question: which signal must stay live, and which behavior can your stored data never show you?

Side-by-side data paths for the same P-7 access task. RLHF samples a fresh rollout, scores it with a reward model, and charges KL before a PPO update. DPO never samples: it trains on the frozen chosen ticket-and-cite answer versus the rejected grant-tonight answer plus a frozen reference.
RLHF scores a new sample, including the "Policy-safe answer" preamble, then charges KL. DPO reuses the frozen P-7 pair and a frozen reference.
FeatureRLHF (PPO)DPO
Reward modelTrain a separate reward modelNo separate RM; reward is implicit
Training loopOn-policy RL with rolloutsOffline pairwise loss on fixed comparisons
Logical rolesPolicy + ref + reward + criticPolicy + reference
Most expensive stepSampling and scoring fresh responsesForward/backward on stored pairs
StabilitySensitive to reward scale, KL, and PPO settingsFewer loops, still sensitive to data and beta
Online explorationYesNot in vanilla DPO
Data dependenceCan collect fresh comparisons during trainingLimited by current pair coverage unless you refresh
MonitoringReward drift, KL, value loss, rollout qualityPreference loss, chosen log-prob, margin, length

DPO is a strong candidate baseline for offline pairwise preferences. PPO isn't obsolete. If you need online exploration, fresh model-generated negatives, or a reward that moves as the policy moves, an RL-style loop can reach cases a frozen DPO dataset can't.

The data both methods inherit

RLHF and DPO consume the same kind of row, then spend it differently. RLHF fits a reward model on the comparisons, then rolls out. DPO trains the policy on the pairs themselves.[1]Reference 1Training Language Models to Follow Instructions with Human Feedback (InstructGPT).https://arxiv.org/abs/2203.02155[3]Reference 3Direct Preference Optimization: Your Language Model is Secretly a Reward Model.https://arxiv.org/abs/2305.18290 The row is shared; the feedback path is not.

The hygiene from the reward-modeling chapter still applies: same rendered prompt, a clear non-tie label, generator provenance, and prompt-grouped splits so related comparisons don't leak into evaluation. A pair from another generator isn't automatically invalid, but it can miss the failure modes your current policy actually produces. When shift matters, include current-policy samples.

You don't need a huge dump of easy instructions. You need coverage of the distinctions you care about: refusals, tool use, reasoning, style, and the P-7-style policy calls. Ask what happens when the current policy invents a failure absent from the stored pairs: DPO has no training row for it until you refresh the data, while PPO can expose it only after a fresh rollout reaches its judge. If annotators keep disagreeing, more labels can quantify uncertainty. They won't turn a vague rubric into a training signal.

When the proxy lies

That release rehearsal is reward hacking in miniature. A policy exploits the scorer instead of getting better. The reward model is a proxy; optimize hard enough and the proxy becomes the target.

If the scorer overweights length or markdown, policy optimization will amplify those traits faster than answer quality. The visible symptom is rising proxy reward without a matching gain in held-out human preference.

HackSymptomDetection
Length gamingAnswers get steadily longerTrack mean response length
SycophancyModel agrees with a wrong userTest with false user claims
Format exploitationEverything wrapped in listsCompare formatted vs plain scores
Confidence mimicrySounds sure on hard itemsCalibration checks on known-hard questions

Verbosity

Annotators sometimes treat length as quality. Predict what happens next: a padded P-7 explanation can beat a short, correct one, so the policy learns to pad if that correlation is in the data.

  • Symptom: mean length climbs while helpfulness plateaus.
  • Fix: length-matched preference evals, and explicit concise-versus-padded labels. Length penalties can also punish necessary detail, so validate them.

The 0.693 trap

If the policy starts equal to its reference, every DPO relative margin is zero and the loss starts near −log⁡(0.5)=0.693-\log(0.5)=0.693−log(0.5)=0.693. That's expected. At zero logit, the gradient is σ(0)−1=−0.5\sigma(0)-1=-0.5σ(0)−1=−0.5, so the binary loss is not flat.

That is initialization, not evidence that a pair is weak. Ambiguous pairs still hurt. Conflicting labels on the same prompt can cancel in aggregate or teach arbitrary style. Diagnose from agreement, slices, and held-out behavior, not from initial loss.

dpo_zero_margin_is_not_zero_gradient.py
1from math import exp, log 2 3def sigmoid(value: float) -> float: 4 return 1 / (1 + exp(-value)) 5 6for logit in [0.0, 2.0]: 7 loss = -log(sigmoid(logit)) 8 gradient = sigmoid(logit) - 1 9 print(f"logit={logit:.1f} loss={loss:.3f} gradient={gradient:.3f}")
DPO zero-margin output
1logit=0.0 loss=0.693 gradient=-0.500 2logit=2.0 loss=0.127 gradient=-0.119
  • Symptom: loss stays near 0.6930.6930.693 after real updates, and held-out preference doesn't move.
  • Fix: confirm the policy is updating, then inspect contradictory labels, unresolved ties, prompt leakage, and missing coverage before blaming beta.

A fresh DPO run starts near loss 0.693 with a pair gradient of about -0.5. Does that prove the pair is ambiguous or uninformative?

Answer

No. A policy initialized from its reference starts with zero relative margin, so 0.693 is expected and the directional gradient is strong. Suspect ambiguity only when training stays there without held-out improvement, then inspect conflicting labels, leakage, and coverage.

A release gate that actually uses humans

Release asks a simpler question: did behavior improve within the tested drift budget? Tie proxy improvement to behavior you care about:

  1. Hold out human eval. Higher RM score has to win more often with people.
  2. Track auxiliaries: length, refusal rate, formatting drift, calibration.
  3. Watch KL and stop when you leave the tested drift budget.
  4. Refresh the scorer when current outputs leave its training distribution.

With the release-candidate numbers from the opening, predict the gate before running it: proxy reward should improve, human preference should fail, and promotion should be blocked.

alignment_release_gate.py
1metrics = { 2 "proxy_reward_delta": 0.31, 3 "held_out_human_win_delta": -0.04, 4 "mean_length_delta_tokens": 48, 5} 6ready = metrics["held_out_human_win_delta"] > 0 and metrics["mean_length_delta_tokens"] < 20 7 8print(f"proxy_improved={metrics['proxy_reward_delta'] > 0}") 9print(f"human_preference_improved={metrics['held_out_human_win_delta'] > 0}") 10print(f"release_ready={ready}")
Alignment release gate output
1proxy_improved=True 2human_preference_improved=False 3release_ready=False
Reward-hacking chart for the P-7 assistant. Proxy reward delta climbs from 0 to +0.31 while held-out human preference falls to -0.04 after step 2. A stop line at step 3 marks the promotion block, with mean length also up 48 tokens.
Block promotion when proxy reward rises while held-out preference falls. Here the split is already visible by step 3, and mean length is up 48 tokens.

Other failure signatures worth the same stop rule:

  • DPO loss stays near 0.6930.6930.693 after confirmed updates: audit labels, ties, leakage, and coverage rather than treating init loss as a diagnosis.
  • DPO improves tone but still grants admin: the pair set rewarded style, not the P-7 refusal. Add targeted safety pairs and policy-specific evals.
  • PPO generations get repetitive while reward rises: freeze promotion, inspect reward scale and KL, then refresh evaluation together.

Online DPO and iterative alignment

Vanilla DPO is offline: it trains on a fixed set of chosen and rejected responses.[3]Reference 3Direct Preference Optimization: Your Language Model is Secretly a Reward Model.https://arxiv.org/abs/2305.18290 Ask what happens when the policy improves past those rows: old comparisons describe a model you no longer have, so they may no longer contain hard negatives.

Later work studies the online setting: sample fresh responses from the current policy, label them with humans or a preference model, then apply an IPO-style or related pairwise update on the new comparisons.[5]Reference 5Human Alignment of Large Language Models through Online Preference Optimisation.https://arxiv.org/abs/2403.08635

Diagram showing Prompts, Sample, Judge, and Fresh pair.
Prompts, Sample, Judge, and Fresh pair.

The loop is:

  1. Sample two or more candidates from the current policy.
  2. Ask humans or a preference model which is better.
  3. Store a new (prompt, chosen, rejected) triple.
  4. Run a DPO-style update with whatever reference-policy rule the method uses.
  5. Repeat so the data follows the model.

There isn't one canonical "online DPO" algorithm, and reference-update choices differ. The family resemblance is what matters: refresh preference data on-policy, keep a pairwise loss, skip a full PPO stack.[5]Reference 5Human Alignment of Large Language Models through Online Preference Optimisation.https://arxiv.org/abs/2403.08635 You get less distribution mismatch and harder negatives over time, without necessarily standing up a critic.

Nearby methods, not drop-in replacements

These methods make different data contracts. Start with the signal you can reliably collect: a chosen/rejected pair, a binary label, or a task verifier. Nearby objectives relax the pair requirement, change the loss, or drop the reference. One popular method in this table isn't a DPO variant at all.

MethodWhat changes
IPO (Identity Preference Optimization)Replaces DPO's log-sigmoid with a squared loss on the preference margin, so the margin isn't driven without bound when labels look nearly deterministic.[6]Reference 6A General Theoretical Paradigm to Understand Learning from Human Feedback.https://arxiv.org/abs/2310.12036
KTO (Kahneman-Tversky Optimization)Drops pairs. Binary thumbs-up/down on individual outputs is enough.[7]Reference 7KTO: Model Alignment as Prospect Theoretic Optimization.https://arxiv.org/abs/2402.01306
ORPO (Odds Ratio Preference Optimization)Folds SFT and preference alignment into one stage and drops the separate reference model.[8]Reference 8ORPO: Monolithic Preference Optimization without Reference Model.https://arxiv.org/abs/2403.07691
SimPO (Simple Preference Optimization)Drops the reference and uses length-normalized average log-probability as the implicit reward, plus a target margin γ\gammaγ. In the authors' setups, β\betaβ around 2.0 to 2.5 and γ\gammaγ around 0.5 to 1.5 were typical.[9]Reference 9SimPO: Simple Preference Optimization with a Reference-Free Rewardhttps://arxiv.org/abs/2405.14734
GRPO (Group Relative Policy Optimization)Online RL, introduced in DeepSeekMath: sample a group of outputs for one prompt, normalize rewards inside the group, and skip a learned critic. DeepSeek-R1 is a later, verifier-heavy reasoning example.[10]Reference 10DeepSeekMath: Pushing the Limits of Mathematical Reasoning in Open Language Modelshttps://arxiv.org/abs/2402.03300[11]Reference 11DeepSeek-R1: Incentivizing Reasoning Capability in LLMs via Reinforcement Learninghttps://arxiv.org/abs/2501.12948[12]Reference 12GRPO Trainer.https://huggingface.co/docs/trl/grpo_trainer

IPO, KTO, ORPO, and SimPO still live in the offline preference family. GRPO is a different branch. Process reward models (PRMs) score intermediate steps rather than only the finished answer; that's adjacent credit assignment, and RLVR & Verifiable Rewards treats it properly.[13]Reference 13Let's Verify Step by Step.https://arxiv.org/abs/2305.20050

For subjective assistant behavior from fixed pairs, start with DPO. Binary logs without pairs point to KTO. Tight memory makes ORPO and SimPO attractive because they skip a frozen reference. When DPO overfits near-deterministic labels, IPO is the bounded-margin test. When a task has a checkable verifier, online RL such as GRPO is the method to evaluate, not another DPO flag.

There is one edge case worth predicting before the code: if every verifier gives a group the same reward, normalization has no direction and every relative advantage should be zero.

grpo_group_relative_advantage.py
1from statistics import mean, pstdev 2 3def group_advantages(rewards: list[float]) -> tuple[float, float, list[float]]: 4 center = mean(rewards) 5 scale = pstdev(rewards) 6 if scale == 0: 7 return center, scale, [0.0 for _ in rewards] 8 return center, scale, [(reward - center) / scale for reward in rewards] 9 10reward_groups = { 11 "mixed": [1.0, 0.0, 0.5, 1.0], 12 "all_equal": [1.0, 1.0, 1.0, 1.0], 13} 14 15for name, rewards in reward_groups.items(): 16 center, scale, advantages = group_advantages(rewards) 17 print( 18 f"{name}: mean={center:.3f} std={scale:.3f} " 19 f"advantages={[round(value, 3) for value in advantages]}" 20 )
Group-relative advantage output
1mixed: mean=0.625 std=0.415 advantages=[0.905, -1.508, -0.302, 0.905] 2all_equal: mean=1.000 std=0.000 advantages=[0.0, 0.0, 0.0, 0.0]

The zero-variance guard is load-bearing. If every sampled answer gets the same reward, the group has no relative signal. TRL reports frac_reward_zero_std, the fraction of generation-batch samples whose reward standard deviation is zero. A high value means the rewards aren't distinguishing answers, so inspect the verifier or the sampling before assuming GRPO is learning from useful comparisons.[12]Reference 12GRPO Trainer.https://huggingface.co/docs/trl/grpo_trainer

What comes after pairwise human labels

Human comparisons don't scale to every new failure. Constitutional AI and RLAIF (Reinforcement Learning from AI Feedback) write the rules down as principles, then use a model to critique, revise, and rank against those principles, so you need fewer repeated harmlessness labels.[14]Reference 14Constitutional AI: Harmlessness from AI Feedback.https://arxiv.org/abs/2212.08073 The next chapter is that pipeline, plus red teaming to see where the principles fail.

The dependence doesn't go away. A constitution is only as good as the judge that applies it. Held-out humans still decide whether "cite P-7 and escalate" survived contact with a real user.

Complete the lesson

Mastery Check

Answer every question, then check your score. Score 75% or higher to mark this lesson complete.

1.Which sequence and role set describes the PPO-style RLHF loop in the article?

Correct answer: SFT policy, reward model, and PPO update, with actor, reference, reward, and value roles represented in the rollout.

RLHF uses an SFT starting policy, a learned reward signal, and an online PPO-style update. The computation still needs actor, reference, reward, and value roles even when implementations shard or share weights.

2.A high-reward response contains a policy-safe preamble and has policy/reference log-ratio 1.6 with beta 0.20. Why can its shaped reward fall below a near-reference response?

Correct answer: Subtract beta times policy-reference drift, making the preamble 1.03 versus 1.18 for the near-reference response.

KL is a drift budget charged in the reward. A raw reward increase can be outweighed by movement away from the SFT reference, which is why the preamble sample loses after shaping.

3.For chosen policy/reference log-probs -8.2/-8.5 and rejected -9.5/-9.1 with beta 0.1, what DPO row values follow?

Correct answer: Logit 0.07 and loss about 0.659, from margin 0.3 - (-0.4) = 0.7 scaled by beta.

Chosen relative advantage is 0.3 and rejected is -0.4, so the margin is 0.7. Beta 0.1 gives logit 0.07, and negative log-sigmoid of that value is about 0.659.

4.A DPO margin rises from 0.7 to 1.5 while chosen log-probability falls below its reference value. What does this pattern require?

Correct answer: Inspecting likelihood displacement, KL or log-ratios, and held-out preference quality before taking more updates.

DPO can increase the gap by suppressing the rejected answer faster while also suppressing the chosen answer. The margin alone hides that displacement, so absolute and reference-relative diagnostics matter.

5.Which data and rollout distinction separates online PPO-style RLHF from vanilla DPO?

Correct answer: PPO uses fresh on-policy rollouts; DPO trains offline on fixed pairs with a frozen reference.

Online RLHF carries rollout and reward-model costs each cycle. DPO uses a direct offline pairwise objective, retaining a frozen reference in its likelihood-ratio comparison.

6.A policy's reward-model score climbs while held-out humans dislike longer compliance preambles. What is the likely diagnosis?

Correct answer: The reward proxy is overoptimized through a spurious preamble or length correlate; check human preference and KL.

A reward model is a proxy learned from finite comparisons. The policy can discover features such as a polite preamble that raise numeric reward without improving human judgments, which is classic reward hacking.

7.What loss should a zero-margin DPO row produce before learning, assuming the reference-relative logit is zero?

Correct answer: Expect about 0.693, because a zero logit gives probability 0.5 and -log(0.5).

A zero logit assigns equal probability to the preferred and rejected ordering. The negative log-likelihood of 0.5 is approximately 0.693, a useful initialization check.

8.Which routing of nearby alignment methods matches their data and objective assumptions?

Correct answer: KTO for individual binary feedback, IPO for near-deterministic pairs, and GRPO for online grouped rewards.

KTO drops pair requirements for thumbs-up or down feedback. IPO bounds the pairwise margin with a squared loss, while GRPO is online group-relative RL rather than another offline DPO variant.

9.A GRPO group gives every sampled answer exactly the same reward. What should the trainer report?

Correct answer: Zero relative advantage for every sample, so the group supplies no learning signal and the verifier or sampling needs inspection.

GRPO normalizes rewards within a sampled group. With zero standard deviation, all relative advantages are zero, so more updates cannot create information absent from the verifier or samples.

9 questions remaining.

Next Step
Continue to Constitutional AI & Red Teaming

RLHF and DPO steer a policy with preference comparisons, human or otherwise. The next chapter writes those rules as a constitution, uses AI critique and ranking to scale the labels, then red-teams the result to see which safeguards actually hold.

PreviousReward Modeling from Preference Data
Share this article
XFacebookLinkedInBlueskyRedditHacker NewsEmail
References

Training Language Models to Follow Instructions with Human Feedback (InstructGPT).

Ouyang, L., et al. · 2022 · NeurIPS 2022

https://arxiv.org/abs/2203.02155

Learning to Summarize from Human Feedback.

Stiennon et al. · 2020

https://arxiv.org/abs/2009.01325

Direct Preference Optimization: Your Language Model is Secretly a Reward Model.

Rafailov, R., et al. · 2023

https://arxiv.org/abs/2305.18290

Proximal Policy Optimization Algorithms.

Schulman, J., et al. · 2017

https://arxiv.org/abs/1707.06347

Human Alignment of Large Language Models through Online Preference Optimisation.

Calandriello, D., et al. · 2024

https://arxiv.org/abs/2403.08635

A General Theoretical Paradigm to Understand Learning from Human Feedback.

Azar, M. G., Rowland, M., et al. · 2023

https://arxiv.org/abs/2310.12036

KTO: Model Alignment as Prospect Theoretic Optimization.

Ethayarajh, K., et al. · 2024 · ICML 2024

https://arxiv.org/abs/2402.01306

ORPO: Monolithic Preference Optimization without Reference Model.

Hong, J., Lee, N., & Thorne, J. · 2024

https://arxiv.org/abs/2403.07691

SimPO: Simple Preference Optimization with a Reference-Free Reward

Meng, Y., et al. · 2024

https://arxiv.org/abs/2405.14734

DeepSeekMath: Pushing the Limits of Mathematical Reasoning in Open Language Models

Shao, Z., et al. · 2024

https://arxiv.org/abs/2402.03300

DeepSeek-R1: Incentivizing Reasoning Capability in LLMs via Reinforcement Learning

DeepSeek-AI · 2025

https://arxiv.org/abs/2501.12948

GRPO Trainer.

Hugging Face · 2026

https://huggingface.co/docs/trl/grpo_trainer

Let's Verify Step by Step.

Lightman, H., et al. · 2023 · ICLR

https://arxiv.org/abs/2305.20050

Constitutional AI: Harmlessness from AI Feedback.

Bai, Y., et al. · 2022 · arXiv preprint

https://arxiv.org/abs/2212.08073

Discussion

Questions and insights from fellow learners.

Discussion loads when you reach this section.