RAGLAB: A Modular and Research-Oriented Unified Framework for Retrieval-Augmented Generation

Xuanwang Zhang, Yunze Song, Yidong Wang, Shuyun Tang, Xinfeng Li, Zhengran Zeng, Zhen Wu, Wei Ye, Wenyuan Xu, Yue Zhang, Xinyu Dai, Shikun Zhang, Qingsong Wen

Abstract

Large Language Models (LLMs) demonstrate human-level capabilities in dialogue, reasoning, and knowledge retention. However, even the most advanced LLMs face challenges such as hallucinations and real-time updating of their knowledge. Current research addresses this bottleneck by equipping LLMs with external knowledge, a technique known as Retrieval Augmented Generation (RAG). However, two key issues constrained the development of RAG. First, there is a growing lack of comprehensive and fair comparisons between novel RAG algorithms. Second, open-source tools such as LlamaIndex and LangChain employ high-level abstractions, which results in a lack of transparency and limits the ability to develop novel algorithms and evaluation metrics. To close this gap, we introduce RAGLAB, a modular and research-oriented open-source library. RAGLAB reproduces 6 existing algorithms and provides a comprehensive ecosystem for investigating RAG algorithms. Leveraging RAGLAB, we conduct a fair comparison of 6 RAG algorithms across 10 benchmarks. With RAGLAB, researchers can efficiently compare the performance of various algorithms and develop novel algorithms.

Addressing the Research Gap

Retrieval-Augmented Generation (RAG) has become the standard method for reducing hallucinations in Large Language Models (LLMs) by grounding them in external knowledge. However, the research field is currently fragmented. Popular open-source tools like LangChain and LlamaIndex are designed for building applications, not for scientific research; they often employ high-level abstractions that hide internal operational mechanisms, making it difficult to develop or evaluate new algorithms transparently.

Furthermore, many published RAG papers are not open-source, or they use unaligned instructions, retrievers, and knowledge bases. This lack of standardization makes it nearly impossible to determine if a new algorithm's performance boost comes from a clever logic change or simply a better-tuned prompt. As shown in the comparison of existing libraries, most lack the features necessary for a truly fair scientific evaluation.

Comparison of RAG libraries highlighting RAGLAB's unique support for fair comparison and data collection.

The RAGLAB Framework

RAGLAB introduces a modular architecture where every component of a RAG system—Retriever, Corpus, Generator, Instruction Lab, Trainer, and Metric—is decoupled and standardized. This design allows researchers to move past the "black box" limitations of existing tools and conduct true apples-to-apples comparisons.

The modular architecture of the RAGLAB framework.

Key Technical Highlights

  • Instruction Lab: A module that standardizes prompts across three pools (System, Task, and Algorithm instructions). This ensures that when comparing two algorithms, the only variable changing is the algorithm itself.
  • Retriever Server/Client: To solve the bottleneck of repeatedly loading massive knowledge bases during parallel evaluations, RAGLAB uses a server-client architecture with a retrieval caching mechanism. This reduces latency for identical queries to less than 0.1 seconds.
  • Algorithm Reproduction: The framework natively reproduces six influential RAG algorithms: Naive RAG, RRR, ITER-RETGEN, Self-Ask, Active RAG, and Self-RAG.
  • Unified Interfaces: It integrates high-performing models like Contriever and ColBERT for retrieval, and supports VLLM, HuggingFace, and OpenAI for generation, allowing researchers to swap components with minimal code changes.

Experimental Setup and Benchmarking

The authors evaluated the framework using 10 widely used benchmarks covering five distinct NLP tasks: OpenQA, Multi-Hop QA, Multiple-Choice, Fact Verification, and Long-Form QA. They also provided preprocessed versions of the 2018 and 2023 Wikipedia corpora, complete with pre-built indices and embeddings to facilitate standardized testing.

Key Insights and Results

The researchers conducted a massive evaluation across three different base models (Llama3-8B, Llama3-70B, and GPT-3.5).

  • Model Size Matters for Advanced RAG: One of the most interesting findings was that complex algorithms like Self-RAG (which uses special tokens to critique its own retrieval) don't significantly outperform simpler methods when using smaller base models like Llama3-8B. However, when scaled up to Llama3-70B, Self-RAG significantly outperforms the competition, achieving top-tier results in OpenQA (48.8 ACC on PopQA) and Long-Form QA (39.84 str-em on ASQA).
  • Iterative RAG for Multi-Hop QA: Results showed that ITER-RETGEN consistently excels in Multi-Hop QA tasks, highlighting the value of iterative retrieval-generation cycles for complex reasoning.
  • RAG is not a Panacea: Interestingly, direct LLM generation sometimes outperformed RAG in multiple-choice tasks. The authors suggest that retrieved information can occasionally act as a "distractor" in these specific contexts.
  • Efficiency and User Validation: The retriever caching system allows for high-concurrency access, making large-scale benchmarking significantly faster. A study of 20 NLP researchers found that 85% perceived RAGLAB as significantly enhancing their research efficiency.

Conclusion

RAGLAB provides a much-needed standardized environment for RAG research, moving the field away from opaque evaluations toward rigorous, reproducible science. While currently focused on Wikipedia-based retrieval and six core algorithms, the team plans to expand the framework's scope to include more diverse knowledge bases and comprehensive evaluations of resource consumption and inference latency.

Summary updated

BibTeX
@inproceedings{zhang2024raglab,
  author = {Xuanwang Zhang and Yunze Song and Yidong Wang and Shuyun Tang and Xinfeng Li and Zhengran Zeng and Zhen Wu and Wei Ye and Wenyuan Xu and Yue Zhang and Xinyu Dai and Shikun Zhang and Qingsong Wen},
  title = {{RAGLAB: A Modular and Research-Oriented Unified Framework for Retrieval-Augmented Generation}},
  booktitle = {Conference on Empirical Methods in Natural Language Processing},
  year = {2024},
  url = {https://openreview.net/forum?id=tiXjmiF4cU},
}
Figure