A complete implementation of LightRAG using ArangoDB as the storage backend, demonstrating how knowledge graphs enable multi-hop reasoning that traditional RAG systems cannot achieve.
Traditional RAG retrieves documents based on vector similarity alone. It struggles with questions that require connecting information across multiple documents.
LightRAG + ArangoDB builds a knowledge graph from your documents, enabling:
- Multi-hop reasoning: Answer questions that require traversing relationships between entities
- Better context retrieval: Find relevant information through graph connections, not just semantic similarity
- Unified storage: Documents, embeddings, and relationships all stored in ArangoDB
- Docker & Docker Compose
- OpenAI API key (for embeddings and LLM)
git clone https://github.com/YOUR_USERNAME/lightrag-arangodb.git
cd lightrag-arangodb
# Create environment file
cp .env.example .env
# Add your OpenAI API key to .env
nano .env# Start ArangoDB and the LightRAG container
docker compose up -d --build
# Create the multihop database for the demo
docker exec arangodb-single arangosh \
--server.password openSesame \
--javascript.execute-string "db._createDatabase('multihop');"docker exec lightrag-app python multi_hop_demo.pyAfter running the full demo once, you can re-run queries against the existing database without re-ingesting:
# Copy query script to container
docker cp query_multihop.py lightrag-app:/app/
# Run queries only (saves results to JSON)
docker exec lightrag-app python query_multihop.py
# Get the results file
docker cp lightrag-app:/app/multihop_results.json ./The multi_hop_demo.py uses completely fabricated data about a fictional company called "Nexova Technologies" to prove that answers come from the knowledge graph—not the LLM's training data.
Document 1: "PJ Kowalski is the lead architect at Nexova Technologies. He reports directly to Daniel Chen."
Document 2: "Daniel Chen is the VP of Engineering. His office is on the 4th floor."
Query: "What floor is the office of the person who hired PJ Kowalski?"
Reasoning Path: PJ Kowalski → reports to Daniel Chen → office on 4th floor
A traditional vector search might not connect these documents, but the knowledge graph traverses:
- Find "PJ Kowalski" entity
- Follow relationship to "Daniel Chen" (reports to)
- Find "4th floor" connected to Daniel Chen's office
├── arangodb_impl.py # ArangoDB storage implementations for LightRAG
├── demo.py # Basic demo with sample documents
├── multi_hop_demo.py # Multi-hop reasoning demonstration (ingest + query)
├── query_multihop.py # Query-only script (no ingestion, saves results to JSON)
├── docker-compose.yml # Docker services configuration
├── Dockerfile # LightRAG container build
├── requirements.txt # Python dependencies
└── .env.example # Environment template
The query_multihop.py script saves detailed results to multihop_results.json:
{
"timestamp": "2026-02-25T...",
"summary": {
"naive_correct": 3,
"hybrid_correct": 7,
"total_queries": 8,
"winner": "hybrid"
},
"queries": [
{
"query": "What color is the car driven by the manager of employee NX-4472?",
"expected": "red",
"reasoning": "NX-4472 = PJ → PJ's manager = Daniel → Daniel's car = cherry red",
"hops": 3,
"naive": { "response": "...", "correct": false },
"hybrid": { "response": "...", "correct": true }
}
]
}This project implements all four LightRAG storage backends for ArangoDB:
| Storage Type | Class | Purpose |
|---|---|---|
| Graph | ArangoDBStorage |
Entity nodes and relationship edges |
| KV | ArangoDBKVStorage |
Document chunks and metadata |
| Vector | ArangoDBVectorStorage |
Embeddings for semantic search |
| Doc Status | ArangoDBDocStatusStorage |
Document processing tracking |
LightRAG supports different query modes:
from lightrag import LightRAG, QueryParam
# Vector-only search (like traditional RAG)
result = await rag.aquery(query, param=QueryParam(mode="naive"))
# Knowledge graph + vector search (multi-hop reasoning)
result = await rag.aquery(query, param=QueryParam(mode="hybrid", enable_rerank=False))Once running, access the ArangoDB web interface:
- URL: http://localhost:8530
- Username: root
- Password: openSesame
- Database: multihop
Explore the knowledge graph visually to see entities and their relationships!
# Required
OPENAI_API_KEY=sk-your-key-here
# ArangoDB (defaults work with docker-compose)
ARANGO_HOST=http://arangodb:8529
ARANGO_USERNAME=root
ARANGO_PASSWORD=openSesame
ARANGO_DATABASE=multihop- LightRAG Paper: LightRAG: Simple and Fast Retrieval-Augmented Generation
- LightRAG GitHub: HKUDS/LightRAG
- ArangoDB Docs: arangodb.com/docs
MIT License - feel free to use this for your own projects!
Built with ❤️ using LightRAG and ArangoDB