Modules / Gen AI / Alignment Lab

Fine-Tuning vs RLHF and DPO

Pretraining decides what a model can say. Supervised fine-tuning decides what it usually says. Preference optimisation decides which of two plausible answers it prefers — and, pushed too hard, which one it degenerates into.

Overview

Quick Context

A pretrained model is a text predictor. Ask it a question and it produces something a document containing that question might plausibly continue with — which is not the same as an answer, and certainly not a helpful one.

Two more stages turn that into an assistant. Supervised fine-tuning shows it thousands of written demonstrations of the behaviour you want. Preference optimisation then shows it pairs of answers with a human verdict on which is better, for all the cases where nobody could write the ideal answer but anyone can pick the better of two.

Stage 2 — Fine-Tuning

0.0

how hard the demonstrations pull

Stage 3 — Preferences

1.00

high keeps the model near its SFT self; low lets it chase reward

a real and well-documented flaw, not a hypothetical one

"Explain why the sky is blue to a 10-year-old"

The Three Stages

Scores

What Humans Rate It
5.4
out of 10, expected
What the reward model says
Drift from SFT (KL) 0.000

 

Which Stage Fixes What

Pretraining — knowledge and fluency. Enormously expensive, done once.

SFT — format, task, register. Cheap, needs written examples.

RLHF / DPO — taste between plausible answers. Needs comparisons, not examples.

Retrieval — facts. None of the above.

Fine-Tuning, RLHF and DPO: A Practical Guide

Three techniques that all get called "training", doing three different jobs.

The maths both preference methods share

Every preference method optimises the same objective: get more reward without drifting far from the model you started with. That constraint has a closed form,

π(y) ∝ πref(y) · exp( r(y) / β )

which is exactly what this page computes. The reference policy is the SFT model, r is the reward, and β is the leash: large β keeps the tuned model close to its reference, small β lets it chase reward wherever that leads. The drift readout is the KL divergence between the two, which is the quantity the penalty is penalising.

RLHF gets r from a reward model trained on human comparisons, then optimises against it with PPO. DPO skips the reward model entirely: the same optimum can be reached by a supervised-looking loss on the preference pairs themselves. Same target, far less machinery, which is why DPO and its relatives took over so quickly.

Three stages, three different jobs

A usable assistant is not produced in one training run. Three stages follow one another, each teaching something the previous one cannot.

1. Pretraining — next-token prediction over enormous quantities of text. This is where knowledge and language competence come from. It costs millions of pounds and produces a base model that completes text rather than answering questions.

2. Supervised fine-tuning (SFT) — training on curated examples of instructions and good responses. This teaches the format: that a question should be answered, that output should be structured a particular way, that a conversation has turns.

3. Preference optimisation — RLHF, DPO or similar. Humans compare pairs of responses and the model is tuned towards the preferred one. This teaches the qualities that are easy to recognise and hard to demonstrate: helpfulness, appropriate caution, tone, refusing what should be refused.

StageData neededTeaches
PretrainingTrillions of tokensKnowledge, language
SFTThousands of examplesFormat, task behaviour
PreferenceThousands of comparisonsQuality, tone, safety

Why preference learning exists at all

The natural question: if SFT can learn from good examples, why add a stage?

Because for many qualities, writing an ideal example is harder than judging between two candidates. Asked to produce the perfect response to a sensitive question, most annotators struggle. Shown two responses and asked which is better, they answer quickly and consistently.

Preference data is therefore cheaper and more reliable to collect for exactly the qualities that matter most in an assistant.

There is a second reason, which is about the loss function. SFT maximises the likelihood of one target response, so anything not in the target is implicitly wrong — even if it is equally good. Preference training instead pushes the model's distribution towards a whole region of preferred behaviour, which suits problems with many valid answers.

RLHF, and how DPO simplified it

RLHF has three moving parts:

  1. Collect human comparisons of response pairs.
  2. Train a reward model to predict which response a human would prefer.
  3. Optimise the language model against that reward with reinforcement learning (PPO), including a KL penalty keeping it close to the SFT model.

