The DPO loss is a logistic loss on the implicit reward margin. It is the same as the reward-model loss from the reward-modelling question, but applied directly to the policy's log-probabilities.
Implement dpo_loss(logit), returning -log(sigmoid(logit)) in a numerically stable form.
logaddexp to avoid overflow for large magnitudes.The loss equals log(1 + exp(-logit)), which np.logaddexp(0, -logit) computes safely.
No results yet
Run your code to check it against the examples, or submit to run every test.