Papers › Direct Preference Optimization: Your Language Model is Secretly a Reward Model

Direct Preference Optimization: Your Language Model is Secretly a Reward Model

29 May 2023NeurIPS 2023 11arXiv:2305.18290archive 2025-07-28

Rafael Rafailov, Archit Sharma, Eric Mitchell, Stefano Ermon, Christopher D. Manning, Chelsea Finn

While large-scale unsupervised language models (LMs) learn broad world knowledge and some reasoning skills, achieving precise control of their behavior is difficult due to the completely unsupervised nature of their training. Existing methods for gaining such steerability collect human labels of the relative quality of model generations and fine-tune the unsupervised LM to align with these preferences, often with reinforcement learning from human feedback (RLHF). However, RLHF is a complex and often unstable procedure, first fitting a reward model that reflects the human preferences, and then fine-tuning the large unsupervised LM using reinforcement learning to maximize this estimated reward without drifting too far from the original model. In this paper we introduce a new parameterization of the reward model in RLHF that enables extraction of the corresponding optimal policy in closed form, allowing us to solve the standard RLHF problem with only a simple classification loss. The resulting algorithm, which we call Direct Preference Optimization (DPO), is stable, performant, and computationally lightweight, eliminating the need for sampling from the LM during fine-tuning or performing significant hyperparameter tuning. Our experiments show that DPO can fine-tune LMs to align with human preferences as well as or better than existing methods. Notably, fine-tuning with DPO exceeds PPO-based RLHF in ability to control sentiment of generations, and matches or improves response quality in summarization and single-turn dialogue while being substantially simpler to implement and train.

PaperPDFConference PDFCodeCode Syntology ran

In Syntology Open this paper in Syntology's Atlas, the map of the papers in Syntology's graph and their citations.

For agents, Syntology's MCP tool lists every function and class Syntology harvested from this paper and whether it ran (how to connect): get_harvested_code_for_paper(arxiv_id="2305.18290")

Code

Syntology Ran 6 of 31 code samples harvested from 7 repositories linked to this paper; 25 have no recorded run. Of those that ran: 1 ran · fixture could not drive it; 5 ran with no contract checked.

By repository: community (archive-listed): 31 samples from 7 repositories, 6 ran. The run record, sample by sample. “Ran” means executed on a synthesized input, not that the code is correct or reproduces the paper.

29 repositories listed; official and paper-mentioned ones first.

12kimih/hicupid mentioned on GitHubpytorchApache-2.0 report
TU2021/DPO-VP mentioned on GitHubpytorch report
babelscape/alert mentioned on GitHubpytorchNOASSERTION report
davidkim205/komt mentioned on GitHubpytorchApache-2.0 report
eric-mitchell/direct-preference-optimization mentioned on GitHubpytorchApache-2.0 report
frankxwang/dpo-prefix-sharing mentioned on GitHubpytorch report
huggingface/trl mentioned on GitHubpytorch report
icip-cas/Word-Deed-Consistency-Test mentioned on GitHubpytorch report
imagination-research/lbt mentioned on GitHubMIT report
internlm/xtuner mentioned on GitHubpytorch report
kidist-amde/ddro mentioned on GitHubpytorch report
lucidrains/self-rewarding-lm-pytorch mentioned on GitHubpytorchMIT report
lujunru/sampo mentioned on GitHubpytorchMIT report
lvwerra/trl mentioned on GitHubpytorchApache-2.0 report
padlex/trl mentioned on GitHubpytorchApache-2.0 report
sauc-abadal/alt mentioned on GitHubpytorch report
shibing624/medicalgpt mentioned on GitHubpytorchApache-2.0 report
sunzeyeah/rlhf mentioned on GitHubpytorch report
tatsu-lab/alpaca_farm mentioned on GitHubpytorchApache-2.0 report
uppaal/detox-edit mentioned on GitHubpytorchMIT report
wangclnlp/deepspeed-chat-extension mentioned on GitHubpytorchApache-2.0 report
yifan-song793/eto mentioned on GitHubpytorch report

Repository list and official/mentioned flags are the archive's, frozen 2025-07-28. Reachability, where shown, is from one Syntology probe window (2026-09-16 to 2026-09-18); repositories not probed show nothing. GitHub stars are not tracked.

