Causal Relationship Extraction GraphRAG
A system that automatically extracts cause-to-effect relationships from documents, stores them in a Neo4j graph, and lets users search and visualize causal chains in natural language.
Duration
Short-term development
Team
1 person
01 // OVERVIEW
Project Overview
A system that automatically extracts cause-and-effect relationships from input text documents and stores them in structured form in a Neo4j graph database. It supports natural-language causal chain exploration - such as tracing back to root causes or following downstream effects - and includes interactive graph visualization built with Streamlit and PyVis.
02 // KEY FEATURES
Key Features
Automatic Causal Extraction and Graph Building
Uses LangChain + OpenAI (gpt-4o-mini) to extract cause-effect pairs from documents and store them via Neo4j APOC. Simply entering text or a file in the sidebar builds the graph.
Natural-Language Causal Chain Exploration
Answers natural-language queries like "What caused X?" or "What is the root cause of X?" in either concise or detailed mode. Supports both tracing back to root causes and following downstream effects.
Interactive Graph Visualization
Combines a Streamlit app with PyVis + NetworkX to provide a browser-based visualization screen where nodes and edges can be manipulated interactively. Administrators can also add, delete, and edit the weights of nodes and edges.
03 // TECHNICAL DEEP-DIVE
Technical Highlights
Solution
Merging Identical Concepts Expressed Differently
To address the problem of the same concept, phrased differently across documents, being scattered across multiple nodes, we built in a feature to merge and link similar nodes, keeping the graph consistent.
Solution
A Design That Can Be Adapted to an On-Premise, API-Independent Setup
While built around cloud APIs, the architecture makes the LLM provider easy to swap, keeping migration to an on-premise environment (Ollama + Llama-family models) viable.
04 // IMPACT & RESULTS
Results
Neo4j
Persists causal relationships in a graph database
2 modes
Switch between concise and detailed answer formats
Docker-based
Launches instantly with docker compose up