★ Reading this for free? Get 25 structured AI courses + per-chapter AI tutor — the first chapter of every course free, no card.Start free in 30 secondsOr own every course: $149 once
Training

DPO vs KTO vs ORPO: Preference Fine-Tuning for Local LLMs

May 1, 2026
18 min read
Barsha Mohapatra

Want to go deeper than this article?

Free account unlocks the first chapter of all 25 courses — RAG, agents, MCP, voice AI, MLOps, real GitHub repos.

📚AI Learning Path

Go from reading about AI to building with AI 25 structured courses. Hands-on projects. Runs on your machine. Start free.

Start free
Or own it for life — Lifetime $149, pay once

DPO, ORPO and KTO all align a model to preferences without RLHF's separate reward model and PPO loop. They differ in the data they need and the number of training stages. Quick answer: use DPO if you already have an SFT model and paired preferences, ORPO if you are starting from a base model with paired preferences, and KTO if your feedback is thumbs-up/thumbs-down rather than pairs.

DPO vs KTO vs ORPO at a Glance

DPOORPOKTO
PaperRafailov et al., May 2023Hong et al., March 2024Ethayarajh et al., February 2024
DataPairs: prompt, chosen, rejectedPairs: prompt, chosen, rejectedUnpaired: prompt, completion, good/bad label
SFT step first?YesNo — SFT and preference in one stageYes, usually
Reference modelYes (frozen copy of the starting model)NoYes
What the paper reportedExceeds PPO-based RLHF at controlling sentiment; matches or improves response quality in summarization and single-turn dialoguePhi-2, Llama-2 7B and Mistral 7B trained on UltraFeedback alone reach up to 12.20% on AlpacaEval 2.0, 66.19% on IFEval (instruction-level loose) and 7.32 on MT-BenchMatches or exceeds preference-based methods at scales from 1B to 30B, from only a binary desirable/undesirable signal
TRL class (Nov 2026)trl.DPOTrainertrl.experimental.orpo.ORPOTrainertrl.KTOTrainer
Pick it whenYou have an SFT checkpoint and pairsYou start from a base model and want one stageYour feedback is thumbs up/down or A/B outcomes

Results are each paper's own claims, from the abstracts. They were measured on different models and benchmarks, so they are not a head-to-head ranking.

What changed since these papers (SimPO and GRPO)

  • SimPO (Meng et al., May 2024) drops the reference model and uses the length-normalized log-probability as the reward. Its authors report it beats DPO by up to 6.4 points on AlpacaEval 2 and 7.5 on Arena-Hard. TRL's DPO trainer exposes SimPO-style length normalization as loss_type="sigmoid_norm".
  • GRPO (DeepSeekMath, February 2024) is online reinforcement learning without a critic model: it samples a group of answers per prompt and scores each against the group. DeepSeek used it to train DeepSeek-R1, and it is now the usual choice when answers can be checked automatically (maths, code, tool calls). TRL ships it as GRPOTrainer.
  • Rule of thumb: offline preference data about style, tone or helpfulness → DPO, ORPO or KTO. Verifiable right/wrong answers and a reward function → GRPO.

By 2026 all three are standard tools in local fine-tuning pipelines. They share a common goal — align the model to your preferences — but use different mathematical formulations and dataset assumptions. Updated November 2, 2026: decision table with paper-cited results, TRL code for the current API, and the SimPO/GRPO note above.