Code Syntology ran Syntology

31 samples harvested; 6 ran; 0 honoured the contract we drafted; 25 have no recorded run. Read from Syntology's graph 2026-09-24; that is when this build read the record, not when the samples ran.

1ran · fixture could not drive it
5ran
25unverified

Licence: 2 of the 31 samples are pointer only, meaning Syntology does not serve that copy's text. This page shows no code text for any sample; each one links to its file in the repository.

Harvested from 7 repositories linked to this paper, official or community; each sample names its own and says which. “Ran” means the sample executed on a synthesized input. It does not mean the output is correct, and nothing here reproduces the paper's results. “Honoured” and “violated” refer to a contract Syntology drafted from the code itself; “our draft was wrong” and “fixture could not drive it” are failures of Syntology's instrument, not of the code.

Each sample ends with its code_sha256, Syntology's identity for that exact code. An agent fetches the stored sample with Syntology's MCP tool get_code(code_sha256="…") (how to connect); click an identity to copy that call.

Repository labels, per sample. official repository: The archive marks this repository official for the paper. named in the paper: The archive records that the paper mentions this repository; it is not marked official. community (archive-listed): In the archive's code links for this paper, not marked official and not recorded as mentioned in the paper. found in paper text by Syntology: Syntology found this repository in the paper's own text; whether it is the authors' implementation is not asserted. community: Not in the archive's code links for this paper; a community repository Syntology harvested. Samples from a repository marked official are listed first. Licence labels name the repository's licence as recorded at harvest. “Pointer only” means Syntology does not serve that copy's text, for one of four reasons: no licence file was found; the licence was not identified; the licence is recorded as permissive but that copy's record is not marked cleared; or the licence is outside the permissive list Syntology serves text under (MIT, Apache-2.0, BSD and similar). Some licences outside that list permit redistribution, such as WTFPL, and GPL-3.0 under its conditions; they are simply not on the list. Hover a licence label for the reason. File links open the file on GitHub at the default branch, which may have changed since the harvest.

