[Paper Review] T-RAG: Lessons from the LLM Trenches
The paper presents Tree-RAG (T-RAG), a retrieval-augmented generation system with a hierarchical entities tree and finetuned Llama-2 7B for on-prem QA over private governance documents, showing improved accuracy over standard RAG and finetuned baselines, plus lessons learned.
Large Language Models (LLM) have shown remarkable language capabilities fueling attempts to integrate them into applications across a wide range of domains. An important application area is question answering over private enterprise documents where the main considerations are data security, which necessitates applications that can be deployed on-prem, limited computational resources and the need for a robust application that correctly responds to queries. Retrieval-Augmented Generation (RAG) has emerged as the most prominent framework for building LLM-based applications. While building a RAG is relatively straightforward, making it robust and a reliable application requires extensive customization and relatively deep knowledge of the application domain. We share our experiences building and deploying an LLM application for question answering over private organizational documents. Our application combines the use of RAG with a finetuned open-source LLM. Additionally, our system, which we call Tree-RAG (T-RAG), uses a tree structure to represent entity hierarchies within the organization. This is used to generate a textual description to augment the context when responding to user queries pertaining to entities within the organization's hierarchy. Our evaluations, including a Needle in a Haystack test, show that this combination performs better than a simple RAG or finetuning implementation. Finally, we share some lessons learned based on our experiences building an LLM application for real-world use.
Motivation & Objective
- Demonstrate a real-world LLM-based QA system for private organizational documents.
- Show how combining RAG with a finetuned open-source LLM improves factual accuracy and response quality.
- Introduce a tree-based context (entities hierarchy) to augment responses for entity-related questions.
- Propose a new evaluation metric (Correct-Verbose) to capture correct but overly verbose answers.
- Share practical lessons learned from deploying an LLM-powered QA system in production.
Proposed method
- Combine Retrieval-Augmented Generation (RAG) with finetuned open-source Llama-2 7B for answer generation.
- Introduce Tree-RAG (T-RAG): augment standard RAG context with an entities tree that encodes organizational hierarchies.
- Generate an instruction dataset from the organization’s governance document and perform PEFT (QLoRA) with 4-bit quantization to finetune the LLM.
- Use a vector store (Chroma DB) for document chunks and MM Retrieval to select diverse, relevant chunks.
- Augment retrieved context with textual statements about entities found in the query via spaCy-based NER with custom organization-specific rules.
- Represent the organization’s hierarchy as a tree and query it to extract entity-position information to augment context when entities are mentioned.
- Evaluate using human judgments on Correct (C) and Correct-Verbose (CV) responses.

Experimental results
Research questions
- RQ1Does the T-RAG system improve factual accuracy and relevance over standard RAG or a finetuned model alone in enterprise document QA?
- RQ2What is the impact of adding the entities tree context on performance, especially for complex entity-related questions?
- RQ3How does a finetuned LLM compare to RAG when context is limited or when entity hierarchies are leveraged?
- RQ4Does the proposed Correct-Verbose metric provide meaningful differentiation between systems?
Key findings
- T-RAG achieves higher overall correct or correct-verbose responses (27/37) than RAG (21/37) or Finetuned (20/37).
- Tree context significantly improves entity-related question accuracy, especially for complex queries.
- Including the entity tree context with finetuned Llama-2 yields substantial gains (e.g., simple questions from 8/17 to 17/17; complex from 8/22 to 15/22).
- RAG with entity-tree context reduces hallucinations and misalignment of entities within organizational categories.
- T-RAG exhibits more verbose correct answers (CV) but overall higher correctness across question sets.
- Evaluation used three user-question sets with human-rated responses (C or CV).

Read this paper
Open the full text in the Nubint reader and ask about any passage as you read.
Read this paper on NubintThis review was generated by AI from the original paper. Please check the paper before citing it.