Resources/Model training/Training methods

Metric

Reading the DPO loss

The DPO loss measures how clearly the model now prefers the better answer in each pair, relative to where it started. It begins at ln 2 ≈ 0.693 and falls toward 0 as the preference is learned.

Chapter 74 min read4 references

What it is

During a preference run the trainer reports a loss, per step or per epoch, and sometimes on held-back pairs too. It answers one question: on average, how confidently does the model's implicit reward rank the preferred answer above the non-preferred one, compared with where the model started?

It looks like a supervised loss but does not mean the same thing. Supervised loss is cross-entropy over tokens and can start anywhere, often above 1. DPO loss is a per-pair classification loss with a fixed starting value and a floor of 0. The two are not comparable.

Why it starts at 0.693

At the first step, the model being trained and the reference model are identical. Every log-ratio is 0, so every margin is 0, σ(0) = 0.5 and the loss is −ln 0.5 = ln 2 ≈ 0.693: the loss of a coin flip. That holds for every dataset and every model, which makes it a useful sanity check. The first logged values should sit at or just below 0.69; a start far from it usually means the reference is not the starting model, or a different loss variant is in use.

Step 0
step 0:  model = reference
         every log-ratio = 0  →  margin = 0
         loss = −ln σ(0) = −ln 0.5 = ln 2 ≈ 0.693

The shapes to recognise

0.690.30START: LN 2 ≈ 0.693training steps →barely movedlearningtoo easy?
Every DPO run starts at ln 2 ≈ 0.693, the loss of a coin flip. What happens next tells you whether the pairs are teaching anything, and whether they are too easy.
What you seeWhat it usually meansWhat to do
Stays around 0.6–0.7The pairs barely changed the model. Common with few pairs, or when the two answers differ only slightly.Add pairs and make the difference between answers clearer; only then consider a lower β or another epoch.
Falls steadily, e.g. to 0.3The model is learning the preference.Evaluate against the starting model to check that answers really improved.
Drops to near 0 very fastThe pairs are too easy (the worse answer is obviously bad), or the model is memorising them.Use more varied or harder pairs, fewer epochs, or a higher β.
Climbs above 0.69On average the model now ranks the pairs the wrong way round, compared with where it started.Check that preferred and non-preferred are not swapped; lower the learning rate.

Translating the numbers

Because the loss for a pair is −ln σ(β × margin), each value corresponds to a level of agreement between the model and the label:

Lossσ: agreement with the labelβ × margin
0.6930.50 (coin flip)0
0.510.600.4
0.300.741.05
0.100.902.25
0.010.994.6

The reported loss is an average over pairs, so a middling value can hide a split: most pairs learned well and a few ranked the wrong way. That is why trainers often report preference accuracy (the share of pairs ranked the right way) and the average reward margin alongside it.

An average that hides a split
  1. Four pairs end training with β × margin of 2.0, 2.0, 2.0 and −1.0.
  2. Their losses are 0.13, 0.13, 0.13 and 1.31.
  3. The average is 0.42, which reads as moderate progress. In fact three pairs are learned and one is firmly ranked the wrong way. That pair is worth reading: it may be mislabelled.

What the loss cannot tell you

  • Whether answers improved. The loss is computed on fixed pairs, not on answers the model writes. A model can separate your pairs perfectly and still answer new questions worse.
  • Which way the probabilities moved. The loss falls if the rejected answer becomes less likely, even when the chosen one does too. Researchers have found the chosen answer's likelihood often decreases during DPO (“likelihood displacement”), and the TRL docs note the gap is typically widened more by suppressing rejected answers than by raising preferred ones.
  • Whether overfitting hurts. In the Zephyr report the DPO step overfit strongly after one epoch (perfect training-set accuracy), yet that did not harm benchmark results, and the best model came from three DPO epochs. When the supervised model had been trained for more than one epoch, though, longer DPO training caused a regression. The training curves could not tell those cases apart; evaluations did.

Token accuracy, shown for supervised runs, is not a measure of preference learning, so it is not shown for DPO.

Common mistakes

  • Comparing a DPO loss with a supervised loss. Different formulas, different scales.
  • Comparing DPO losses across runs with different β.
  • Celebrating a loss near 0. With few or easy pairs it is the expected result, and often a sign of memorising.
  • Missing swapped labels. A loss that climbs above 0.69 usually means the preferred and non-preferred sides were reversed somewhere.
  • Stopping at the curve. Only an evaluation against the starting model shows whether answers improved.

References and further reading

External sources open in a new tab.

  1. 01Direct Preference Optimization: Your Language Model is Secretly a Reward ModelRafailov et al., 2023 · arXiv · arxiv.orgDefines the loss and explains how its gradient weights each pair.
  2. 02DPO TrainerHugging Face TRL docs · huggingface.coLists what a DPO trainer logs: loss, implicit rewards, margins and accuracies.
  3. 03Unintentional Unalignment: Likelihood Displacement in Direct Preference OptimizationRazin et al., 2024 · arXiv · arxiv.orgWhy the preferred answer's likelihood can fall during DPO, and which pairs cause it.
  4. 04Zephyr: Direct Distillation of LM AlignmentTunstall et al., 2023 · arXiv · arxiv.orgA worked SFT-then-DPO run, including what overfitting the DPO step did and did not do.

Turn weeks of expert work into minutes

See how Scalata fits your team, your data, and your controls.