Aigenthix/Graph_RAG
๐ฌ RAG Comparison Suite
Compare Simple RAG vs Agentic RAG vs Graph RAG performance on your documents.
A production-ready application for benchmarking and analyzing three different Retrieval-Augmented Generation approaches using Groq's fastest LLMs.
โจ Features
๐ฏ Three RAG Modes
Simple RAG - Fast & Cost-Effective
- Direct retrieval + generation
- Average latency: 620ms
- Best for: Real-time applications, FAQ systems
- Cost: $0.0018/query
Agentic RAG - Accurate & Complex
- Multi-step reasoning with tool use
- Average latency: 1800ms
- Best for: Research, problem-solving
- Cost: $0.0045/query
Graph RAG - Balanced & Relational
- Knowledge graph-based retrieval
- Average latency: 950ms
- Best for: Entity relationships, knowledge bases
- Cost: $0.0030/query
๐ค Four Groq Models
- Llama 3.1 8B - Fastest (for real-time)
- Llama 3.3 70B - Best Quality
- GPT-OSS 120B - Enterprise-Grade
- GPT-OSS 20B - Balanced
๐ Advanced Features
โ Document Upload - PDF and CSV support โ Real-time Metrics - Latency, tokens, cost tracking โ Benchmarking - Automated performance testing โ HTML Reports - Professional result visualization โ Source Citations - Track which documents were used โ Performance Tuning - Temperature and top-k controls โ Cost Analysis - Per-query cost breakdown โ Comparison Matrix - Side-by-side mode comparison
๐ Quick Start
1. Add API Key
- Go to Settings โ Repository secrets
- Add secret:
GROQ_API_KEY - Get key from: https://console.groq.com/keys
2. Upload Document
- Click Upload button
- Select PDF or CSV file (max 50MB)
- Wait for processing
3. Submit Query
- Type your question
- Select RAG mode (Simple, Agentic, or Graph)
- Choose model (8B, 70B, 120B, or 20B)
- Click Submit
4. View Results
- See generated answer
- Check metrics:
- โฑ๏ธ Response time (ms)
- ๐ข Token usage
- ๐ฐ Cost estimate
- ๐ Sources used
- ๐ฏ Confidence score
5. Compare Modes
- Try different RAG modes on same query
- Compare performance metrics
- Choose best mode for your use case
๐ Performance Comparison
Latency (milliseconds)
Query Type Simple Agentic Graph
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
Direct Fact Lookup 620 1800 950
Multi-Document 1200 3200 1800
Complex Reasoning 1500 3800 2100Accuracy (by query type)
Query Type Simple Agentic Graph
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
Direct Lookup 100% 100% 100%
Inference 78% 88% 85%
Multi-doc Summary 72% 82% 80%Cost per Query
Simple RAG: $0.0018 โ Cheapest
Graph RAG: $0.0030 (1.7x)
Agentic RAG: $0.0045 (2.5x)Monthly Cost (10,000 queries)
Simple RAG: $18
Graph RAG: $30
Agentic RAG: $45๐ฏ Use Cases
Use Simple RAG When...
โ Response time < 1 second required โ Budget-conscious ($15-20/month) โ Simple fact lookups โ High throughput needed (>1000 qps) โ Real-time applications
Examples: FAQ systems, document search, knowledge lookup
Use Agentic RAG When...
โ Accuracy > 85% required โ Multi-step reasoning needed โ Complex document synthesis โ Tool use / sub-queries needed โ Expert analysis required
Examples: Research synthesis, problem-solving, analysis reports
Use Graph RAG When...
โ Entity relationships important โ Knowledge extraction critical โ Balanced latency/accuracy (1-2s) โ Domain expertise required โ Complex document linking
Examples: Knowledge bases, expert systems, relationship queries
๐ง Configuration
Temperature & Sampling
For Creative Responses (Agentic):
temperature: 0.8
top_k: 40
For Factual Responses (Simple, Graph):
temperature: 0.3
top_k: 10Chunk Settings
Simple RAG: 512 tokens/chunk
Agentic RAG: 1024 tokens/chunk
Graph RAG: 256 tokens/chunkModel Selection Guide
Fast needed? โ Llama 3.1 8B
Quality needed? โ Llama 3.3 70B
Enterprise grade? โ GPT-OSS 120B
Balanced? โ GPT-OSS 20B๐ Benchmarking
Run Local Benchmarks
# Benchmark all modes (10 iterations each)
python benchmark.py --mode all --iterations 10
# Benchmark specific mode
python benchmark.py --mode simple --model llama-3.1-8b-instant
# With custom output
python benchmark.py --output my_results.jsonGenerate HTML Reports
# Generate report from benchmark results
python rag_comparison_report.py
# View in browser
open rag_comparison_report.html๐ Documentation
Getting Started
- [Deployment Guide](HF_DEPLOYMENT_GUIDE.md) - Step-by-step deployment
- [Quick Reference](README_HF_UPLOAD.txt) - Files & commands
Understanding RAG Modes
- [Comparison Guide](HF_RAG_COMPARISON.md) - Detailed comparison
- [Sample Results](BENCHMARK_DATA_SAMPLES.md) - Real examples
Advanced Topics
- [File Manifest](HF_UPLOAD_MANIFEST.md) - File inventory
- [Complete Package](HF_COMPLETE_PACKAGE.md) - Full overview
๐ ๏ธ Supported Formats
โ๏ธ Technical Details
Architecture
- Frontend: HTML5 + CSS3 + Vanilla JavaScript
- Backend: Flask (Python 3.11+)
- LLM Provider: Groq API
- Embeddings: Sentence Transformers (all-MiniLM-L6-v2)
- Vector DB: Chromadb
- Document Parsing: PyPDF2, Pandas
Requirements
- Python 3.11+
- 4GB RAM minimum
- 500MB disk space
- Groq API key
Performance
- Initial load: ~30 seconds
- Query response: 600ms - 4000ms
- Document processing: Varies by size
- Memory usage: 2-4GB
๐ Security
โ API keys stored in HF Secrets (not in code) โ Input validation on all queries โ File upload size limited (50MB) โ No sensitive data in logs โ CORS properly configured โ Dependencies pinned to versions
๐ Support & Troubleshooting
Common Issues
Q: API Key Error A: Verify GROQ_API_KEY is set in Space Settings โ Secrets
Q: Models Not Showing A: Check browser console, try hard refresh (Cmd+Shift+R)
Q: Query Timeout A: Try with smaller document, use faster model (8B), or check Groq API status
Q: Upload Fails A: File must be <50MB, PDF or CSV format, valid encoding
Q: Build Failed A: Check logs in Space, verify Python 3.11 available
Get Help
- Deployment: See
HF_DEPLOYMENT_GUIDE.mdโ Troubleshooting - Comparison: See
HF_RAG_COMPARISON.mdโ Use Cases - Benchmarking: See
BENCHMARK_DATA_SAMPLES.mdโ Examples - Files: See
HF_UPLOAD_MANIFEST.mdโ Inventory
๐ Deployment Info
Status: โ Production Ready Version: 2.0 Size: ~600 KB Deploy Time: 25-30 minutes Cost: Free HF Spaces + Groq API usage
Deploy Locally
pip install -r requirements_hf.txt
export GROQ_API_KEY=your_key_here
python app_docker.py
# Visit http://localhost:5000Deploy on HF Spaces
See HF_DEPLOYMENT_GUIDE.md for step-by-step instructions.
๐ Comparison Matrix
๐ Learning Resources
For Understanding RAG
- Read:
HF_RAG_COMPARISON.md - Review: Comparison matrices
- See: Sample results below
For Using This App
- Upload test document
- Try different RAG modes
- Compare metrics
- Pick best for your use case
For Advanced Usage
- Run
benchmark.pylocally - Generate HTML reports
- Analyze batch results
- Optimize settings
๐ก Tips & Best Practices
For Best Results
- Document Quality: Clear, well-structured text
- Query Specificity: Detailed questions get better answers
- Model Selection: Match model to latency requirements
- Mode Selection: Use comparison matrix to decide
- Temperature: Lower = factual, Higher = creative
For Cost Optimization
- Use Simple RAG when possible
- Use Llama 8B instead of 70B
- Batch similar queries
- Monitor token usage
- Review monthly costs
For Accuracy Improvement
- Use Agentic RAG for complex queries
- Increase document chunk overlap
- Use larger models (70B, 120B)
- Provide detailed context
- Test with representative queries
๐ Quick Stats
๐ Ready to Compare?
- โ
Add your
GROQ_API_KEYto Secrets - โ Upload your document
- โ Submit a query
- โ Compare the results!
Questions? See the documentation links above.
Status: โ Production Ready | Version: 2.0 | Updated: 2026-06-25
๐ฌ Start comparing RAG modes now!
