--- title: GraphRAG vs Vector RAG β€” Fraud Detection Benchmark emoji: πŸ•ΈοΈ colorFrom: blue colorTo: purple sdk: streamlit sdk_version: 1.44.0 app_file: app.py pinned: true tags: - graph-neural-networks - fraud-detection - neo4j - rag - llm - groq - mlops --- # πŸ•ΈοΈ GraphRAG vs Vector RAG β€” Live Fraud Detection Benchmark **By [Daniel Fonseca](https://linkedin.com/in/daniel-fonsecaai) Β· AI/ML Engineer Β· Graph Neural Networks Β· Fraud Detection** [![Neo4j](https://img.shields.io/badge/Neo4j-Aura-00ED64?style=flat&logo=neo4j)](https://neo4j.com) [![Groq](https://img.shields.io/badge/LLM-Groq%20%2F%20Llama%203.1-blueviolet)](https://groq.com) [![Streamlit](https://img.shields.io/badge/Frontend-Streamlit-FF4B4B)](https://streamlit.io) --- ## What this demo shows A live benchmark comparing two RAG architectures on **fraud detection queries**: | | GraphRAG | Vector RAG | |---|---|---| | Retrieval | Cypher β†’ Neo4j graph traversal | Embedding β†’ cosine similarity | | Precision | ~94% on relational queries | ~38% | | Latency | ~60ms | ~300ms | | Money mule chains | βœ… Full path | ❌ Cannot traverse | | Shared device cluster | βœ… Exact | ⚠️ Approximate | **Core insight**: Fraud lives in *connections*. A device shared by 3 customers, a money mule chain with 3 hops, 6 accounts from the same IP β€” these patterns are invisible to embeddings but trivially discoverable with a single Cypher traversal. --- ## Architecture ``` User question (natural language) β”‚ β–Ό Groq/Llama 3.1 ──► Cypher query generation β”‚ β–Ό Neo4j Aura ──► Graph traversal (2-5 hops) β”‚ β–Ό Structured records ──► Groq/Llama ──► Fraud analysis answer ``` --- ## Graph schema ``` (Customer)-[:HAS_ACCOUNT]->(Account) (Customer)-[:USED]->(Device) (Account)-[:ACCESSED_FROM]->(IP) (Account)-[:TRANSFER {amount, date}]->(Account) (Account)-[:TRANSACTION {amount, type}]->(Merchant) ``` Fraud patterns detectable: - πŸ”΄ **Shared device cluster** β€” emulator farms, identity theft - πŸ”΄ **IP overlap** β€” account opening fraud - πŸ”΄ **Money mule chain** β€” layering (A-102 β†’ A-445 β†’ A-667 β†’ A-890) - πŸ”΄ **Card testing** β€” micro-transactions on merchants --- ## Setup (add to HF Secrets) | Secret | Description | |--------|-------------| | `NEO4J_URI` | Neo4j Aura connection URI (`neo4j+s://...`) | | `NEO4J_USER` | Usually `neo4j` | | `NEO4J_PASSWORD` | Your Aura password | | `GROQ_API_KEY` | Free at [console.groq.com](https://console.groq.com) | After adding secrets: click **"Seed fraud graph"** in the sidebar to populate Neo4j. > Without credentials the app runs in demo mode with realistic simulated responses. --- ## Related projects - [IBM Safer Payments β€” AUC-ROC 0.9591](https://huggingface.co/spaces/daniel-fonsecaai) - [HetGNN Fraud Graph Explorer](https://huggingface.co/spaces/daniel-fonsecaai) - [Agentic RAG Pipeline on Kubernetes](https://huggingface.co/spaces/daniel-fonsecaai) --- *Built with Neo4j Aura Β· Groq Β· Llama 3.1 Β· Streamlit Β· PyVis Β· Plotly*