DPO OctopusMind/DPO/dpo.py community (archive-listed) ran Apache-2.0 (permissive) · be7453ec96f94038 · report
PairWiseLoss sunzeyeah/rlhf/src/models/loss.py community (archive-listed) ran · metamorphic tier: invariant fingerprinted no licence file found · pointer only · d69bfa3e1e60a92b · report
Policy sauc-abadal/alt/alt/trainer/alt_trainer.py community (archive-listed) ran MIT (permissive) · 0a800ad29eb472ac · report
convert_state_dict padlex/trl/trl/models/sd_utils.py community (archive-listed) ran Apache-2.0 (permissive) · 8f1ce89b816a0734 · report
preference_loss icip-cas/Word-Deed-Consistency-Test/dpo/trainers.py community (archive-listed) ran · fixture could not drive it fingerprinted no licence file found · pointer only · c79211fc0225a27f · report
top_k_top_p_filtering padlex/trl/trl/core.py community (archive-listed) ran Apache-2.0 (permissive) · 5bcf8e086423cf6b · report
ALTTrainer_noKL sauc-abadal/alt/alt/trainer/alt_trainer.py community (archive-listed) unverified MIT (permissive) · 68d8bd0d51b34185 · report
T5ForPretrain kidist-amde/ddro/src/pretrain/T5ForPretrain.py community (archive-listed) unverified Apache-2.0 (permissive) · 88b1660f36f94aca · report
T5ForPretrainDPO kidist-amde/ddro/src/pretrain/T5ForPretrain.py community (archive-listed) unverified Apache-2.0 (permissive) · 9fc13a517d28b68e · report
average_precision kidist-amde/ddro-direct-document-relevance-optimization/src/utils/evaluate.py community (archive-listed) unverified Apache-2.0 (permissive) · 99d26fdcc1af5b62 · report
compare_metrics kidist-amde/ddro-direct-document-relevance-optimization/src/utils/compare_models.py community (archive-listed) unverified Apache-2.0 (permissive) · 9169d5b42acf842a · report
conversations_formatting_function padlex/trl/trl/extras/dataset_formatting.py community (archive-listed) unverified Apache-2.0 (permissive) · e491afec66bfd582 · report
convert_state_dict_to_diffusers padlex/trl/trl/models/sd_utils.py community (archive-listed) unverified Apache-2.0 (permissive) · fa59c920caf016e6 · report
convert_to_scalar padlex/trl/trl/core.py community (archive-listed) unverified Apache-2.0 (permissive) · c32b636f13ed9ee5 · report
flatten_dict padlex/trl/trl/core.py community (archive-listed) unverified Apache-2.0 (permissive) · a51ae45a1f6c0b5b · report
get_all_parameters padlex/trl/trl/models/utils.py community (archive-listed) unverified Apache-2.0 (permissive) · 2f5119732e8dbd63 · report
hit_at_k kidist-amde/ddro-direct-document-relevance-optimization/src/utils/evaluate.py community (archive-listed) unverified Apache-2.0 (permissive) · e9ac5f8dce946d2f · report
instructions_formatting_function padlex/trl/trl/extras/dataset_formatting.py community (archive-listed) unverified Apache-2.0 (permissive) · 875b816ac9842673 · report
is_transformers_greater_than padlex/trl/trl/import_utils.py community (archive-listed) unverified Apache-2.0 (permissive) · 2a9ca02cb6e196ff · report
iter_params padlex/trl/trl/models/utils.py community (archive-listed) unverified Apache-2.0 (permissive) · 48685a350888e505 · report
load_checkpoint kidist-amde/ddro-direct-document-relevance-optimization/src/pretrain/train_ddro_encoder_decoder.py community (archive-listed) unverified Apache-2.0 (permissive) · 0f3aeaf1bff007f2 · report
load_data kidist-amde/ddro-direct-document-relevance-optimization/src/pretrain/eval_ddro_docid_ranking.py community (archive-listed) unverified Apache-2.0 (permissive) · 4099bb8045c005b6 · report
load_doc_offsets kidist-amde/ddro-direct-document-relevance-optimization/src/pretrain/train_ddro_encoder_decoder.py community (archive-listed) unverified Apache-2.0 (permissive) · 01a7e0dc6f29f042 · report
load_encoded_docid kidist-amde/ddro-direct-document-relevance-optimization/src/utils/generate_demo.py community (archive-listed) unverified Apache-2.0 (permissive) · 9c879833332cded9 · report
load_metrics kidist-amde/ddro-direct-document-relevance-optimization/src/utils/compare_models.py community (archive-listed) unverified Apache-2.0 (permissive) · 1233495c1bf99438 · report
load_query_texts kidist-amde/ddro-direct-document-relevance-optimization/src/pretrain/train_ddro_encoder_decoder.py community (archive-listed) unverified Apache-2.0 (permissive) · 8c68bf8c060f4814 · report
prepare_dataset kidist-amde/ddro-direct-document-relevance-optimization/src/pretrain/finetune_docTTTTTquery_NQ.py community (archive-listed) unverified Apache-2.0 (permissive) · 19b1210f13924026 · report
recall_at_k kidist-amde/ddro-direct-document-relevance-optimization/src/utils/evaluate.py community (archive-listed) unverified Apache-2.0 (permissive) · a05d09685378cdb9 · report
scheduler_step padlex/trl/trl/models/modeling_sd_base.py community (archive-listed) unverified Apache-2.0 (permissive) · ade247252fd2d3db · report
setup_chat_format padlex/trl/trl/models/utils.py community (archive-listed) unverified Apache-2.0 (permissive) · ccaedb0c5f904b0b · report
split_dataset kidist-amde/ddro-direct-document-relevance-optimization/src/pretrain/finetune_docTTTTTquery_NQ.py community (archive-listed) unverified Apache-2.0 (permissive) · bdad0f787751d773 · report

Tasks

Language ModelingLanguage ModellingPreference MappingWorld Knowledgemodelreinforcement-learning

Results from the paper archive 2025-07-28

No leaderboard rows for this paper in the archive.

Methods

Introduced by this paper: DPO

ALIGNDPO

Report a problem or propose a change · a person checks every report against the paper or source before anything changes; decisions are listed on /corrections