RETA-LLM: A Retrieval-Augmented Large Language Model Toolkit

Jiongnan Liu, Jiajie Jin, Zihan Wang, Jiehan Cheng, Zhicheng Dou, Ji-Rong WenarXiv 2023 · DOI

Introduction

Large Language Models (LLMs) have demonstrated remarkable capabilities across various domains. However, they are frequently limited by two significant drawbacks: hallucinations—the generation of factually incorrect but plausible-sounding information—and a lack of domain-specific or real-time knowledge due to the static nature of their training data.

Retrieval-Augmented Generation (RAG) has emerged as a primary solution, allowing models to query external corpora before generating responses. Despite its promise, building a production-ready RAG system involves significant engineering challenges, including query disambiguation, context window management, and output verification. RETA-LLM addresses these hurdles by providing a comprehensive, modular, and "plug-and-play" toolkit designed to streamline the development of LLM-based assistants.

The RETA-LLM Pipeline

The core architecture of RETA-LLM is a five-module pipeline that decouples Information Retrieval (IR) systems from the LLM, ensuring maximum flexibility and scalability.

  1. Request Rewriting: This module uses LLMs to clarify conversational queries. For instance, a follow-up question like "How about Economics?" is rewritten to "Introduce the majors in the School of Economics" to ensure the retrieval system has sufficient context.
  2. Document Retrieval: RETA-LLM supports both dense retrieval (embedding-based) and sparse retrieval (e.g., BM25), connecting seamlessly to external IR systems.
  3. Passage Extraction: To accommodate limited LLM context windows, this module employs a sliding window strategy and LLM-based filtering to extract the most relevant snippets from retrieved documents.
  4. Answer Generation: The backbone LLM generates a response synthesized from the extracted references.
  5. Fact Checking: A final verification step compares the generated answer against the retrieved evidence. This allows the system to identify factual errors or admit when the evidence is insufficient to answer the query.
The RETA-LLM framework illustrates the five-step pipeline from user request to final response, integrating external IR systems and LLMs.

Key Insights and Design Principles

The development of RETA-LLM highlights several critical design considerations for modern RAG systems:

  • System Disentanglement: By separating the IR and LLM components, developers can upgrade search engines or language models independently without re-engineering the entire pipeline.
  • Conversational Context: Integrating an LLM-based rewriter significantly improves retrieval accuracy in multi-turn dialogues where user queries are often underspecified.
  • Unsupervised Domain Adaptation: The toolkit includes an "Index Builder" that supports unsupervised training of dense retrieval models, allowing the system to adapt to niche vocabularies without labeled datasets.
  • Automated Self-Correction: The dedicated fact-checking module acts as a vital safety net, acknowledging that LLMs can misinterpret even "open-book" references.

Practical Application and Results

To demonstrate the toolkit's efficacy, the authors developed the RUC-enrollment-assistant, a specialized bot built using web pages from Renmin University of China’s enrollment platform. The system utilizes a dense retrieval module and the YuLan-13B model as its backbone.

A screenshot of the RUC-enrollment-assistant service case, demonstrating the system's ability to provide accurate, in-domain answers regarding university majors.

RETA-LLM is designed for high compatibility, supporting various models including Alpaca, ChatGLM, and GPT-3.5. Its modular design enables a rapid transition from raw data (e.g., HTML files) to a functional, Streamlit-based web service with minimal custom code.

Future Directions

While RETA-LLM provides a robust foundation, future work aims to incorporate active retrieval strategies, where the model can dynamically decide to query more information during the generation process. Additionally, the authors plan to enhance the fact-checking module's robustness to detect more subtle factual nuances and further increase the system's overall modularity.

Summary updated

BibTeX
@misc{liu2023reta,
  author = {Jiongnan Liu and Jiajie Jin and Zihan Wang and Jiehan Cheng and Zhicheng Dou and Ji-Rong Wen},
  title = {{RETA-LLM: A Retrieval-Augmented Large Language Model Toolkit}},
  year = {2023},
  eprint = {2306.05212},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2306.05212},
}
Figure