Retrieval meets Long Context Large Language Models

Peng Xu, Wei Ping, Xianchao Wu, Lawrence McAfee, Chen Zhu, Zihan Liu, Sandeep Subramanian, Evelina Bakhturina, Mohammad Shoeybi, Bryan Catanzaro · DOI

Abstract

This paper investigates the synergy between extending Large Language Model (LLM) context windows and augmenting them with retrieval systems. Contrary to the view that retrieval is merely a workaround for short context, the authors demonstrate that retrieval enhances performance even for models with 32K context windows. Notably, a retrieval-augmented 4K model can often match or exceed the performance of a 16K model, offering significant computational efficiency.

Introduction

As LLMs are increasingly deployed for long-form tasks like legal document analysis or book summarization, two primary scaling strategies have emerged: extending the native context window (e.g., to 100K+ tokens) or using Retrieval-Augmented Generation (RAG). While long context windows are computationally expensive due to the quadratic complexity of self-attention, RAG systems selectively feed relevant snippets to the model. This study explores whether these approaches are mutually exclusive or complementary, focusing on state-of-the-art models like Llama2-70B and a proprietary 43B GPT.

Methodology

The researchers evaluated several configurations to determine the optimal balance between context length and retrieval:

  • Context Extension: Pretrained models were extended from 4K to 16K and 32K using positional interpolation.
  • Retrieval Integration: Three retrievers (Dragon, Contriever, and OpenAI embeddings) were used to extract the "top-N" relevant chunks (~300 words each).
  • Instruction Tuning: Models underwent instruction fine-tuning to ensure they could effectively utilize the provided context, using a prompt template that prioritizes retrieved information.
  • Evaluation Datasets: The study utilized seven diverse tasks from the Scroll and LongBench benchmarks, covering summarization (QMSum), question answering (Qasper, NarrativeQA, HotpotQA, MuSiQue), and multiple-choice (QuALITY).

Key Insights

Retrieval as a Universal Performance Booster

A significant finding is that retrieval consistently improves performance regardless of the model's native context window. For instance, a 32K window model still benefits from retrieval as it acts as a noise filter, focusing the model's attention on relevant data.

The "Lost-in-the-Middle" Phenomenon

The study confirms that LLMs tend to perform better when relevant information is located at the extreme ends of the input. Retrieval helps mitigate this by repositioning the most relevant "middle" information to the beginning of the prompt.

EM scores across different positions for Llama2-70B, illustrating the performance dip for information located in the middle of the context window.

Model Size and Reasoning

Larger models (70B) demonstrate a superior ability to reason over retrieved chunks compared to smaller models (7B). In smaller models, the context window itself often acts as the primary bottleneck, whereas larger models are more sensitive to the quality of the retrieved information.

Results

The retrieval-augmented Llama2-70B-32k (Llama2-70B-32k-ret) emerged as a top performer, surpassing established models like GPT-3.5-turbo-16k and Davinci-003 across nine long-context tasks.

Performance comparison of various models with and without retrieval across different sequence lengths and datasets.

Beyond accuracy, retrieval-augmented models offer substantial efficiency gains. On the NarrativeQA task, the retrieval-augmented model was 4x faster during generation than the non-retrieval baseline, as it avoided processing the entire noisy document during decoding. The study also found that providing the top 5 to 10 retrieved chunks is generally optimal; exceeding this (e.g., top 20) can introduce distracting irrelevant information.

Conclusion and Future Work

While retrieval significantly enhances long-context LLMs, challenges remain. Models can still be distracted by irrelevant retrieved chunks, and the overall system performance is heavily dependent on the retriever's quality. Future research should focus on improving dense retrievers for specialized domains and exploring even longer context windows (64K+) combined with advanced attention mechanisms.

Summary updated

BibTeX
@inproceedings{xu2024retrieval,
  author = {Peng Xu and Wei Ping and Xianchao Wu and Lawrence McAfee and Chen Zhu and Zihan Liu and Sandeep Subramanian and Evelina Bakhturina and Mohammad Shoeybi and Bryan Catanzaro},
  title = {{Retrieval meets Long Context Large Language Models}},
  booktitle = {International Conference on Learning Representations},
  year = {2024},
  url = {https://openreview.net/forum?id=xw5nxFWMlo},
}
Figure