Jump to content

Connect SuperML | Leeroopedia MCP: Equip your AI agents with best practices, code verification, and debugging knowledge. Powered by Leeroo — building Organizational Superintelligence. Contact us at founders@leeroo.com.

Principle:OpenRLHF OpenRLHF DPO Loss Computation

From Leeroopedia


Knowledge Sources
Domains Alignment, Loss_Functions
Last Updated 2026-02-07 00:00 GMT

Overview

A family of loss functions that optimize language model policies directly from preference data by comparing log-probability ratios between policy and reference models.

Description

DPO Loss Computation implements the core mathematical operation of Direct Preference Optimization. It computes the implicit reward margin between chosen and rejected responses by comparing the log-probability ratios of the policy model against a frozen reference model. The loss encourages the policy to increase the probability of preferred responses relative to the reference.

Three variants are supported: standard DPO, conservative DPO (with label smoothing), and IPO (Identity Preference Optimization with squared loss).

Usage

Used internally by DPOTrainer. The variant is selected via args.ipo (boolean) and args.label_smoothing (float) parameters.

Theoretical Basis

Standard DPO loss: L=logσ(β(logπθ(yw|x)πref(yw|x)logπθ(yl|x)πref(yl|x)))

Conservative DPO (cDPO): Adds label smoothing ϵ: L=(1ϵ)logσ(βΔ)ϵlogσ(βΔ)

IPO: Replaces sigmoid with squared loss: L=(Δ12β)2

where Δ=logπθ(yw|x)πref(yw|x)logπθ(yl|x)πref(yl|x)

Related Pages

Implemented By

Page Connections

Double-click a node to navigate. Hold to expand connections.
Principle
Implementation
Heuristic
Environment