A comprehensive evaluation framework comparing various RAG approaches using the RAGAS evaluation framework with research-based enhancements.
- ChromaDB RAG - Traditional vector similarity search
- GraphRAG - Multi-hop graph traversal with entity resolution
- Advanced GraphRAG - Community detection and element summarization
- Text2Cypher - Natural language to Cypher query translation
- Neo4j Vector - Graph database vector search
- Hybrid Cypher - Combined vector + graph traversal
- DRIFT GraphRAG - Dynamic reasoning with iterative fact-finding
- Research-based corpus sampling with TF-IDF clustering and stratified selection
- Domain-aware entity extraction (financial, medical, legal, technical, academic)
- Multi-strategy text sampling for optimal entity type discovery
- Quality metrics and performance analysis
- Multiple dataset presets from nano (10 docs) to full (60K docs)
- Domain-specific benchmarks with rich metadata
- JSONL format for flexible evaluation data
- Automated Q&A pair generation for evaluation
All approaches are evaluated using RAGAS framework with automated visualizations and comprehensive performance metrics.
- GraphRAG Patterns: Neo4j GraphRAG Field Guide
- Microsoft GraphRAG: Community Summary Retrievers
- DRIFT Algorithm: Microsoft DRIFT Research
- Entity Discovery: 2025 research in ontology discovery and active learning
RAGvsGraphRAG/
βββ π data_processors/ # Document processing and graph construction
β βββ process_data.py # π― Main CLI for data processing
β βββ build_graph/ # Graph processor
β β βββ main_processor.py # Main orchestrator class
β β βββ entity_discovery.py # Research-based entity discovery
β β βββ text_processing.py # PDF extraction, chunking, embeddings
β β βββ graph_operations.py # Neo4j operations & entity resolution
β β βββ README.md # Technical deep-dive documentation
β βββ chroma_processor.py # ChromaDB vector processing
β βββ graph_processor.py # Legacy processor (use build_graph instead)
β βββ advanced_graph_processor.py # Community detection and summarization
βββ π retrievers/ # RAG retrieval implementations
β βββ chroma_retriever.py # ChromaDB vector similarity search
β βββ graph_rag_retriever.py # Multi-hop graph traversal
β βββ advanced_graphrag_retriever.py # Community-enhanced GraphRAG
β βββ text2cypher_retriever.py # Natural language to Cypher
β βββ neo4j_vector_retriever.py # Neo4j vector search
β βββ hybrid_cypher_retriever.py # Combined vector + graph
β βββ drift_graphrag_retriever.py # Dynamic reasoning approach
β βββ README.md # Retriever usage guide
βββ π benchmark/ # Evaluation framework
β βββ ragas_benchmark.py # π― Main evaluation CLI
β βββ visualizations.py # Automated chart generation
β βββ benchmark.csv # Default benchmark dataset
β βββ ragbench/ # RAGBench dataset integration
β β βββ simple_ingester.py # Dataset processor
β β βββ evaluator.py # Q&A data preparation
β β βββ results_formatter.py # Human-readable reports
β β βββ configs.py # Preset configurations
β β βββ README.md # RAGBench documentation
β βββ README.md # Benchmarking guide
βββ π benchmark_outputs/ # Generated results and visualizations
βββ π tests/ # Test and validation scripts
βββ π PDFs/ # Source documents for processing
βββ π chroma_db/ # ChromaDB vector store data
βββ π requirements.txt # Python dependencies
# Install dependencies
pip install -r requirements.txt
# Copy and configure .env file from template
cp .env_example .env
# Configure your settings in .env:
# - Provider selection (openai, ollama, vertexai)
# - Embedding model selection
# - Neo4j connection details
# - API keys as needed
# See .env_example for all available options- VertexAI/Ollama: 768 dimensions
- OpenAI (small/ada-002): 1536 dimensions
- OpenAI (large): 3072 dimensions
You must use the same embedding model for data ingestion AND querying!
See Embedding Dimensions Guide for detailed information.
# Using Docker (recommended)
docker run --name neo4j-rag \
-p 7474:7474 -p 7687:7687 \
-e NEO4J_AUTH=neo4j/password \
neo4j:latest# Place PDFs in PDFs/ folder, then:
python data_processors/process_data.py --pdfs# Quick test with nano preset (10 documents)
python data_processors/process_data.py --ragbench --preset nano
# Or larger dataset with domain hint
python data_processors/process_data.py --ragbench --preset micro --domain financial
# See all available presets
python data_processors/process_data.py --list-presets
# This creates:
# - Neo4j graph with dynamically discovered entities and relationships
# - ChromaDB vector store for similarity search
# - Entity resolution to merge duplicates using LLM evaluation
# - Corpus-wide entity discovery with CLI approval and caching# Compare all RAG approaches (uses default benchmark.csv with 18 questions)
python benchmark/ragas_benchmark.py --all
# Use RAGBench evaluation data (automatically created during processing)
python benchmark/ragas_benchmark.py --all --jsonl benchmark/ragbench__nano_benchmark.jsonl
# Selective testing
python benchmark/ragas_benchmark.py --chroma --graphrag --text2cypher--jsonl file.jsonlβ Uses specified JSONL file (highest priority)--csv file.csvβ Uses specified CSV file- No file specified β Uses default
benchmark/benchmark.csv(18 questions)
# Examples:
python benchmark/ragas_benchmark.py --hybrid-cypher # Uses default CSV
python benchmark/ragas_benchmark.py --hybrid-cypher --jsonl my.jsonl # Uses custom JSONL--hybrid-cypher) determine which retriever to test, not which file to use.
- Neo4j Browser: http://localhost:7474 (explore the knowledge graph)
- Charts:
benchmark_outputs/folder (performance comparisons) - Detailed Reports: HTML reports with individual Q&A analysis
- Multi-strategy corpus sampling with TF-IDF clustering and stratified selection
- Domain-aware entity extraction with hints for financial, medical, legal, technical domains
- Quality metrics including diversity scores and compression ratios
- Interactive CLI approval for discovered entity types
- Multiple dataset presets from nano (10 docs) to full (60K docs)
- Rich metadata with domain, dataset, and record IDs
- JSONL format for flexible evaluation data
- Automated Q&A generation for comprehensive evaluation
- ChromaDB RAG - Fast vector similarity search
- GraphRAG - Multi-hop graph traversal with entity resolution
- Advanced GraphRAG - Community detection and element summarization
- Text2Cypher - Natural language to database queries
- Neo4j Vector - Graph database vector search
- Hybrid Cypher - Combined vector + graph approach
- DRIFT GraphRAG - Dynamic reasoning with iterative refinement
- RAGAS metrics - Context Recall, Faithfulness, Factual Correctness
- Automated visualizations - Performance charts and heatmaps
- Detailed reports - HTML, CSV, and JSON outputs
- Human-readable analysis - Individual Q&A breakdowns
- Data Processors - Data processing and ingestion guide
- Build Graph - Technical deep-dive on enhanced graph processing
- Retrievers - Retrieval approaches and usage patterns
- Benchmark - Evaluation framework and RAGAS integration
- RAGBench - RAGBench dataset integration details
- Embedding Dimensions -
β οΈ IMPORTANT: Guide for handling different embedding models and dimensions
- Python 3.8+
- Neo4j Database (Docker recommended)
- OpenAI API Key (for embeddings and LLM processing)
- 8GB+ RAM (for larger datasets)
- Optional: scikit-learn (for enhanced entity discovery)
Neo4j graph-enhanced vector search with dynamic entity discovery. Automatically discovers entity types from your documents with CLI approval. Includes LLM-based entity resolution to merge duplicates.
Intelligent routing between global community search and local entity search with element summarization and community detection.
Iterative refinement algorithm with dynamic follow-ups and multi-depth exploration using NetworkX action graphs.
Natural language to Cypher query translation with direct Neo4j graph database querying and schema-aware prompt engineering.
Pure Neo4j vector similarity search using native vector operations without graph traversal for fast retrieval - good to compare against vector only databases such as ChromaDB.
The benchmark evaluates all approaches using three key RAGAS metrics:
How well the retrieval system finds relevant information needed to answer the question.
How faithful the generated answer is to retrieved context without hallucination.
How factually accurate the response is compared to ground truth reference answers.
The Average Score for each approach is calculated as:
Average Score = (Context Recall + Faithfulness + Factual Correctness) / 3
The graph processor now features intelligent entity discovery that adapts to your document content:
- Corpus Analysis: Analyzes your entire document collection using hybrid sampling (first/last 500 chars + entity-rich patterns)
- LLM Proposal: GPT-4 proposes relevant entity types based on document content
- CLI Approval: You review and approve/modify the proposed entities
- Schema Caching: Approved entities are cached for reuse across runs
- Dynamic Extraction: Extracts only the approved entity types from each document chunk
Simply run the graph processor and it will automatically discover entities from your documents:
python data_processors/graph_processor.py- Adaptive: Discovers entities relevant to your specific domain (contracts, medical, legal, etc.)
- Consistent: Single entity schema applied across all documents in a corpus
- Efficient: Caches approved schemas to avoid re-discovery
- User-Controlled: You approve all entity types before processing
π Analyzing corpus with LLM...
π Proposed entities: Contract, Vendor, Deliverable, Timeline, Budget, Compliance
β
Approve these entities? (y/n/edit): y
π Processing documents with approved entities...
- Add PDFs: Place new PDF files in the
PDFs/directory - Reprocess: Run your chosen processing command again:
python data_processors/graph_processor.py # Reprocesses all PDFs - Test: Validate with
python tests/test_ragas_setup.py
- Edit questions: Modify
benchmark/benchmark.csv:question,ground_truth Your custom question?,Expected answer here - Run benchmark:
python benchmark/ragas_benchmark.py --all
# Verify all systems working
python tests/check_chromaDB.py # ChromaDB status
python tests/check_schema.py # Neo4j schema and statistics
python tests/test_ragas_setup.py # All approaches validation- Set up environment variables in
.env - Run
pip install -r requirements.txt - Add PDFs to
PDFs/directory - Choose processing level:
python data_processors/graph_processor.py - Validate setup:
python tests/test_ragas_setup.py - Run benchmark:
python benchmark/ragas_benchmark.py --all
python benchmark/ragas_benchmark.py --hybrid-cypher --chroma --neo4j-vector --graphrag --advanced-graphrag --limit 1 --jsonl benchmark/ragbench__nano_benchmark.jsonl
python benchmark/ragas_benchmark.py --hybrid-cypher --chroma --neo4j-vector --graphrag --advanced-graphrag --text2cypher --limit 1