The KL penalty is not optional. Without it the policy drifts into degenerate text that scores highly on the reward model and is useless — reward hacking, and it is the characteristic failure of the method.

Practically, RLHF is complicated: two models in memory, an RL loop that is sensitive to hyperparameters, and a reward model that can be gamed.

DPO (direct preference optimisation) removes the reward model and the RL loop. It shows that the same objective can be optimised directly on the preference pairs with a simple classification-style loss — increase the likelihood of the preferred response, decrease the likelihood of the rejected one, relative to a frozen reference model.

 RLHF (PPO)DPO
Reward modelRequiredNot needed
Training loopRL, sensitiveSupervised, stable
MemoryPolicy + reward + referencePolicy + reference
QualityStrong, well-provenComparable in most reports
ComplexityHighLow

DPO's simplicity is why it became the default for open models. Variants — IPO, KTO, ORPO, SimPO — adjust the loss or remove the reference model; the family is still moving.

The one equation both preference methods share

RLHF and DPO look like completely different machinery, and they optimise the same objective. Writing that objective out is the shortest route to understanding what preference training does -- and what neither method can fix.

example_01.pyNumPy
Output

Guided tour

  1. Start at pretraining. With SFT at 0 and no preference method, the dense jargon answer is the most likely one. That is what "most probable continuation" looks like when the text you trained on is the internet.
  2. Apply SFT. Raise Supervised Fine-Tuning to 2. The demonstrated answer — short, clear, aimed at a child — takes over. Nothing has been rewarded yet; it is just imitation.
  3. Add RLHF with a tight leash. Set the method to RLHF with beta at 3. The good answer gains a little, the drift stays small, and human ratings go up.
  4. Loosen the leash. Drag beta down towards 0.1. The model collapses onto the long, hedging, flattering answer — because the reward model scores it highest. Reward goes up, the human rating goes down, and the drift readout goes through the roof. That is reward hacking, and it is why the KL penalty is not optional.
  5. Fix the reward model instead. Uncheck Reward Model Likes Long Answers and the collapse stops happening, at the same beta. The KL penalty was never the real fix; it was a guard rail against a proxy that was wrong.
  6. Compare DPO. Switch the method to DPO. It moves probability towards the preferred answer and away from the rejected one, and it has no reward model to hack — but it also has no opinion at all about answers nobody compared.

Choosing between them

  • Wrong facts? None of these. Use retrieval. Fine-tuning teaches behaviour, and treating it as a way to insert knowledge is the most expensive mistake in this area.
  • Wrong format, tone or task? SFT, and often LoRA so you are not moving every weight.
  • Right content, wrong judgement? Preferences. If you can rank two outputs but cannot write the perfect one, that is exactly the signal these methods consume.
  • Nothing but a few examples? Try prompting first. A great deal of what people fine-tune for is a system prompt away.

Failure modes

  • Reward hacking. The reward model is a proxy for human judgement, and optimisers find every gap between the two — length, confidence, flattery, formatting.
  • Alignment tax. Heavy preference tuning can make a model more agreeable and less capable, hedging where it used to answer.
  • Catastrophic forgetting. Fine-tune hard on a narrow task and unrelated abilities degrade. Low learning rates, adapters and mixed data all exist for this.
  • Preference data that disagrees with itself. Two annotators, two answers, no shared rubric. The resulting reward model learns the noise.
  • Evaluating on the reward model. If the reward model is also your evaluation, you have measured the thing you optimised and learned nothing.

Worth remembering

Pretraining supplies knowledge and fluency, supervised fine-tuning supplies behaviour by imitation, and preference optimisation supplies judgement between answers that are all plausible. RLHF and DPO reach the same optimum — a policy proportional to the reference times the exponentiated reward — with DPO skipping the reward model that RLHF has to train and then defend. The beta term is the leash, and slackening it produces exactly the failure you would predict: reward climbs, human ratings fall, and the model drifts into whatever the proxy overrates. None of these stages is a way to teach a model new facts; that is what retrieval is for.

