Prefer to DPO: What was optimized when comparing two responses
The logarithmic, loss and gradient of DPO is calculated over time from pair preferences and reference strategies, and the length, labelling and evaluation deviations are checked.
Learning objectives and first steps3 objectives • 3 first fixes
Try to do it after reading
- Distinguishing oversight fine-tuning, incentives for modelling and pairing preferences
- Hand-held margin, loss and guidance for DPO
- Check the consistency of preferred data, templates and reference strategies
Suggested first
- Conditional probability is the same as the sequence logarithm
- Sigmoid, cross entropy and gradient
- Training and verification isolation
"What answer is more appropriate" how to turn into a training signal
(b) Give the same question and answer A with possible clear source, conciseness and compliance; The answer to B was smooth, but the key condition was missing. Supervising the fine-tuning of a model as a target text; The preference for data records the relative choice between two responses. The latter does not automatically indicate that the answer chosen is perfect, but rather that it is more favoured under the current conditions of questions, guidelines and labelling.
A basic sample contains a hint for x, selected for yw and unselected for yl. The training should be preceded by clear criteria for comparison: facts, level of assistance, format, risk boundaries or style. If these dimensions are mixed into an unexplained success, models may learn to be “more and better” or “more confident”. This chapter explains the objectives of DPO with a fixed probability, does not train authentic language models, nor does it treat preference promotion as sufficient evidence of factual correctness.
From reference strategy to relative improvement
Let πθ be the trainable policy and πref the frozen reference. For the same prompt, evaluate both complete answers' conditional probabilities. Sum log probabilities over valid answer tokens instead of multiplying tiny probabilities, using consistent prompt, padding and template masks. The reference measures change from prior behavior, not a correct-answer distribution.
DPO uses two logarithmic differences to indicate how much improvement the reference model has been given to the selected answer as compared to the unselected answer. Multiply beta, via sigmoid, using positive and negative logarithm losses.DPO original paper (a) The linkage between incentive optimization and preference models with KL; This relies on modelling assumptions and does not capture all rewards or all human values.
Count a couple of synthetic answers
Reference probabilities are 0.2 and 0.1; current probabilities are 0.3 and 0.05. They need not sum to one because other answers exist. Log ratios are log1.5≈0.405465 and log0.5≈−0.693147, giving Δ≈1.098612=log3. With β=0.2, margin≈0.219722, preference probability≈0.554711 and loss≈0.589309.
If policy initially equals reference, Δ=0 and loss=log2≈0.693147. A lower current loss only means this pair's relative probabilities align with the preference. It guarantees neither higher absolute generation probability of the chosen answer nor better other-task performance. Both probabilities can fall while the unchosen one falls faster, increasing Δ.
The logical pair is beta (scow)-1; this example is about 0.08905058. The gradient drops, which tends to increase the thugs. Beta is also present in model interpretation and optimization scales, and it is not appropriate to summarize actual training results with an isolated slogan such as “the larger the more conservative”; Learning rates, data, length of training and deviation from reference levels need to be monitored together. When the same platinum is fixed, beta = 1 receives losses of about 0.287682, but this does not prove to be better than complete training after the change to beta = 1.
Data is easier to make error than the loss formula
If chosen and rejected come from different tips, model learning is not a relative preference for the same subject. If the two sides have different chat templates, the boundary symbol itself will also be a signal. The probability of a long answer sequence involves more items, and the length deviations and interruptions must be examined exclusively; The sequence and conversion to token are not allowed to be called the original DPO. There should be rules for dealing with flat, uncertain or label conflicts, and repeated reminders should be split into groups to prevent leaks of the same subject to the validation set.
InstructGPT dissertation (a) To provide a historical route of demonstration, preference and incentive optimization, which is suitable for different stages; This chapter does not repeat its model ranking.DPO document for TRL To check the data format with the current realization options. It is a dynamic page that fixes a version and checks default losses, reference models and cut-off settings before being used, and the pure arithmetical example here cannot be considered a tested training configuration.
import mathlog_ratio_w = math.log(.3) - math.log(.2)log_ratio_l = math.log(.05) - math.log(.1)delta, beta = log_ratio_w-log_ratio_l, .2margin = beta*deltaloss = max(0., -margin) + math.log1p(math.exp(-abs(margin)))grad_delta = beta*(1/(1+math.exp(-margin))-1)print(delta, margin, loss, grad_delta)# 1.098612..., 0.219722..., 0.589308..., -0.089057...Standard Python is implemented and a stable softplus is written to avoid a significant negative margin time overflow. In diagnostic training, the logarithmic probabilities on both sides, relative to margin, length, reference deviations and the factual quality of the task shall be recorded, in addition to the loss. The continuous increase in the training set margin and the decline in the quality of independence may be an over-programming model that cannot automatically be interpreted as progress with more training steps.
Calculating from Sequence Probability to Dial token
Assuming that only two targets are selected, token, the probabilities are in order of zero-five and zero-six, and the entire probabilities are zero-three; The two probability answers were zero one and zero five, and the whole paragraph was zero five. This corresponds to the preceding figures, but should be more likely to add logarithms to the real long-term responses to avoid a spillover. The two answers may vary in length and cannot be filled to the same length to turn padding into effective supervision.
It is also possible to check whether the reference model is actually frozen: if the reference probability changes with the current optimization steps, the target changes. This may be the case for shared weights, fit-in switches or erroneous training models. A fixed text pair at validation, recording the probability of reference logarithms before and after training and checking whether random dropout affects comparisons; It also ensures that the selection is fully consistent with the unselected reminder and does not include an extra endpoint on one side.
Check understanding
The probability of being selected is zero-three and not zero-five, why not one?
They are two events in the complete answer space of the language model, while the other answers also account for the probabilistic quality; The alternative probability in the preferred model is defined by another sigmoid and cannot be mixed.
The initial strategy is a reference. What are the losses?
Both logarithms are zero, margin zero, sigmoid one in two, so the negative logarithm is log2. This baseline facilitates checking of initialization and mask consistency.
The absolute probability of margin becoming larger, and chosen increasing?
Not necessarily. Unopportunity may decline more rapidly. The probabilities and actual generation quality of logarithms on both sides should be seen separately and not only relatively poor.
What happens when you write chosen?
The gradient systematically drives the wrong direction. A small number of manual checks, labelling guidelines and hard review are more likely to detect such problems than simply observing loss, as errors can also be well drawn up.
Could the longer answer be preferred to the longer version of the text?
Can't. Length may be mixed with information quality. It is necessary to measure the length of the cut, exchange the location of the display, clarify the criteria for the mark and check whether the cut is asymmetric.
Does DPO guarantee that all facts are correct and that no border crossings will take place?
There is no such guarantee. It optimizes the relative preferences of the given data and assumptions; Fact-checking, competency control and deployment assessment remain the responsibility of an independent process.
Nuclear for 2026-10-29, DPO Adoption arXiv v3 , InstructGPT Yes. v1 , not installed or executed TRL 。 Next Decoding and KV Cache, distinguishing between training objectives and actual generation.
Sources and reconciliations
Definitions, methods and interfaces are available.
- Direct Preference Optimization — Your Language Model is Secretly a Reward Model
- Training language models to follow instructions with human feedback
- Hugging Face TRL — DPO Trainer
Figures and calculations are reorganized according to this chapter. Mathematical measurements, framework operations and real business effects are described separately in the body of the text.