Graphy is a powerful Graph Retrieval-Augmented Generation (GraphRAG) application built with LangGraph, Groq, and Neo4j. It allows users to upload PDF documents, extract structured knowledge into a graph database, and perform complex queries using natural language.
- PDF Knowledge Extraction: Upload PDF documents and automatically extract entities and relationships.
- GraphRAG Engine: Combines the power of Knowledge Graphs with LLMs for more accurate and context-aware answers.
- Natural Language Querying: Ask questions in plain English; the app converts them into Cypher queries to retrieve data from Neo4j.
- Powered by Groq: Utilizes the lightning-fast inference of Groq with support for multiple models (Llama 3.3, Llama 3.1, Mixtral, Gemma) to ensure reliability and performance.
- LangGraph Orchestration: Uses a stateful graph workflow to manage the query generation, execution, and response formatting pipeline.
- Frontend: Streamlit
- LLM: Llama 3.3, Llama 3.1, Mixtral, Gemma 2 (via Groq API)
- Graph Database: Neo4j
- Orchestration: LangGraph
- Framework: LangChain
- Embeddings: HuggingFace (
sentence-transformers/all-MiniLM-L6-v2) - PDF Processing: PyMuPDF
Before running the application, ensure you have the following:
- Python 3.9+ installed.
- A Neo4j Database (AuraDB Free tier works great).
- A Groq API Key.
-
Clone the repository:
git clone <repository-url> cd <repository-folder>
-
Install dependencies:
pip install streamlit python-dotenv langchain-community langchain-core langchain-groq langchain-huggingface langchain-neo4j langchain-experimental langgraph pymupdf neo4j
-
Set up Environment Variables: Create a
.envfile in the root directory and add your credentials:GROQ_API_KEY=your_groq_api_key NEO4J_URI=neo4j+s://your-instance.databases.neo4j.io NEO4J_USERNAME=neo4j NEO4J_PASSWORD=your_password
-
Run the Streamlit app:
python -m streamlit run main.py
-
Configure & Connect:
- Enter your Groq API Key and Neo4j credentials in the sidebar (or use
.env). - Select your preferred LLM Model (e.g., Llama 3.3, Mixtral) from the dropdown to handle rate limits or optimize performance.
- Click Connect & Initialize.
- Enter your Groq API Key and Neo4j credentials in the sidebar (or use
-
Upload a PDF:
- Use the file uploader to select a PDF document.
- The app will process the file, split the text, and extract a knowledge graph.
-
Ask Questions:
- Type your question in the input box (e.g., "What symptoms does the patient have?").
- The app will generate a Cypher query, execute it against the graph, and provide a natural language answer.
- Ingestion: The PDF is loaded using
PyMuPDFLoaderand split into chunks. - Extraction:
LLMGraphTransformer(powered by the selected Groq model) analyzes the text to identify nodes (e.g., Patient, Disease, Medication) and relationships. - Storage: The extracted graph data is stored in Neo4j.
- Retrieval (GraphRAG):
- Generate Cypher: The LLM translates the user's question into a Cypher query based on the graph schema.
- Execute: The query is run against the Neo4j database.
- Answer: The results are formatted and synthesized into a final answer by the LLM.
Contributions are welcome! Please feel free to submit a Pull Request.