Traditional RAG makes AI agents hallucinate statistics and aggregations. This demo compares RAG (FAISS, a vector similarity search library) vs Graph-RAG (Neo4j, a graph database) on 300 hotel FAQ documents to measure which approach reduces hallucinations.
Based on recent papers:
- RAG-KG-IL: Multi-Agent Hybrid Framework for Reducing Hallucinations — KG reduces hallucinations by 73% vs standalone LLMs
- MetaRAG: Metamorphic Testing for Hallucination Detection — Proves hallucinations are inherent to LLMs
- RAKG: Document-level Retrieval Augmented Knowledge Graph Construction — Automated KG construction from text
Research (RAG-KG-IL, 2025) identifies three types of RAG hallucinations:
- Fabricated statistics — LLM generates plausible-sounding numbers from text chunks instead of computing them (paper shows 73% more hallucinations without KG)
- Incomplete retrieval — Vector search returns top-k documents, missing data scattered across hundreds of documents (paper found 54 instances of missing information with RAG-only)
- Out-of-domain fabrication — When no relevant data exists, RAG returns similar-looking results and the LLM fabricates an answer (MetaRAG)
Graph-RAG solves this with:
- Native aggregations —
AVG(),COUNT()computed in the database, not guessed - Relationship traversal — Cypher queries follow exact paths (Hotel → Room → Amenity)
- Explicit failure — Empty results when data doesn't exist, no fabrication
| Capability | RAG | Graph-RAG |
|---|---|---|
| Aggregations (avg, count) | ❌ Cannot compute | ✅ Native database operations |
| Multi-hop reasoning | ❌ Limited to top-k docs | ✅ Relationship traversal |
| Counting across documents | ❌ Only sees 3 docs | ✅ Precise COUNT() |
| Missing data handling | ❌ Fabricates answers | ✅ Honest "no results" |
Two agents query the same 300 hotel FAQs with different approaches:
- RAG Agent → FAISS similarity search → top 3 docs → LLM summarizes
- Graph-RAG Agent → LLM writes Cypher queries from natural language (Text2Cypher) → Neo4j executes → precise results
- Python 3.9+
- Neo4j Desktop with APOC plugin
- OpenAI API key
uv venv && uv pip install -r requirements.txtCreate a .env file with your credentials:
# OpenAI API Key (required)
OPENAI_API_KEY=your_openai_api_key_here
# Neo4j Configuration (required for Graph-RAG demo)
NEO4J_URI=neo4j://127.0.0.1:7687
NEO4J_USER=neo4j
NEO4J_PASSWORD=your_neo4j_password_hereHow to get credentials:
- AWS Credentials: Install the AWS CLI and run
aws configurewith your Access Key ID and Secret Access Key. Amazon Bedrock access is required inus-east-1. - Neo4j Password: Use the password you set when starting Neo4j (see Step 5 of the workshop setup), or retrieve it from AWS Secrets Manager if running at an AWS event.
This demo uses the Hotel Booking Demand dataset adapted as hotel FAQ documents for knowledge graph construction.
At an AWS Event: The workshop environment pre-loads the data on the Code Editor EC2 instance. Skip this step.
Self-paced: Download hotel-faqs.zip from the workshop assets and extract:
# Download from workshop assets (link provided during setup)
unzip hotel-faqs.zip -d data/Option A: LITE Version (Recommended for Testing - ~10-15 minutes)
Process only 30 documents (10% of dataset) for quick testing:
# Build FAISS vector index (fast, ~30 seconds)
uv run load_vector_data_lite.py
# Build Neo4j knowledge graph (~10-15 minutes)
uv run build_graph_lite.pyOption B: Full Version (~2 hours)
Process all 300 documents for complete dataset:
# Build FAISS vector index (fast, ~1 min)
uv run load_vector_data.py
# Build Neo4j knowledge graph (slower, ~2 hours - uses LLM for entity extraction)
uv run build_graph.pyuv run travel_agent_demo.pyThe demo creates two agents that query the same 300 hotel FAQs:
# Traditional RAG Agent - uses vector search
rag_agent = Agent(
name="RAG_Agent",
tools=[search_faqs], # FAISS similarity search
model=OpenAIModel("gpt-4o-mini")
)
# Graph-RAG Agent - uses knowledge graph
graph_agent = Agent(
name="GraphRAG_Agent",
tools=[query_knowledge_graph], # Cypher queries on Neo4j
model=OpenAIModel("gpt-4o-mini")
)The graph is built automatically using neo4j-graphrag — no hardcoded schema:
from neo4j_graphrag.experimental.pipeline.kg_builder import SimpleKGPipeline
# No entities/relations defined — LLM discovers them from text
kg_builder = SimpleKGPipeline(
llm=llm,
driver=neo4j_driver,
embedder=embedder,
from_pdf=False,
perform_entity_resolution=True, # dedup similar entities
)
# Process each document
await kg_builder.run_async(text=document_text)The LLM reads each document and:
- Discovers entity types (Hotel, Room, Amenity, Policy, Service)
- Extracts relationships (HAS_ROOM, OFFERS_AMENITY, HAS_POLICY)
- Resolves duplicates (merges similar entities into single nodes)
If you add new documents with new entity types (Restaurant, Airport, etc.), the LLM discovers them automatically.
| Technology | Purpose |
|---|---|
| Strands Agents | AI agent framework |
| neo4j-graphrag | Automatic knowledge graph construction |
| Neo4j | Graph database |
| FAISS | Vector similarity search |
| SentenceTransformers | Text embeddings (runs locally, no API costs — swap for any embedding provider) |
APOC not found: APOC (Awesome Procedures On Cypher) is a Neo4j plugin that provides utility functions needed for graph operations. Install the APOC plugin in Neo4j Desktop from the Plugins tab, then restart the database.
Graph build slow: Each document takes ~30s (LLM extraction). 300 docs ≈ 2.5 hours. Run once.
API errors: Check has valid OPENAI_API_KEY
Model alternatives: All demos work with OpenAI, Anthropic, or Ollama — see Strands Model Providers
This demo uses Strands Agents. The same Graph-RAG pattern (knowledge graph + Text2Cypher) can be implemented with LangGraph, CrewAI, AutoGen, Haystack, or any framework that supports custom tool calling.
Research (RAG-KG-IL, 2025) shows knowledge graphs reduce hallucinations by 73% compared to standalone LLMs. In this demo, Graph-RAG correctly answers aggregation queries (averages, counts) and multi-hop questions that traditional RAG consistently gets wrong by fabricating statistics from text chunks.
No. The graph is built automatically using neo4j-graphrag's SimpleKGPipeline. The LLM reads each document and discovers entity types (Hotel, Room, Amenity, Policy), extracts relationships, and resolves duplicates — no hardcoded schema required. New entity types are discovered automatically when you add new documents.
The lite version (30 documents) takes approximately 15 minutes. The full version (300 documents) takes approximately 2 hours because each document requires LLM-based entity extraction (~30 seconds per document). You only need to build it once.
Demo 02 - Semantic Tool Selection — Reduce token waste and wrong tool picks with FAISS-based semantic filtering.
If you discover a potential security issue in this project, notify AWS/Amazon Security via the vulnerability reporting page. Please do not create a public GitHub issue.
This library is licensed under the MIT-0 License. See the LICENSE file for details.


