Introduction
Retrieval-Augmented Generation (RAG) has become a cornerstone of modern AI applications, primarily focusing on grounding Large Language Models (LLMs) with unstructured text. However, the next frontier lies in GraphRAG, which utilizes structured knowledge graphs to provide even more precise context. While much of the existing literature focuses on Resource Description Framework (RDF) graphs and SPARQL, this paper explores the more expressive and industry-relevant Labeled Property Graphs (LPGs).
LPGs, utilized by databases like Neo4j and Memgraph, offer a flexible way to model complex relationships, such as those found in industrial digital twins. However, translating natural language into Cypher (the declarative query language for LPGs) is notoriously difficult. LLMs often struggle with variable schemas, frequently hallucinating non-existent node labels or property names that do not exist in the underlying database.
The Multi-Agent Architecture
To address these challenges, we propose a modular, multi-agent framework built on LangGraph. This system decomposes the complex task of query generation into a collaborative workflow involving seven specialized agents.
The workflow is centered around a Self-Correction Loop. When a user submits a question, the Query Generator creates an initial Cypher query. The Graph DB Executor then attempts to run it. If an error occurs or the Query Evaluator deems the result incomplete or logically flawed, the system triggers a verification process. The Named Entity Extractor and Entities Checker validate the query against the actual database schema, identifying hallucinations in node labels or properties. Finally, the Instructions Generator and Feedback Aggregator synthesize these findings into a "fix-it" prompt for the next iteration. The system can iterate up to four times to refine the query based on database-grounded feedback.
Experimental Setup and Datasets
The framework was rigorously tested against two primary benchmarks:
- CypherBench: A comprehensive dataset spanning five domains (art, flight accidents, companies, geography, and fictional characters) containing 7.8 million entities.
- IFC (Industry Foundation Classes) Data: A technical dataset representing a "Sample House" digital twin, designed to test the system's performance in the Architecture, Engineering, and Construction (AEC) domain.
Performance Analysis
The multi-agent approach demonstrated a clear advantage over traditional "single-pass" LLM prompts. By allowing the system to iterate based on database-grounded feedback, accuracy improved significantly across all tested models.
As shown in the results, Gemini 2.5 Pro emerged as the strongest backbone, with its accuracy rising from 67.00% to 77.23% when moving from a single-pass to an agentic setup. Other models like Qwen3 Coder and GPT-4o (2024-11-20) also saw substantial gains, with Qwen3 Coder seeing an average jump of +7.67%. On the specialized IFC dataset, the system successfully navigated complex spatial queries, such as calculating roof volumes, which often baffle standard RAG implementations.
Key Insights
- Schema-Aware Prompting: Presenting the database schema in a format that mimics actual Cypher syntax significantly reduces initial generation errors compared to simple lists of names.
- Iterative Learning: The system effectively "learns" the schema on the fly. For instance, if an LLM guesses a property name like
name, the Entities Checker identifies the correct property (e.g.,title) using Levenshtein similarity and provides a correction instruction. - LPG Expressiveness: By targeting LPGs rather than RDF triples, the framework more naturally handles multi-hop traversals and attribute-level reasoning required for complex industrial applications.
Limitations and Future Work
While the multi-agent framework marks a significant step forward, several challenges remain. The system occasionally struggles with compositional logic, particularly complex "OR" conditions that require merging disparate subqueries. Additionally, symmetric relationships (e.g., spouse relations) can lead to directionality errors during validation. Future research will focus on implementing multi-turn dialogue capabilities and more robust subgoal planning to handle multi-intent user questions and prevent semantic conflation.
Summary updated