This guide covers everything: the math behind each method (skipping RLHF's reward-model + PPO complexity), dataset formats, when to use which, integration with QLoRA via TRL and Axolotl, hyperparameter tuning, common failure modes, and concrete recipes for aligning Llama 3.1 8B to a specific brand voice or domain style.

Reading articles is good. Building is better.

Free account = the first chapter of all 25 courses, with a per-chapter AI tutor. No card.

Table of Contents

  1. DPO vs KTO vs ORPO at a Glance
  2. Why Preference Fine-Tuning Matters
  3. The RLHF Pipeline (and Why It Was Replaced)
  4. DPO: Direct Preference Optimization
  5. ORPO: Unified SFT + Preference
  6. KTO: Unpaired Preference Signals
  7. Choosing DPO vs ORPO vs KTO
  8. Dataset Format and Sources
  9. TRL Integration
  10. Axolotl Integration
  11. Hyperparameter Tuning
  12. QLoRA + DPO/ORPO/KTO
  13. Evaluating Preference-Tuned Models
  14. Alignment Tax and Mitigations
  15. Common Failures
  16. FAQ

Why Preference Fine-Tuning Matters

Standard SFT (supervised fine-tuning) teaches a model to imitate target outputs. But often you have multiple acceptable responses with quality differences — and you want the model to learn which is better, not just which appeared in your training set.

Preference fine-tuning operationalizes "better than": train the model to assign higher probability to preferred responses than rejected ones.

Use cases:

  • Style adaptation (brand voice, formality, humor)
  • Helpfulness vs harmlessness trade-offs
  • Refusal behavior tuning
  • Domain-specific quality (medical accuracy, legal citation style)
  • A/B test winning patterns

The RLHF Pipeline (and Why It Was Replaced)

Classical RLHF (used by InstructGPT, ChatGPT, early Llama 2 chat):

Step 1: SFT on demonstrations
Step 2: Train a reward model on preference pairs
Step 3: Use PPO reinforcement learning to optimize policy against reward model

Problems: PPO needs the policy, a reference model, a reward model and a value model in memory at once, samples from the model during training, is sensitive to hyperparameters, and is prone to reward hacking.

DPO showed that the reward model and PPO step can be eliminated — directly optimize the policy on preferences via a closed-form loss. Offline preference tuning of open-weight models is now mostly DPO and its variants; online RL came back for reasoning in the form of GRPO (see the note at the top).


Own it instead of renting it

Run this on your own machine and stop paying every month

Pay once and keep it. No renewal, no per-token bill, and nothing you feed it ever leaves your hardware.

DPO: Direct Preference Optimization

The DPO loss for a preference pair (prompt x, chosen y_w, rejected y_l):

L_DPO = -log σ(β · log π(y_w|x)/π_ref(y_w|x) - β · log π(y_l|x)/π_ref(y_l|x))

Where π is the model being trained, π_ref is a frozen reference (typically the SFT checkpoint), and β controls deviation magnitude.

Intuition: increase the log-probability of chosen responses relative to rejected, weighted against the reference model. β=0.1 is the typical default.

Pipeline:

  1. SFT on demonstrations (gives π_ref)
  2. DPO on preference pairs (yields aligned π)

ORPO: Unified SFT + Preference

ORPO (Hong et al., March 2024) unifies SFT and DPO into a single loss:

L_ORPO = L_SFT(y_w) + λ · L_OR(y_w, y_l)

Where L_SFT is standard SFT loss on chosen responses, and L_OR is an odds-ratio loss penalizing rejected responses. λ controls the strength of preference signal.

Result: skip the SFT-then-DPO two-stage pipeline and the reference model. Train once, get both. The paper's headline: Phi-2, Llama-2 7B and Mistral 7B trained this way on UltraFeedback alone reach up to 12.20% on AlpacaEval 2.0 and 7.32 on MT-Bench. In TRL the λ weight is the beta argument of ORPOConfig (default 0.1).

Use ORPO when starting from a base (non-SFT) model. Use DPO when you already have an SFT checkpoint.


KTO: Unpaired Preference Signals

KTO (Ethayarajh et al., 2024) handles binary feedback without paired comparisons:

L_KTO = E[w_y · σ(β · (log π(y|x)/π_ref(y|x) - z_ref))]

Where w_y is +1 for "good" responses, -1 for "bad", and z_ref is a baseline. Loss derived from Kahneman-Tversky prospect theory (loss-aversion modeling).

Useful when:

  • You have user thumbs-up/thumbs-down without paired comparisons
  • A/B test outcomes (winner / loser of single response shown)
  • Automated quality classifier scores
  • Larger datasets of unpaired feedback than paired

The KTO paper reports it matches or exceeds preference-based methods at scales from 1B to 30B. TRL can also convert a paired dataset into KTO format automatically (chosen → desirable, rejected → undesirable).


Choosing DPO vs ORPO vs KTO

ScenarioMethod
Existing SFT checkpoint + paired preferencesDPO
Base model + paired preferences (no SFT done)ORPO
Unpaired feedback (thumbs up/down, A/B)KTO
Very small preference dataset (<500 pairs)DPO with high β
Large unpaired dataset (>10K examples)KTO
Want simplest pipelineORPO

Dataset Format and Sources

DPO / ORPO format:

{
  "prompt": "What is local AI?",
  "chosen": "Local AI is...",
  "rejected": "Local AI is some thing..."
}

KTO format (TRL field names):

{"prompt": "What is local AI?", "completion": "Local AI is...", "label": true}
{"prompt": "What is local AI?", "completion": "Local AI is some thing...", "label": false}

Both formats also accept conversational messages (lists of role/content dicts); TRL applies the chat template for you.

Sources:

  • HH-RLHF (Anthropic) — helpfulness/harmlessness pairs
  • UltraFeedback — broad preference pairs
  • OpenAssistant — community-rated responses
  • Synthetic AI judge: generate 2 responses, ask GPT-4o/Claude which is better
  • Production logs with thumbs-up/down (KTO)
  • Manual annotation for brand voice / specific tone

For most domain adaptation, AI-judge synthetic pairs are the cheapest practical route; spot-check a sample by hand before training.


TRL Integration

Current TRL (checked against the main-branch docs, November 2, 2026). The tokenizer is passed as processing_class (the old tokenizer= argument is gone), and ref_model is optional — if you omit it, TRL uses the starting model as the reference.

from datasets import load_dataset
from peft import LoraConfig
from trl import DPOConfig, DPOTrainer

dataset = load_dataset("trl-lib/ultrafeedback_binarized", split="train")

trainer = DPOTrainer(
    model="Qwen/Qwen3-0.6B",          # or your SFT checkpoint
    args=DPOConfig(
        output_dir="./dpo_output",
        beta=0.1,
        learning_rate=1e-5,           # TRL's tip for LoRA adapters; ~1e-6 for full fine-tuning
        num_train_epochs=1,
        per_device_train_batch_size=2,
        gradient_accumulation_steps=4,
    ),
    train_dataset=dataset,
    peft_config=LoraConfig(),         # drop this line for full fine-tuning
)
trainer.train()

ORPO now lives in TRL's experimental module:

from trl.experimental.orpo import ORPOConfig, ORPOTrainer

trainer = ORPOTrainer(model=model, args=ORPOConfig(output_dir="./orpo_output", beta=0.1),
                      processing_class=tokenizer, train_dataset=dataset)

KTO uses the unpaired format and its own config:

from trl import KTOConfig, KTOTrainer

trainer = KTOTrainer(model="Qwen/Qwen3-0.6B",
                     args=KTOConfig(output_dir="./kto_output", per_device_train_batch_size=4),
                     train_dataset=load_dataset("trl-lib/kto-mix-14k", split="train"))

Axolotl Integration

base_model: meta-llama/Meta-Llama-3.1-8B-Instruct
adapter: qlora
load_in_4bit: true
lora_r: 32
lora_alpha: 64

rl: dpo                       # or orpo, kto
dpo_beta: 0.1
datasets:
  - path: ./preferences.jsonl
    type: chatml.intel
    split: train

learning_rate: 5e-7
num_epochs: 1
micro_batch_size: 2
gradient_accumulation_steps: 4
accelerate launch -m axolotl.cli.train dpo.yml

Hyperparameter Tuning

ParameterDPOORPOKTO
Learning rate1e-6 default (full); ~1e-5 for LoRA adapters1e-6 TRL default5e-7 to 5e-6; at most ~1e-6 with β=0.1
β0.1 default; higher = stay closer to referencen/a0.1 default
λ (ORPO, beta in TRL)n/a0.1 defaultn/a
Batch sizeAnyAnyPer-device ≥ 4, effective 16-128 (TRL guidance)
Epochs1-21-31-2

Defaults and ranges from the TRL documentation for each trainer. For KTO with imbalanced data, set desirable_weight / undesirable_weight so the weighted ratio of positives to negatives lands between 1:1 and 4:3.

Lower learning rates than SFT! Preference fine-tuning is sensitive — too high LR causes catastrophic forgetting.


QLoRA + DPO/ORPO/KTO

Combining 4-bit quantized base with preference fine-tuning:

# Axolotl
adapter: qlora
load_in_4bit: true
lora_r: 32
lora_alpha: 64
rl: dpo
dpo_beta: 0.1

Memory: similar to QLoRA SFT. Time: longer than SFT on the same data, because DPO scores both the chosen and the rejected response and also needs reference log-probabilities (TRL can precompute them with precompute_ref_log_probs=True to save memory). With LoRA, TRL uses the base model with the adapter switched off as the reference, so no second copy is loaded.

How long a run takes depends on model size, number of pairs, sequence length and GPU; run 50 steps first and extrapolate.


Evaluating Preference-Tuned Models

Three evaluation axes:

  1. Held-out preference accuracy: does the model prefer chosen over rejected on held-out pairs?
  2. General benchmark regression: re-run MMLU / HumanEval / GSM8K and compare against the starting model; any clear drop is the alignment tax
  3. Qualitative: spot-check 50-100 outputs by hand

For brand voice / style adaptation: human evaluation matters more than benchmarks. Have target users rate 30-50 outputs blind vs the SFT-only model.


Alignment Tax and Mitigations

Preference fine-tuning often degrades unrelated capabilities — the "alignment tax." Mitigations:

  1. Higher β (0.3-0.5) — limits deviation from reference
  2. Fewer epochs (1-2 max)
  3. Mix in SFT data — 30-50% general SFT examples in the training mix
  4. Smaller LoRA rank — limits capacity for over-specialization
  5. Regular evaluation on out-of-domain benchmarks during training

Common Failures

SymptomCauseFix
Catastrophic forgettingLR too highDrop to 5e-7
No preference learningβ too high or LR too lowLower β to 0.05 or raise LR
Model becomes verbose / over-confidentOver-trainingFewer epochs, smaller dataset
Rejected responses still preferredBad dataRe-curate preference dataset
OOM with reference modelTwo models in memoryUse model_adapter_name=None for adapter-only DPO

FAQ

See answers to common DPO/ORPO/KTO questions below.


Sources: DPO paper (Rafailov et al., 2023) | ORPO paper (Hong et al., 2024) | KTO paper (Ethayarajh et al., 2024) | SimPO paper (Meng et al., 2024) | DeepSeekMath / GRPO (Shao et al., 2024) | TRL DPO, ORPO and KTO docs | HuggingFace TRL | Axolotl.

Related guides:

🎯
AI Learning Path

Go from reading about AI to building with AI

25 structured courses. Hands-on projects. Runs on your machine. Start free.

Or own it for life — Lifetime $149 $599, pay once

Liked this? 25 full AI courses are waiting.

From fundamentals to RAG, agents, MCP servers, voice AI, and production deployment with real GitHub repos. First chapter free, every course.

Reading now
Join the discussion
Tagsdpoorpoktopreference fine-tuningrlhf alternativealignmenttrlaxolotl

Barsha Mohapatra

Local AI Master writes hands-on courses and hardware guides for running AI on machines you own. Content is checked against current releases and corrected when readers tell us it is wrong.

Build Real AI on Your Machine

RAG, agents, NLP, vision, and MLOps - chapters across 25 courses that take you from reading about AI to building AI.

Want the structured version?

Hands-on courses on local AI, from $8.99 a month. The first chapter of each is free.

AI Learning Path

Comments (0)

No comments yet. Be the first to share your thoughts!

📅 Published: May 1, 2026🔄 Last Updated: November 2, 2026✓ Manually Reviewed

Bonus kit

Ollama Docker Templates

10 one-command Docker stacks. Includes QLoRA-DPO preference fine-tuning reference deploy. Included with paid plans, or free after subscribing to both Local AI Master and Little AI Master on YouTube.

See Plans →

Build Real AI on Your Machine

RAG, agents, NLP, vision, and MLOps - chapters across 25 courses that take you from reading about AI to building AI.

Was this helpful?

Barsha Mohapatra

Written by

Barsha Mohapatra

Founder and Editor, Local AI Master · Founder, Little AI Master

Founder of Little AI Master and the editor behind every course and guide on Local AI Master. Years of tutoring students taught her where AI education actually fails.

📚
Free · no account required

Grab the AI Starter Kit — career roadmap, cheat sheet, setup guide

No spam. Unsubscribe with one click.

🎯
AI Learning Path

Go from reading about AI to building with AI

25 structured courses. Hands-on projects. Runs on your machine. Start free.

Or own it for life — Lifetime $149 $599, pay once
Free Tools & Calculators