What each stage cannot fix

This is the practically useful part, because it determines which stage to reach for.

Fine-tuning does not reliably add facts. It can be made to memorise, and doing so is inefficient, hard to update, and produces confident errors on anything nearby that was not memorised. Facts belong in retrieval.

Preference training does not add capability. It shapes which of the model's existing behaviours are expressed. A model that cannot do arithmetic will not learn to from preference data.

Neither fixes a knowledge cut-off. Only retrieval or a tool does.

SFT on a narrow task can cause forgetting. Heavy fine-tuning on one domain degrades general ability — the alignment tax. LoRA reduces it, as does mixing general data into the fine-tuning set.

So the decision table most projects need:

GoalApproach
Add current or private factsRAG
Enforce an output formatSFT, or a structured-output constraint
Teach a specialised taskSFT, usually with LoRA
Adjust tone and helpfulnessPreference optimisation
Reduce unwanted responsesPreference optimisation plus system prompting
Get started quicklyPrompting with few-shot examples

Practical guidance

Try prompting first. With few-shot examples and a clear system prompt, a strong model handles a great many tasks without any training. Fine-tuning is a commitment to a pipeline, a dataset and a retraining cadence.

If fine-tuning, use LoRA. A few hundred to a few thousand well-curated examples, adapters rather than full weights, and evaluation against a held-out set that existed before you started.

Data quality dominates quantity. A thousand carefully written examples beat ten thousand scraped ones. The well-known result here is that a small, high-quality instruction set can produce a surprisingly capable assistant.

Preference optimisation is rarely the first move for an application team. It matters when you are shipping a model whose tone and refusal behaviour you own.

Evaluate on what you care about. Fine-tuning improves the target metric and can degrade others. Keep a general capability check alongside the task-specific one.

Questions people ask

RAG or fine-tuning? RAG for facts, currency and citations. Fine-tuning for format, style and task behaviour. They are complementary and frequently used together.

How much data do I need for SFT? A few hundred examples can shift format noticeably; a few thousand for a substantial task change.

Is DPO strictly better than RLHF? Simpler and comparable in most published comparisons. Well-executed PPO still leads on some benchmarks.

What is the alignment tax? The capability lost when tuning for helpfulness and safety. Real, and usually small relative to the gain.

Can I fine-tune a hosted model? Several providers offer it, usually LoRA-based, with your data and their infrastructure.

Does fine-tuning make a model smaller or faster? No — that is distillation or quantisation. Fine-tuning changes behaviour, not size.

Recap in one screen

  • Pretraining gives knowledge, SFT gives format, preference optimisation gives quality and tone.
  • Preference data exists because judging two responses is easier and more reliable than writing an ideal one.
  • RLHF needs a reward model and an RL loop; DPO achieves comparable results with a supervised loss.
  • Fine-tuning does not reliably add facts — use retrieval for that.
  • Try prompting first, then LoRA on a few thousand carefully curated examples.

Recall check

0 of 3

Say the answer out loud before you reveal it — recalling it is what makes it stick, and rereading it is not.

  1. Without scrolling back — what is the one-line takeaway from this module?

  2. What does this module say about “Quick Context”?

  3. What does this module say about “The maths both preference methods share”?

Cheat sheet

Fine-Tuning vs RLHF and DPO

Pretraining decides what a model can say. Supervised fine-tuning decides what it usually says. Preference optimisation decides which of two plausible answers it prefers — and, pushed too hard, which one it degenerates into.

GEN AI · vizlearn.in/gen_ai/fine_tuning_vs_rlhf.html

Further reading

About the author

Ashish Jangra builds and maintains VizLearn. Every module here is written and the visualisation behind it hand-built, so the numbers in a readout come from the same code that draws the picture. Corrections are genuinely welcome and get priority over everything else — if a page states something wrong, or an animation misrepresents what the algorithm does, get in touch.