Reducing Distraction in Long-Context Language Models by Focused Learning

Zijun Wu, Bingyuan Liu, Ran Yan, Lei Chen, Thomas DelteilarXiv 2024

Abstract

Recent advancements in Large Language Models (LLMs) have significantly enhanced their capacity to process long contexts. However, effectively utilizing this long context remains a challenge due to the issue of distraction, where irrelevant information dominates lengthy contexts, causing LLMs to lose focus on the most relevant segments. To address this, we propose a novel training method that enhances LLMs' ability to discern relevant information through a unique combination of retrieval-based data augmentation and contrastive learning. Specifically, during fine-tuning with long contexts, we employ a retriever to extract the most relevant segments, serving as augmented inputs. We then introduce an auxiliary contrastive learning objective to explicitly ensure that outputs from the original context and the retrieved sub-context are closely aligned. Extensive experiments on long single-document and multi-document QA benchmarks demonstrate the effectiveness of our proposed method.

Introduction

While modern LLMs boast context windows of 32k tokens or more, they are not always efficient at utilizing them. When a document is packed with irrelevant information, the model's attention mechanism tends to over-generalize, spreading focus across all tokens rather than zeroing in on the evidence needed to answer a specific question. This leads to well-documented failures like the "lost in the middle" phenomenon, where models struggle to retrieve information located in the center of a long prompt. While Inference-time Retrieval (RAG) is a common solution, it can cause the model to lose global context and makes the system vulnerable to retriever errors. This research introduces "Focused Learning" to bake this focusing ability directly into the model's weights.

Methodology

The proposed Focused Learning framework employs a two-pronged training strategy:

  1. Retrieval-based Data Augmentation: During fine-tuning, an external retriever (such as Contriever) identifies the top-k most relevant chunks for a given question. An "augmented" version of the document is created where irrelevant chunks are replaced with a special <mask/> token. This creates a "clean" version of the context that preserves the original document's structure.
  2. Contrastive Learning for Focus: The model is trained on both the original "noisy" document and the "clean" augmented version. An auxiliary contrastive loss function forces the model's internal representations (specifically the [EOS] token embedding) of the noisy and clean versions to be as similar as possible.
Figure 1: Overview of the Focused Learning framework, illustrating the retrieval-based data augmentation and the dual loss objective (Contrastive + Causal LM).

By treating data augmentation as a semantic alignment problem, the model learns that the messy, long document is semantically equivalent to the concise, filtered version, implicitly teaching it to perform its own internal retrieval and ignore distracting text.

Experimental Results

The researchers evaluated the method using three primary benchmarks: Qasper (academic paper QA), QuALITY (long story QA), and NQd (Natural Questions with distractors).

Focused Learning consistently outperformed vanilla fine-tuning and standard RAG baselines. On Qasper, the model achieved an F1 score of 59.62, compared to 48.65 for the vanilla-trained model. On the NQd multi-document task, the method improved the Exact Match (EM) score from 44.6 to 48.1. When combined with a simple re-ranking strategy, the score reached 52.0.

Figure 6: Accuracy across different positions of the gold document for varying document counts (10, 20, 30, 50). The proposed method ("Ours") shows improved robustness and higher accuracy compared to the "Vanilla" baseline across different document positions.

Key Insights

  • The Power of Masking: Replacing irrelevant text with a <mask/> token is more effective than simple deletion. The mask helps the model learn to explicitly ignore specific segments while maintaining awareness of the document's overall layout.
  • Shifting Biases: As context grows, the "lost in the middle" problem can shift to a "lost in the beginning" problem, likely due to sliding window attention mechanisms in models like Mistral.
  • Efficiency: These performance gains were achieved with only a few hundred fine-tuning steps using LoRA (Low-Rank Adaptation), making it a cost-effective way to improve long-context performance.

Conclusion and Future Work

Focused Learning effectively reduces distraction in long-context LLMs by embedding retrieval logic into the model weights. While successful in Question Answering, future work will investigate its impact on tasks like long-form summarization, where "irrelevant" information might be necessary for a holistic overview, and explore architectural changes to further mitigate inherent positional biases.

Summary updated

BibTeX
@misc{wu2024reducing,
  author = {Zijun Wu and Bingyuan Liu and Ran Yan and Lei Chen and Thomas Delteil},
  title = {{Reducing Distraction in Long-Context Language Models by Focused Learning}},
  year = {2024},
  eprint = {2411.05928},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2411.05928},
}
Figure