A RAG-Based Institutional Assistant

Gustavo Kuratomi, Paulo Pirozelli, Fábio Gagliardi Cozman, Sarajane Marques Peres2024 · DOI

TL;DR

Researchers at the University of São Paulo (USP) developed a Retrieval-Augmented Generation (RAG) system to help students and staff navigate the university’s complex bureaucratic framework. Their study reveals that while RAG significantly boosts LLM accuracy (from 13% to 54% when the right info is found), the "retrieval" step remains a major bottleneck, especially when users don't use the exact phrasing found in official documents.

What Problem Does This Paper Address?

Large Language Models (LLMs) are impressive, but they suffer from two major flaws in institutional settings: they hallucinate and they lack access to private or frequently updated data. For a massive institution like USP—with nearly 100,000 students and a labyrinth of "normative documents" (statutes, ordinances, and resolutions)—a standard ChatGPT-style model isn't enough.

The authors address the challenge of building a reliable virtual assistant that can answer specific questions about university regulations. They specifically look at how different "moving parts" of a RAG system—like how you chop up documents (chunking) and which models you use to find those chunks (retrieval)—impact the final answer's quality.

Methods

The authors employed a Modular RAG architecture, which separates the process into two distinct stages:

  1. Retrieval: When a user asks a question, the system searches a database of 866 USP documents. They tested several "embedding" models (Sentence-BERT variants like MiniLM and Mpnet) that turn text into math vectors to find semantic matches. They also used BM25, a classic keyword-based search algorithm, as a baseline.
  2. Generation: Once the most relevant text "chunks" are found, they are fed into an LLM along with the original question. The authors tested both proprietary models (GPT-3.5-turbo) and open-source ones (Llama-3, Mixtral, and the Portuguese-specialized Sabia-2).

A key technical detail was their chunking strategy: they tested sizes of 2K, 4K, and 8K characters, using a 1:10 overlap ratio to ensure that important information wasn't accidentally cut in half at the edge of a chunk.

Datasets

The study utilized two primary data components:

  • The Corpus: 866 normative documents collected from USP’s website (Jan 2023 – May 2024).
  • The QA Dataset: 592 question-answer pairs generated using GPT-4.
  • Version 1 (Original): Questions that often shared vocabulary with the source text.
  • Version 2 (Paraphrased): A more difficult set where GPT-4 reformulated the questions to be as linguistically different from the source as possible. This is a crucial benchmark because real users rarely quote legal documents verbatim.

Key Insights and Ideas

  • The "Lexical Advantage" of BM25: Surprisingly, the keyword-based BM25 outperformed fancy neural embedding models on the "original" questions. This happened because the questions used the same words as the documents. However, when questions were paraphrased, the neural models (specifically Mpnet) started to close the gap, proving that semantic search is more robust for real-world, natural language queries.
  • Retrieval is the Weak Link: The "Top-5" accuracy for the best retriever on paraphrased questions was only 30%. This means that 70% of the time, the correct information wasn't even in the top five results sent to the LLM.
  • The Context Jump: The most striking finding was the performance delta. Without any context, the LLM scored 13.68%. With the correct context manually provided, accuracy soared to 54.02%. This confirms that the LLM's "reasoning" is decent, but its "searching" is struggling.
  • Chunk Size Matters: Smaller chunks (2K) generally led to better retrieval performance. Larger chunks likely "dilute" the specific answer, making it harder for embedding models to represent the core meaning accurately.

Key Results

  • Best Retriever: BM25 was the strongest overall, but Mpnet was the most effective neural model for 2K chunks.
  • Best Generator: GPT-3.5-turbo consistently outperformed Llama-3, Mixtral, and Sabia-2 across F1-score and LLM-based evaluations.
  • Overall System Performance: The most effective end-to-end configuration achieved a score of 22.04% against ground truth answers. While this sounds low, it highlights the extreme difficulty of providing precise, legally-grounded answers compared to general conversation.

Limitations and Future Work

The authors identify several hurdles for the next generation of institutional assistants:

  1. Portuguese Language Support: There is a relative scarcity of high-performing embedding models specifically optimized for Portuguese compared to English.
  2. Multi-hop Reasoning: The current system struggles with questions that require linking information across two different documents (e.g., "How does Resolution A affect the rules in Statute B?").
  3. Human-in-the-loop: The study relied heavily on GPT-4 for evaluation. The authors note that future work needs systematic evaluation by university staff to ensure the "ground truth" is actually correct in a bureaucratic sense.
  4. Scaling the Database: The current system only looks at university-wide norms; expanding to specific departments or institutes will significantly increase the "noise" the retriever must filter through.

Summary updated

Abstract

Although large language models (LLMs) demonstrate strong text generation capabilities, they struggle in scenarios requiring access to structured knowledge bases or specific documents, limiting their effectiveness in knowledge-intensive tasks. To address this limitation, retrieval-augmented generation (RAG) models have been developed, enabling generative models to incorporate relevant document fragments into their inputs. In this paper, we design and evaluate a RAG-based virtual assistant specifically tailored for the University of São Paulo. Our system architecture comprises two key modules: a retriever and a generative model. We experiment with different types of models for both components, adjusting hyperparameters such as chunk size and the number of retrieved documents. Our optimal retriever model achieves a Top-5 accuracy of 30%, while our most effective generative model scores 22.04% against ground truth answers. Notably, when the correct document chunks are supplied to the LLMs, accuracy significantly improves to 54.02%, an increase of over 30 percentage points. Conversely, without contextual input, performance declines to 13.68%. These findings highlight the critical role of database access in enhancing LLM performance. They also reveal the limitations of current semantic search methods in accurately identifying relevant documents and underscore the ongoing challenges LLMs face in generating precise responses.
BibTeX
@misc{kuratomi2024rag,
  author = {Gustavo Kuratomi and Paulo Pirozelli and Fábio Gagliardi Cozman and Sarajane Marques Peres},
  title = {{A RAG-Based Institutional Assistant}},
  year = {2024},
  doi = {10.5753/eniac.2024.245243},
}
Figure