Context-DPO: Aligning Language Models for Context-Faithfulness

Baolong Bi, Shaohan Huang, Yiwei Wang, Tianchi Yang, Zihan Zhang, Haizhen Huang, Lingrui Mei, Junfeng Fang, Zehao Li, Furu Wei, Weiwei Deng, Feng Sun, Qi Zhang, Shenghua Liu

Abstract

Large Language Models (LLMs) often prioritize internal pre-trained knowledge over provided context in Retrieval-Augmented Generation (RAG) tasks, a phenomenon termed "stubbornness." This paper introduces Context-DPO, a fine-tuning framework using Direct Preference Optimization to align models toward context-faithfulness. By training models to prefer context-grounded responses over those based on internal memory, Context-DPO achieves up to a 280% improvement in faithfulness across various benchmarks without compromising general generative performance or truthfulness.

Introduction

Large Language Models are increasingly integrated into RAG systems to provide up-to-date and domain-specific answers. However, a significant "knowledge conflict" arises when retrieved documents contradict a model's pre-trained weights. In such cases, models often ignore the context in favor of their internal "beliefs." Paradoxically, research indicates that as models become larger and more advanced (e.g., GPT-4o, Llama-3), they become less faithful to context, growing more confident in their internal parameters and harder to steer via simple prompting.

Illustration of faithful vs. stubborn responses in the presence of knowledge conflict.

Methods

Context-DPO is the first alignment method designed to bake context-faithfulness directly into model weights. The process follows four main steps:

  1. Counterfactual Collection: Real-world factual triples from Wikidata are modified by swapping the "Object" with a different entity of the same type to create plausible but "fake" facts.
  2. Context Generation: An LLM generates natural-sounding passages that embed these counterfactual facts.
  3. Preference Data Construction: For a given question, the system generates a Faithful Response (grounded in the counterfactual context) and a Stubborn Response (grounded in the model's internal knowledge).
  4. Alignment via DPO: Direct Preference Optimization is used to fine-tune the model. Unlike standard Supervised Fine-Tuning (SFT), which often fails to break internal biases, DPO's contrastive nature explicitly teaches the model to prefer the faithful response over the stubborn one.

Results and Evaluation

The researchers evaluated Context-DPO using a new benchmark, ConFiQA (Context Faithfulness Question Answering), alongside standard datasets like Natural Questions (NQ), MQUAKE, and TruthfulQA.

Performance Gains

The improvements across popular open-source models were dramatic:

  • Qwen2-7B: Saw a massive 280% improvement in context-faithfulness.
  • Mistral-7B: Improved by 151%.
  • Llama3-8B: Improved by 78%.

Zero Side Effects

Crucially, evaluation on TruthfulQA demonstrated that the models' general knowledge and generative capabilities remained intact. Context-DPO specifically targets the relationship between context and output rather than overwriting the model's internal factual database. Interpretability analysis showed that the method fundamentally shifts the model's logit distribution, reducing the probability of "stubborn" tokens and boosting "faithful" ones.

Conclusion

Context-DPO offers a robust solution to the stubbornness paradox in LLMs, consistently outperforming sophisticated prompting techniques without requiring extra inference-time overhead. While the current study focuses on explicit knowledge conflicts, future work will explore more subtle retrieval noise and the development of "accountable" models capable of citing their contextual sources.

Summary updated

BibTeX
@inproceedings{bi2025context,
  author = {Baolong Bi and Shaohan Huang and Yiwei Wang and Tianchi Yang and Zihan Zhang and Haizhen Huang and Lingrui Mei and Junfeng Fang and Zehao Li and Furu Wei and Weiwei Deng and Feng Sun and Qi Zhang and Shenghua Liu},
  title = {{Context-DPO: Aligning Language Models for Context-Faithfulness}},
  booktitle = {Annual Meeting of the Association for Computational Linguistics},
  year = {2025},
}
Figure