Abstract
Retrieval-Augmented Generation (RAG) has emerged as a critical technique for mitigating hallucinations in Large Language Models (LLMs) by grounding responses in external data. While unstructured text RAG is common, Knowledge Graph-based RAG (KG-RAG) provides superior structured reasoning paths for complex queries. However, current KG-RAG frameworks suffer from a trade-off between the flexibility of modular methods and the accuracy of computationally expensive coupled methods. This paper introduces FRAG (Flexible Modular KG-RAG), a framework that bridges this gap. By utilizing a lightweight reasoning-aware module to predict query complexity, FRAG routes questions to specialized retrieval pipelines. Experimental results demonstrate that FRAG achieves state-of-the-art performance, improving accuracy on complex datasets by up to 75% while reducing training time from hours to minutes.
1. Introduction
Large Language Models (LLMs) often struggle with factual accuracy and complex reasoning when relying solely on internal parameters. RAG addresses this by fetching relevant external information. Knowledge Graphs (KGs) are particularly effective for this purpose because they represent data as interconnected entities and relations, allowing for multi-hop reasoning.
Existing KG-RAG approaches generally fall into two categories: modular methods, which are easy to deploy but often use inefficient "one-size-fits-all" retrieval strategies, and coupled methods, which fine-tune the LLM to the KG. While coupled methods are accurate, they are rigid and require significant computational resources. FRAG addresses these limitations by introducing a modular framework that adapts its retrieval strategy based on the linguistic complexity of the input query.
2. Methodology
FRAG operates through a three-stage modular pipeline designed to optimize both accuracy and efficiency.
2.1 Reasoning-aware Module
The first stage involves a lightweight classifier based on DeBERTaV3. Unlike traditional methods that perform expensive graph lookups to determine query difficulty, FRAG analyzes the query text alone. It classifies questions as either Simple (requiring 1-2 hops) or Complex (requiring 3 or more hops). This text-based prediction allows the system to anticipate the necessary reasoning depth with near-zero computational overhead.
2.2 Flexible-retrieval Module
Based on the complexity prediction, the query is routed to a tailored retrieval pipeline:
- Preprocessing: The system extracts a relevant subgraph and applies pruning algorithms like Personalized PageRank (PPR) to manage the search space.
- Tailored Retrieval: For simple queries, FRAG employs Breadth-First Search (BFS) to capture comprehensive local context. For complex queries, it utilizes Dijkstra’s algorithm to identify the shortest reasoning paths. This prevents the "path explosion" problem where deep searches generate excessive noise.
- Postprocessing: A Path Ranking Model (PRM) filters the results to ensure only the most semantically relevant paths are passed to the LLM.
2.3 Reasoning and Fast Adaptation
The final reasoning module provides the LLM with the query and the filtered reasoning paths. A unique feature of FRAG is its Fast Adaptation strategy—an optional feedback loop. By evaluating LLM performance on a small sample set, the system can refine the complexity classifier, allowing the framework to improve over time without the need for full model fine-tuning.
3. Experimental Setup
The framework was evaluated using two primary benchmarks:
- WebQSP: Focused on simpler, 1-2 hop questions.
- CWQ (Complex WebQuestions): Focused on multi-hop reasoning, where over 20% of questions require complex paths.
- KG-1000: A balanced dataset curated by the authors to test performance across varying complexity levels.
4. Results and Discussion
FRAG demonstrates significant improvements over existing modular frameworks like ToG and coupled methods like RoG.
4.1 Performance Gains
On the CWQ dataset using the Llama-3-8B model, FRAG improved accuracy from 37.0% to 64.9%. This represents a 75% relative improvement, showcasing the effectiveness of routing complex queries through specialized path-finding algorithms.
4.2 Efficiency and Scalability
FRAG offers a drastic reduction in resource requirements. While coupled methods like RoG require approximately 38 hours of fine-tuning for a 7B parameter model, FRAG’s reasoning-aware module can be trained in just 306 seconds. Furthermore, FRAG achieves "zero-call retrieval." Unlike other modular frameworks that may require up to 13 iterative LLM calls to find the correct path, FRAG performs its entire retrieval process without additional LLM overhead, significantly increasing inference speed.
5. Conclusion and Future Work
FRAG proves that structural complexity in Knowledge Graphs can be predicted from text, allowing for a flexible and efficient RAG pipeline. By avoiding the high costs of fine-tuning and the noise of unoptimized retrieval, FRAG sets a new standard for modular KG-RAG. Future research will explore the use of advanced neural retrievers to replace traditional ranking algorithms and test the framework's adaptability to more heterogeneous, real-world Knowledge Graphs.
Summary updated