How does ORPO perform SFT and alignment in a single step without reference models?
Advanced · 2 min read · Fine-Tuning & Adaptation
Open in study mode to save this question and track progressShort answer: ORPO (Monolithic Odds Ratio Preference Optimization) combines Supervised Fine-Tuning (SFT) cross-entropy loss with an odds ratio penalty term in a single unified loss function, aligning model preferences toward winning completions without requiring a separate reference model or dedicated DPO/RLHF phase.
Detail
Traditional preference alignment requires a 2-stage pipeline:
- Stage 1: Supervised Fine-Tuning (SFT) on target dataset.
- Stage 2: Preference alignment (DPO or RLHF), requiring loading both policy model and frozen reference model into GPU memory simultaneously.
Standard 2-Stage DPO: SFT Training ──► Save Checkpoint ──► Load Policy + Reference Models into VRAM ──► DPO Loss ORPO Single-Stage: Raw Base Model ──► Monolithic ORPO Loss (SFT Loss + Odds Ratio Penalty) ──► Aligned Model
The ORPO Loss Function
Where:
- is standard negative log-likelihood on favored completions .
- is the log odds ratio between winning and losing completions:
Example
PyTorch implementation concept for ORPO Loss:
python
import torch
import torch.nn.functional as F
def orpo_loss(policy_chosen_logps, policy_rejected_logps, sft_loss, lambda_or=0.1):
# Calculate log odds ratio
log_odds_chosen = policy_chosen_logps - torch.log1p(-torch.exp(policy_chosen_logps))
log_odds_rejected = policy_rejected_logps - torch.log1p(-torch.exp(policy_rejected_logps))
log_odds_ratio = log_odds_chosen - log_odds_rejected
or_loss = -F.logsigmoid(log_odds_ratio).mean()
# Unified monolithic loss
total_loss = sft_loss + lambda_or * or_loss
return total_lossInterview tips
- Emphasize memory efficiency: ORPO eliminates the reference model, saving ~50% GPU VRAM during preference alignment compared to DPO.
- Highlight that ORPO prevents preference alignment degradation while accelerating training throughput.
Related Concepts
- [[What is dataset formatting for instruction tuning (Alpaca vs ShareGPT formats)?]] (
#141): What is dataset formatting for instruction tuning (Alpaca vs ShareGPT formats)? - [[How does DoRA (Weight-Decomposed Low-Rank Adaptation) improve directional weight updates over LoRA?]] (
#146): How does DoRA (Weight-Decomposed Low-Rank Adaptation) improve directional weight updates over LoRA? - [[What is human evaluation (RLHF human rating) and how do you design annotation rubrics?]] (
#175): What is human evaluation (RLHF human rating) and how do you design annotation rubrics?