LongRAG: Enhancing Retrieval-Augmented Generation with Long-context LLMs

Ziyan Jiang, Xueguang Ma, Wenhu ChenarXiv 2024 · OpenReview

Abstract

In traditional RAG framework, the basic retrieval units are normally short. The common retrievers like DPR normally work with 100-word Wikipedia paragraphs. Such a design forces the retriever to search over a large corpus to find the 'needle' unit. In contrast, the readers only need to generate answers from the short retrieved units. The imbalanced 'heavy' retriever and 'light' reader design can lead to sub-optimal performance. The loss of contextual information in the short, chunked units may increase the likelihood of introducing hard negatives during the retrieval stage. Additionally, the reader might not fully leverage the capabilities of recent advancements in LLMs. In order to alleviate the imbalance, we propose a new framework LongRAG, consisting of a 'long retriever' and a 'long reader'. In the two Wikipedia-based datasets, NQ and HotpotQA, LongRAG processes the entire Wikipedia corpus into 4K-token units by grouping related documents. By increasing the unit size, we significantly reduce the total number of units. This greatly reduces the burden on the retriever, resulting in strong retrieval performance with only a few (less than 8) top units. Without requiring any training, LongRAG achieves an EM of 62.7% on NQ and 64.3% on HotpotQA, which are on par with the (fully-trained) SoTA model. Furthermore, we test on two non-Wikipedia-based datasets, Qasper and MultiFieldQA-en. LongRAG processes each individual document as a single (long) unit rather than chunking them into smaller units. By doing so, we achieve an F1 score of 25.9% on Qasper and 57.5% on MultiFieldQA-en. Our study offers insights into the future roadmap for combining RAG with long-context LLMs.

Introduction: The Imbalance of Traditional RAG

Traditional Retrieval-Augmented Generation (RAG) frameworks typically rely on short retrieval units, such as 100-word Wikipedia paragraphs. This design necessitates a "heavy" retriever tasked with finding a specific "needle" in a massive corpus of millions of units, while the reader is relegated to a "light" role, generating answers from limited context.

This imbalance leads to two significant issues. First, the vast search space increases the likelihood of encountering "hard negatives"—snippets that appear relevant but lack the necessary information. Second, chunking documents into small pieces often destroys semantic integrity. If an answer requires synthesizing information across multiple paragraphs or documents, a traditional retriever may fail to capture the full context.

Traditional RAG vs. LongRAG context retrieval example.

The LongRAG Framework

To address these limitations, the authors propose LongRAG, a framework that shifts the burden from the retriever to a long-context Large Language Model (LLM) reader.

Long Retrieval Units

Instead of 100-word chunks, LongRAG groups related documents (e.g., via hyperlinks) into units of approximately 4,000 tokens. For the Wikipedia corpus, this reduces the number of retrieval units from 22 million to roughly 600,000, significantly easing the retriever's task.

Long Retrieval and Reading

The framework employs a "long retriever" using a MaxP strategy to identify relevant long units. Similarity is defined as the maximum score among 512-token chunks within the unit. The "long reader" then processes the top 4-8 units (~30K tokens) using a two-turn extraction process: first generating a detailed answer, then condensing it into a concise format. This approach leverages the advanced reasoning capabilities of modern LLMs over extended contexts.

Architectural comparison and benchmark results for NQ and HotpotQA.

Experimental Results

LongRAG was evaluated on several benchmarks, including Natural Questions (NQ), HotpotQA, Qasper, and MultiFieldQA-en.

  • State-of-the-Art Performance: Without any specialized training, LongRAG achieved an Exact Match (EM) of 62.7% on NQ and 64.3% on HotpotQA, rivaling fully-trained state-of-the-art models like Atlas.
  • Improved Retrieval Recall: By coarsening the retrieval grain, the Recall@1 on NQ improved from 52% to 71%.
  • Long-form Document Success: On the Qasper dataset, LongRAG improved the F1 score to 25.9% (from 22.5% in traditional RAG), and on MultiFieldQA-en, it reached 57.5% (from 51.2%).
  • Context Optimization: The authors identified a "sweet spot" for context length around 30,000 tokens. Beyond this, performance begins to decline due to "lost in the middle" effects or excessive noise.

Conclusion

LongRAG demonstrates that by rebalancing the RAG framework to favor "heavy reading" over "heavy retrieval," we can significantly improve performance and simplify the pipeline. As LLM context windows continue to expand, this paradigm offers a promising roadmap for the future of open-domain question answering and document analysis.

Summary updated

BibTeX
@misc{jiang2024longrag,
  author = {Ziyan Jiang and Xueguang Ma and Wenhu Chen},
  title = {{LongRAG: Enhancing Retrieval-Augmented Generation with Long-context LLMs}},
  year = {2024},
  eprint = {2406.15319},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2406.15319},
}
Figure