Make Your LLM Fully Utilize the Context

Shengnan An, Zexiong Ma, Zeqi Lin, Nanning Zheng, Jian-Guang Lou, Weizhu Chen

Abstract

Despite the expansion of context windows in Large Language Models (LLMs) to 128K tokens and beyond, many models exhibit a "lost-in-the-middle" phenomenon, where information located in the center of a long prompt is frequently ignored. This paper presents INformation-INtensive (IN2) training, a data-driven fine-tuning methodology designed to compel models to utilize their entire context window. By training on synthesized tasks requiring fine-grained information awareness and multi-hop reasoning, the resulting model, FILM-7B, achieves performance comparable to or exceeding GPT-4-Turbo on long-context retrieval tasks while preserving strong performance on standard short-context benchmarks.

Introduction

As LLMs scale their context windows, a performance gap has emerged: models excel at retrieving information from the beginning or end of a prompt but struggle with the middle. This "U-shaped" performance curve limits the reliability of long-context windows for tasks like codebase analysis or multi-document reasoning. The authors argue that this is not a fundamental architectural limitation but a consequence of current training paradigms. Standard pre-training and fine-tuning often place critical information at the extremities, inadvertently teaching models that the middle is less relevant.

Methodology: INformation-INtensive (IN2) Training

To address this supervision failure, the researchers introduced IN2 training, which focuses on changing the model's data "diet" during fine-tuning rather than modifying its architecture.

The training process involves:

  1. Synthesized Long Contexts: Contexts (4K to 32K tokens) are constructed by concatenating short (~128 token) segments.
  2. Information-Intensive QA: Using GPT-4-Turbo as a teacher, two types of questions are generated:
  3. Fine-grained awareness: Requires identifying a specific segment hidden randomly in the context.
  4. Integration and Reasoning: Multi-hop questions requiring the combination of information from multiple scattered segments.
The IN2 data construction process ensures the model must attend to specific segments or integrate multiple segments to answer correctly.

The resulting model, FILM-7B (Fill-in-the-Middle), was fine-tuned from Mistral-7B-Instruct-v0.2 using 1.1 million synthesized examples mixed with general short-context data to maintain broad capabilities.

Experimental Setup: VAL Probing

The authors introduced VArious Long-context (VAL) Probing to evaluate retrieval more rigorously than the standard "Needle-in-the-Haystack" test. VAL Probing includes:

  • Document Sentence Retrieval: Bi-directional natural language retrieval.
  • Code Function Retrieval: Backward retrieval (finding a function name from its definition).
  • Database Entity Retrieval: Forward retrieval in structured data.

Results and Analysis

FILM-7B effectively eliminates the "lost-in-the-middle" problem. While the base Mistral model shows significant performance degradation in the center of the context, FILM-7B maintains high, stable performance across the entire 32K window.

Performance comparison: FILM-7B (orange) maintains robust performance across all relative positions, whereas Mistral (grey) and GPT-4-Turbo (blue) show significant dips or fluctuations.

Key findings include:

  • Retrieval Superiority: FILM-7B achieved an average score of 85.9% on VAL Probing, surpassing GPT-4-Turbo (79.0%).
  • Retrieval Directionality: Models generally find forward retrieval easier than backward retrieval; VAL Probing highlights these specific weaknesses.
  • Generalization: FILM-7B maintained its performance on MMLU (59.3%), showing no "tax" on general intelligence for long-context specialization.
  • RoPE Scaling: Increasing the Rotary Positional Encoding (RoPE) base factor (up to 10x) was found to be beneficial for high-intensity long-context tasks.

Conclusion

IN2 training demonstrates that the "lost-in-the-middle" phenomenon is largely a result of insufficient supervision during training. By explicitly training models to treat every position in the context as potentially critical, FILM-7B achieves state-of-the-art long-context utilization. Future work includes scaling this approach to 128K+ contexts and reducing the computational cost of generating synthetic training data, which currently requires approximately 300 GPU days (A100s) for a 7B model.

Summary updated

BibTeX
@inproceedings{an2024make,
  author = {Shengnan An and Zexiong Ma and Zeqi Lin and Nanning Zheng and Jian-Guang Lou and Weizhu Chen},
  title = {{Make Your LLM Fully Utilize the Context}},
  booktitle = {Advances in Neural Information Processing Systems},
  year = {2024},
  url = {https://openreview.net/forum?id=YGTVEmBXtV},
}
Figure