Chapter 6: RLHF & Alignment
Learn how to align LLMs with human values and preferences. Master Reinforcement Learning from Human Feedback (RLHF)---the technique that transformed GPT-3 into ChatGPT---understand reward modeling, policy optimization with PPO, the simpler Direct Preference Optimization (DPO) alternative, Constitutional AI for scalable oversight, and the challenges of collecting human preference data.
- Topics
- 5
- Videos
- 5
- Min read
- 39
Chapter Overview
Instruction tuning teaches a model to follow instructions, but it does not teach it to be helpful, harmless, or honest. A model might follow the instruction "explain how to hack a website" perfectly---and that is exactly the problem. Alignment ensures models behave in ways that are beneficial and safe.
Reinforcement Learning from Human Feedback (RLHF) is the technique that made ChatGPT possible. The key insight: instead of training on (input, correct output) pairs, we train on (output A is better than output B) preferences. Humans rank model outputs, a reward model learns to predict these preferences, and the LLM is optimized to maximize the reward model's score.
However, RLHF is complex and unstable. Recent alternatives like Direct Preference Optimization (DPO) achieve similar results with a simpler training pipeline. Constitutional AI (CAI) reduces the need for human annotation by having the model critique and revise its own outputs.
This chapter covers:
- Reward Modeling: Training a model to predict human preferences
- PPO for LLMs: The RL algorithm that optimizes the policy against the reward model
- DPO: A simpler alternative that eliminates the need for a separate reward model
- Constitutional AI: Scalable alignment through AI-generated feedback
- Human Preference Data: How to collect, curate, and validate preference annotations
Chapter Roadmap
Click any topic to jump in
Reward Modeling
Training a model to predict human preferences — the bridge between human judgment and optimization.
Preference Data
Collecting comparison data — how to gather and quality-control human preference annotations.
RL-based vs direct optimization
PPO for LLMs
Proximal Policy Optimization — the RL algorithm that fine-tunes LLMs against the reward model.
DPO
Direct Preference Optimization — skipping the reward model by optimizing preferences directly.
Constitutional AI
Self-improvement through AI-generated critiques — reducing reliance on human feedback.
Topics
5 topics in this chapter
After instruction tuning, a model follows requests, but it cannot tell a great answer from a merely acceptable one. It only imitates its demonstrations. To improve further we need a training signal that scores any response the model writes, and nobody can write down a formula for "helpful" or "harmless". What people can do reliably is compare two answers and say which is better. The challenge is to turn those comparisons into a score a training algorithm can maximise.
The previous chapter, Fine-tuning, ended with supervised instruction tuning. This chapter, RLHF & Alignment, goes beyond imitation to optimising for human preferences, and this first topic builds the scoring model.
We start with the Bradley-Terry model, which turns a reward difference into the probability that one response beats another. Then we cover reward model training, the pairwise loss and how rankings become pairs. Next comes reward hacking, what happens when a policy exploits the reward model's mistakes. We finish with reward model evaluation, including the ceiling set by human agreement.
Definition
A reward model is a network that maps a prompt and a response to a single scalar score. It is trained on human comparisons so that preferred responses score higher, typically with a Bradley-Terry likelihood. It is usually initialised from the SFT model, with the language-model head replaced by a scalar head, and it supplies the reward for RLHF.
In this topic
- 1Bradley-Terry Model
- 2Reward Model Training
- 3Reward Hacking
- 4Reward Model Evaluation
Bradley-Terry Model
The Bradley-Terry model, first used to rank sports teams, turns scores into win probabilities. Given a prompt , a preferred response , and a rejected response , the formula says wins with probability of the reward difference, where is the logistic sigmoid. Only differences matter, so adding a constant to every reward changes nothing, and rewards have no absolute meaning. A gap of 0 gives 50 percent, and larger gaps approach certainty. The reward model is usually the SFT model with its vocabulary head replaced by one scalar output. The model assumes preferences are consistent, which intransitive or split human judgments violate.
The Bradley-Terry model parameterizes preferences as . The sigmoid maps the reward difference to , so a gap of gives . The loss is the negative log-likelihood of the observed preference. Gradient: , meaning the gradient vanishes as the model becomes confident about clear preferences and focuses learning on ambiguous pairs.
Reward model scores: , . What is the predicted preference probability?
Reward Model Training
Training maximises the Bradley-Terry likelihood of the observed human choices. The loss in the formula is the negative log sigmoid of the reward gap, averaged over triples of prompt, chosen response , and rejected response . It is small when the chosen response already scores much higher and large when the order is wrong. Labellers often rank several responses, and each ranking of responses gives pairs. InstructGPT ranked 4 to 9 responses per prompt and kept all pairs from one prompt in the same batch, to avoid overfitting. Llama 2 trained separate helpfulness and safety reward models on over a million comparisons, adding a margin for strongly held preferences.
The RM loss is a binary cross-entropy where the 'label' is always 1 (preferred wins). With ranked responses per prompt, you get pairs: 4 responses yield 6 pairs, making ranking far more data-efficient than binary comparison. The RM's generalization depends on the ratio of parameters to comparison pairs — overparameterized RMs memorize annotator noise.
You have 100K prompt-response pairs with rankings. How do you create training data for the RM?
Reward Hacking
A reward model is a learned approximation of human judgment, trained on a limited set of responses. When a policy is optimised hard against it, the policy finds responses that score well for the wrong reasons. It might write longer answers, sound more confident, use phrases the reward model liked, or agree with the user. This is Goodhart's law: a measure that becomes a target stops being a good measure. Gao et al. (2022) measured it with a gold reward model standing in for humans. As optimisation continued, the proxy reward kept rising, but the gold reward first rose and then fell. Larger reward models delayed the fall.
Reward hacking occurs when the policy finds inputs that maximize in regions where the RM has poor calibration. Formally, the RM is accurate near the SFT distribution but unreliable far from it. As KL divergence grows, the policy exploits extrapolation errors. The Goodhart curve shows reward proxy increasing while true quality peaks and then drops.
After RLHF, the model starts producing unnecessarily long, repetitive answers that score high on the RM but are unhelpful. What happened?
Reward Model Evaluation
The basic metric is pairwise accuracy on held-out comparisons, the fraction of pairs where the chosen response gets the higher score. Chance is 50 percent. The ceiling is not 100 percent but the rate at which humans agree with each other, about 73 percent between InstructGPT's labellers, because a reward model cannot predict a coin-flip judgment. Calibration matters too: pairs scored at 0.8 should be won about 80 percent of the time. Benchmarks such as RewardBench test hard cases in chat, reasoning, and safety, where one answer has a verifiable flaw. The final test is downstream: does optimising against it improve the policy according to people?
RM accuracy is bounded by human inter-annotator agreement . If humans agree 76% of the time, a perfect RM can achieve at most 76%. Relative performance normalizes against this ceiling. Calibration measures whether predicted corresponds to 80% actual agreement in held-out data. Expected Calibration Error (ECE) bins predictions and measures the gap between predicted and actual preference rates.
Your RM achieves 73% accuracy on held-out preference pairs. Human annotators agree 76% of the time. Is your RM good?
Theory Exercise
Problem:
You are designing a reward model for a coding assistant. What specific signals should the RM learn to detect as 'good' vs 'bad' code responses? How would you structure the preference data collection?
Hints:
- Think about what makes code responses genuinely helpful
- Consider objective vs subjective quality signals
- Think about the expertise needed for annotation
Related Problems on PixelBank
A reward model can score any response, but it cannot tell the language model how to change its weights. The reward arrives only after a whole response has been sampled, one token at a time, and sampling is not differentiable. So we cannot simply backpropagate the reward. We need a reinforcement learning algorithm that raises the probability of responses that scored well, and we must keep the model from drifting into text that fools the reward model.
The previous topic, Reward Modeling, built the scoring function. This topic uses it to train the policy with Proximal Policy Optimization (PPO), the algorithm behind InstructGPT and the first ChatGPT.
We start with the RLHF objective, expected reward minus a KL penalty that keeps the policy near the SFT model. Then we cover the PPO algorithm, whose clipped ratio lets it take several gradient steps on each batch of samples safely. Next comes the value function baseline, which turns raw rewards into advantages and reduces variance. We finish with implementation challenges: four models in memory, slow generation, and many interacting hyperparameters.
Definition
PPO for LLMs is a policy-gradient method that treats the language model as a policy, each generated token as an action, and the reward model's score, minus a KL penalty to a frozen reference model, as the reward. It maximises a clipped surrogate objective, where the ratio of new to old token probabilities is limited to . A learned value function supplies advantage estimates.
In this topic
- 1The RLHF Objective
- 2PPO Algorithm for LLMs
- 3Value Function Baseline
- 4Implementation Challenges
The RLHF Objective
The formula asks for a policy that earns high reward on prompts from the dataset , while staying close to the reference policy , the frozen SFT model. Closeness is the KL divergence , weighted by . The penalty matters because the reward model is only accurate near the responses it was trained on. Far from them its scores are unreliable and easy to exploit. In practice the KL term is estimated per token from log-probability differences and subtracted from the reward. Bai et al. (2022) found reward grew roughly linearly with the square root of KL. Typical values are 0.01 to 0.2.
The objective has a closed-form solution: . This is a Boltzmann distribution over the reference policy, re-weighted by exponentiated reward. The partition function ensures normalization. Higher flattens the distribution (conservative), lower sharpens it toward high-reward outputs (aggressive). This closed form is what DPO exploits directly.
What happens if (no KL penalty)?
PPO Algorithm for LLMs
PPO updates the policy with the objective in the formula. The ratio compares the current policy with the one that generated the samples, and is the advantage, how much better the response did than expected. Multiplying them gives the standard policy-gradient surrogate. Clipping the ratio to , with usually 0.2, and taking the minimum of the clipped and unclipped terms removes any incentive to move a probability far in one update. That lets PPO reuse each expensive batch of generated responses for several gradient steps. For LLMs the ratio and advantage are computed per token.
PPO clips the importance ratio to . When advantage (good action), the gradient is zero if — preventing too-large increases. When (bad action), gradient is zero if — preventing too-large decreases. The min in is a pessimistic bound: it takes the worse of the clipped and unclipped objectives, ensuring conservative updates in both directions.
The policy ratio and advantage , with . What is the PPO loss?
Value Function Baseline
The policy gradient multiplies each response's log-probability gradient by a score. If that score is the raw reward, every response with a positive reward is reinforced, good or bad, and learning is slow and noisy. Subtracting a baseline fixes this. The value function in the formula estimates the reward the current policy expects on prompt , and the advantage asks whether this response beat that expectation. The gradient stays unbiased, but its variance drops sharply. In RLHF the critic is usually another copy of the model with a scalar head, often started from the reward model and trained alongside the policy.
The advantage subtracts the expected reward for prompt from the actual reward. Without the baseline, the gradient has high variance because all rewards are positive (the model cannot distinguish 'good' from 'slightly less good'). The value baseline centers the signal: positive advantage means 'better than expected,' negative means 'worse.' Variance reduction is proportional to .
Prompt X typically gets reward ~3.5. Response Y gets reward 4.2. What is the advantage?
Implementation Challenges
PPO-based RLHF is the hardest stage of the LLM pipeline to run. It needs four models: the policy and value model, both trained, plus the frozen reference and reward models. Each step alternates slow autoregressive generation with scoring and several PPO epochs, so the GPUs switch between inference and training. Many details matter, including reward normalisation, KL estimation, advantage whitening, the learning rate, , , and batch size. Huang et al. listed over 20 of them when reproducing OpenAI's summarisation results. Watch for rising KL, collapsing output diversity, and growing response length, the usual signs of instability or reward hacking.
RLHF with PPO requires 4 models totaling bytes in BF16 (where is parameter count). For 7B parameters: GB just for weights. Optimizer states (Adam: 2 states per param for policy + value) add another GB. KV cache and activations add GB. Total: GB, requiring multi-GPU setups even for modest model sizes.
During RLHF, you need a 7B policy, 7B reference, 7B reward model, and 7B value model in memory. How much GPU memory?
Theory Exercise
Problem:
During RLHF training, you observe: (1) reward increases steadily, (2) KL divergence increases rapidly, (3) output quality (measured by human eval) peaks and then decreases. Diagnose the problem and propose a fix.
Hints:
- Think about what increasing KL divergence means
- Consider the relationship between reward and actual quality
- Think about the role of the beta parameter
Related Problems on PixelBank
PPO-based RLHF works, but it is expensive and fragile. It trains a separate reward model, keeps four models in memory, samples new text at every step, and depends on many hyperparameters that interact. Many teams found it hard to reproduce. Yet the goal is simple: make preferred responses more likely and rejected ones less likely, without drifting far from the SFT model. The question is whether that can be done directly from the preference pairs, with an ordinary supervised loss.
The previous topic, PPO for LLMs, solved the RLHF objective with reinforcement learning. This topic solves the same objective with no reward model and no sampling loop.
We start with the DPO objective and the observation behind it: the optimal policy of the KL-regularised objective defines its own reward, so a logistic loss on log-probability ratios is enough. Then we compare DPO with RLHF and PPO on cost, stability, and exploration. Next comes the beta parameter, which sets how far the policy may move. We finish with the variants IPO, KTO, and ORPO.
Definition
Direct Preference Optimization (DPO) fine-tunes a policy on preference pairs by minimising a logistic loss on the difference between the two responses' log-probability ratios against a frozen reference model, scaled by . It has the same optimum as the KL-regularised RLHF objective under a Bradley-Terry preference model, but needs no explicit reward model and no reinforcement learning.
In this topic
- 1DPO Objective
- 2DPO vs RLHF/PPO
- 3The Beta Parameter
- 4Variants: IPO, KTO, ORPO
DPO Objective
The KL-regularised RLHF objective has a known optimal policy: is proportional to . Solving for the reward gives plus a term that depends only on , which cancels in a Bradley-Terry comparison. Substituting this implicit reward into the reward-model loss gives the DPO loss in the formula. is the policy being trained, the frozen SFT model, and and the chosen and rejected responses. Each log ratio says how much more likely the policy makes a response than the reference does. The loss pushes the chosen ratio above the rejected one.
DPO rearranges the RLHF closed-form solution to get . Substituting into the Bradley-Terry preference model, the terms cancel, yielding the DPO loss directly in terms of policy log-ratios. The key mathematical insight: you never need to compute the reward or partition function explicitly — they are implicitly defined by the policy-reference ratio.
Conceptually, what does DPO optimize the model to do?
DPO vs RLHF/PPO
DPO trains like SFT. It makes one pass over a fixed dataset of pairs with a standard loss, needs only the policy and a frozen reference, and has one main hyperparameter, . The reference log-probabilities can even be computed once in advance. It is stable and cheap, which is why open models such as Zephyr and Tulu 2 used it. The costs come from being offline. The policy never tries new responses and gets feedback on them, so it learns only from the pairs it is given. An explicit reward model can also score fresh samples, generalise across prompts, and be reused. Online and iterative DPO variants narrow this gap.
DPO reduces memory from to parameters (policy + reference only). The training loop collapses from generate → score → compute advantage → PPO update to a single forward pass through both models on preference pairs. The tradeoff: DPO uses a fixed offline dataset, so it cannot explore new response strategies during training. PPO's on-policy sampling lets it discover and reinforce novel high-reward behaviors that were not in the original preference data.
RLHF requires 4 models; DPO requires 2. What is the memory savings?
The Beta Parameter
In DPO, plays the role of the KL coefficient in RLHF. It scales the log-ratio margin inside the sigmoid. With a large , a small change in the log ratios already saturates the sigmoid, so the loss is satisfied early and the policy stays close to the reference. With a small , the policy must move much further from the reference to reach the same loss, so it follows the preferences more aggressively. That improves alignment on the data but raises the risk of overfitting and degenerate text. The DPO paper used values from 0.1 to 0.5, and 0.1 is the common default. Always tune it on held-out preferences.
controls the strength of the KL constraint. In the implicit reward , higher means a given log-ratio translates to a larger reward difference, so the model needs less deviation to achieve the same reward gap. As , the model can deviate arbitrarily from the reference. As , the model stays at the reference policy regardless of preferences. The optimal balances alignment quality against distribution shift.
DPO with produces very different outputs from SFT. With , outputs are almost identical to SFT. What should you do?
Variants: IPO, KTO, ORPO
Each variant fixes one weakness of DPO. IPO (Azar et al., 2023) points out that with deterministic preferences DPO can push the margin toward infinity and overfit. It replaces the log-sigmoid with a squared loss that pulls the margin toward a fixed target, . KTO (Ethayarajh et al., 2024) needs no pairs, only responses labelled desirable or undesirable, and uses a prospect-theory value function that weighs losses more than gains. It matched pairwise methods from 1B to 30B parameters. ORPO (Hong et al., 2024) adds an odds-ratio penalty to the SFT loss, so one stage does both steps without a reference model.
IPO replaces the log-sigmoid loss with a squared loss , which prevents the implicit reward from growing unboundedly. KTO uses prospect theory: losses from bad outputs are weighted times more than gains from good outputs (typically ), matching Kahneman-Tversky's finding that humans feel losses more strongly. ORPO merges SFT and alignment into one objective by adding an odds-ratio penalty to the standard language modeling loss.
You have 50K examples labeled as 'good response' or 'bad response' but NOT paired comparisons. Which method works?
Theory Exercise
Problem:
You have a limited budget and need to align a 13B model. You have 50K preference pairs. Compare the cost and quality tradeoffs of: (A) Full RLHF with PPO, (B) DPO, (C) KTO with unpaired data.
Hints:
- Consider memory requirements for each approach
- Think about training complexity and engineering effort
- Consider the data requirements
Related Problems on PixelBank
RLHF needs large numbers of human judgments, and for harmlessness that is especially costly. Labellers must read disturbing content, they disagree about borderline cases, and a model trained only to avoid harm tends to become evasive, refusing anything that looks risky. Every change to the desired behaviour also means relabelling. The question is whether the rules themselves, written once in plain language, can supervise the model, with the model doing most of the labelling.
The previous topic, DPO, removed the reward model and the reinforcement learning loop. This topic removes most of the human labels instead.
We start with the constitutional approach from Anthropic: a supervised phase where the model critiques and revises its own responses, and a reinforcement learning phase that uses AI preferences. Then we look at principles as supervision, why a short list of rules generalises to many cases. Next comes RLAIF, training with preferences labelled by an AI, and how well it matches human feedback. We finish with red teaming, the adversarial testing that finds where the rules and training still fail.
Definition
Constitutional AI (CAI) is an alignment method in which a written list of principles, the constitution, replaces most human harmlessness labels. In a supervised phase, the model critiques and revises its own responses against the principles and is fine-tuned on the revisions. In a reinforcement learning phase, an AI model chooses between response pairs using the principles, and those preferences train a reward model for RL.
In this topic
- 1The Constitutional Approach
- 2Principles as Supervision
- 3RLAIF: AI as Annotator
- 4Red Teaming
The Constitutional Approach
CAI has two phases. In the supervised phase, a helpful but unsafe model answers harmful prompts. It is then asked to critique its answer against a randomly chosen principle and to rewrite it, sometimes over several rounds. The original model is fine-tuned on the revised answers. In the RL phase, the fine-tuned model produces pairs of answers, a model picks the better one according to a principle, and those AI preferences train a preference model. RL against that model is called RLAIF. Human helpfulness labels were still used. The result was a model that was both more harmless and less evasive, because it explained its objections instead of refusing silently.
CAI Phase 1 generates response candidates , critiques each against principles, and selects the revised response that minimizes violations. Phase 2 creates AI preference pairs and applies RLHF. The scaling advantage: principles cover an exponential number of scenarios, whereas human annotation scales linearly. One principle like 'avoid harmful content' replaces millions of individual annotations.
The model generates: "Here is how to pick a lock: 1. Get a tension wrench..." The constitution says "Do not provide instructions for illegal activities." What happens?
Principles as Supervision
A human preference label covers one comparison. A principle such as "choose the response that is less likely to help someone cause harm" can be applied to any number of comparisons, at almost no cost per example. The constitution also makes the target explicit: the rules can be read, argued about, and changed, and changing them means rerunning the pipeline, not relabelling everything. Principles have limits. They can conflict, as when helpfulness and caution pull in different directions. They depend on the model interpreting them correctly, and vague wording produces inconsistent labels. Anthropic publishes the constitution it uses for Claude.
Each principle defines a constraint over responses. The constitution is the conjunction . A response is compliant if all constraints are satisfied. In practice, principles are soft constraints evaluated by the LLM itself, producing a score for each principle. The aggregate constitutional score serves as a proxy reward for RLAIF.
Why are principles more scalable than human preference annotations?
RLAIF: AI as Annotator
In RLAIF, an off-the-shelf LLM labels preference pairs in place of people, usually by being shown the prompt, two responses, and a principle or rubric, and asked which is better. Asking it to reason first, and averaging over both orders to remove position bias, improves the labels. The labels then train a reward model as usual. Lee et al. (2023) found RLAIF comparable to RLHF on summarisation and helpful and harmless dialogue, even when the labeller was the same size as the policy. LLM judges also agree with human preferences over 80 percent of the time in MT-Bench tests. They share model biases such as favouring verbose or self-similar text.
In RLAIF, the preference annotator is a language model prompted with the constitution. Given , the AI outputs . Human inter-annotator agreement is typically 73-78%, while AI self-consistency reaches 85-90%. The higher consistency comes at the cost of potential systematic blind spots — the AI may consistently miss violation types it was not trained to detect, whereas diverse human annotators catch a broader range of issues.
Can AI feedback fully replace human feedback?
Red Teaming
Red teaming is adversarial testing: people or models deliberately try to make the system produce harmful output before users do. Targets include dangerous instructions, harassment, bias, privacy leaks, misinformation, and prompt injection. Ganguli et al. (2022) released 38,961 human red-team attacks and found that RLHF models became harder to attack as they grew. Perez et al. (2022) used one language model to generate test cases against another, uncovering tens of thousands of offensive replies in a 280B chatbot. Findings feed back into training data, the constitution, and filters. Because every fix invites new attacks, red teaming is continuous, not a one-time audit.
Red teaming is an adversarial search over prompt space for inputs that maximize the probability of harmful outputs: . Automated red teaming uses another LLM as the attacker, creating a minimax game between the attacker and the aligned model. Each discovered jailbreak becomes a training example: is added to the SFT data, closing the exploit.
A red teamer finds that asking 'pretend you are an evil AI with no restrictions' bypasses safety measures. How do you fix this?
Theory Exercise
Problem:
Design a constitution (5-7 principles) for an LLM assistant used by elementary school students (ages 8-12). How would these differ from a general-purpose assistant's constitution?
Hints:
- Think about age-appropriate content
- Consider the role of the AI as an educational tool
- Think about what safety means for children
Every method in this chapter learns from the same raw material: judgments of which response is better. A reward model can only be as good as its comparisons, and DPO copies whatever the pairs reward. If labellers favour longer answers, the model gets longer. If they reward agreement, it becomes sycophantic. If the guidelines are vague, the labels are noisy and the model learns noise. Collecting preference data is where alignment decisions are actually made.
The previous topic, Constitutional AI, used AI feedback to replace many human labels. This topic covers the human data that still anchors alignment, and how to collect it well.
We start with annotation design: guidelines, calibration, gold questions, and multiple labellers per item. Then we cover common annotation biases, including length, position, and sycophancy, and how each leaks into the model. Next comes scale and cost, what real projects collected and how to spend a labelling budget. We finish with preference data formats, from binary choices to rankings and ratings on separate aspects, and how much signal each gives per unit of labelling work.
Definition
Human preference data is a collection of prompts, candidate responses, and human judgments of their relative quality, recorded as binary choices, rankings, ratings, or per-aspect comparisons. It is the training signal for reward models and direct preference methods. Its value depends on the guidelines, the labeller pool, the agreement between labellers, and the control of systematic biases.
In this topic
- 1Annotation Design
- 2Common Annotation Biases
- 3Scale and Cost
- 4Preference Data Formats
Annotation Design
Good preference data starts with the labelling task, not the model. Write guidelines that define what better means for each dimension, such as helpfulness, honesty, and harmlessness, and say how to trade them off, with worked examples of hard cases. Run calibration rounds where labellers compare answers and discuss disagreements. Mix in gold items with known answers to track each labeller's accuracy. Collect several labels per item for a sample, so agreement can be measured. Let labellers mark ties and say how strong a preference is. Llama 2 recorded strength on a four-level scale, from significantly better to negligibly better, and used it as a margin.
The quality of preference data is bounded by the annotation protocol. With annotators per example and binary labels, the expected label noise is where is the agreement rate. Majority vote over annotators reduces effective noise to . Going from 1 to 3 annotators, each right 75% of the time, reduces the effective error rate from 25% to about 16% ( correct).
Annotator A prefers concise answers. Annotator B prefers detailed explanations. Both are valid preferences. How do you handle this?
Common Annotation Biases
Labellers are fast, tired, and human, and their shortcuts become model behaviour. Length bias favours longer answers, since they look more thorough. Position bias favours whichever response is shown first, or second. Confidence bias favours assured answers over hedged ones, even when the hedge is correct. Sycophancy bias favours answers that agree with the user's stated view. Sharma et al. (2023) found that both humans and preference models sometimes preferred convincing sycophantic answers over correct ones, and that optimising against such models can trade truthfulness for agreement. Countermeasures include random order, length-matched pairs, fact-checking tasks, and prompts built so the correct answer disagrees with the user.
Length bias manifests as where in biased annotations. The reward model learns this: . During RLHF, the policy then optimizes , producing outputs that are longer than optimal. Debiasing requires either normalizing rewards by length or including length-controlled pairs in the training data.
After RLHF, your model gives very long responses and always agrees with the user, even when the user is wrong. What annotation bias caused this?
Scale and Cost
Preference datasets range from tens of thousands to millions of comparisons. InstructGPT's reward model was trained on rankings of 4 to 9 responses for each of tens of thousands of prompts. Anthropic's helpful and harmless data had over 160,000 comparisons, and Llama 2 used over 1 million new comparisons, collected in weekly batches as the model improved. Cost per label varies widely. Crowd workers cost about a dollar or two per comparison, specialists much more, and domain experts in medicine or law the most. Costs are cut by using AI labels for easy cases, reserving experts for hard ones, and collecting rankings instead of single choices.
Data efficiency follows a power law: alignment quality where is the number of preference pairs and -. This means doubling the data yields only 7-23% quality improvement. InstructGPT achieved strong results with 30K pairs, suggesting diminishing returns beyond moderate scale. The cost-quality tradeoff depends on annotator expertise: expert annotations have lower noise () vs crowd workers (), so fewer expert pairs can match many crowd pairs.
You need 100K preference pairs for medical LLM alignment. Expert medical annotators charge 50 USD per comparison. What is the cost? How would you reduce it?
Preference Data Formats
The format fixes how much information each judgment carries. A binary choice between two responses is fastest and most reliable, and it gives one pair. A ranking of responses gives pairs, though they are correlated because they come from one ordering. A Likert rating, such as 1 to 5, captures how good each response is, but people calibrate scales differently, so ratings are noisier across labellers. Per-aspect labels, such as helpfulness and safety judged separately, let you train separate reward models, as Llama 2 did, or weight the aspects later. Single good or bad labels suit KTO. Choose the format to match the algorithm and your labelling budget.
From ranked responses, you extract pairwise comparisons. The information gain scales superlinearly: yields 1 pair, yields 6 pairs (6x data from 2x annotation effort). Ranked data also provides ordinal distance: a pair with rank gap 3 carries stronger signal than gap 1. Weighting the loss by rank gap improves RM training by emphasizing clear preferences over ambiguous ones.
You have 4 responses per prompt and use ranking. How many training pairs does each prompt generate vs binary comparison?
Theory Exercise
Problem:
Design a preference data collection pipeline for a creative writing assistant. How would you define 'preferred' for a subjective task like creative writing? What biases should you watch for?
Hints:
- Creative quality is highly subjective
- Think about what makes writing 'good' vs 'preferred'
- Consider the diversity of writing styles and genres