back to home

neo4j / neo4j-graphrag-python

Neo4j GraphRAG for Python

1,080 stars
188 forks
37 issues
Python

AI Architecture Analysis

This repository is indexed by RepoMind. By analyzing neo4j/neo4j-graphrag-python in our AI interface, you can instantly generate complete architecture diagrams, visualize control flows, and perform automated security audits across the entire codebase.

Our Agentic Context Augmented Generation (Agentic CAG) engine loads full source files into context on-demand, avoiding the fragmentation of traditional RAG systems. Ask questions about the architecture, dependencies, or specific features to see it in action.

Source files are only loaded when you start an analysis to optimize performance.

Embed this Badge

Showcase RepoMind's analysis directly in your repository's README.

[![Analyzed by RepoMind](https://img.shields.io/badge/Analyzed%20by-RepoMind-4F46E5?style=for-the-badge)](https://repomind.in/repo/neo4j/neo4j-graphrag-python)
Preview:Analyzed by RepoMind

Repository Overview (README excerpt)

Crawler view

Neo4j GraphRAG Package for Python The official Neo4j GraphRAG package for Python enables developers to build graph retrieval augmented generation (GraphRAG) applications using the power of Neo4j and Python. As a first-party library, it offers a robust, feature-rich, and high-performance solution, with the added assurance of long-term support and maintenance directly from Neo4j. 📄 Documentation Documentation can be found here Resources A series of blog posts demonstrating how to use this package: • Build a Knowledge Graph and use GenAI to answer questions: • GraphRAG Python Package: Accelerating GenAI With Knowledge Graphs • Retrievers: when the Neo4j graph is already populated: • Getting Started With the Neo4j GraphRAG Python Package • Enriching Vector Search With Graph Traversal Using the GraphRAG Python Package • Hybrid Retrieval for GraphRAG Applications Using the GraphRAG Python Package • Enhancing Hybrid Retrieval With Graph Traversal Using the GraphRAG Python Package • Effortless RAG With Text2CypherRetriever A list of Neo4j GenAI-related features can also be found at Neo4j GenAI Ecosystem. 🐍 Python Version Support | Version | Supported? | |---------|-----------:| | 3.14 | ✓ | | 3.13 | ✓ | | 3.12 | ✓ | | 3.11 | ✓ | | 3.10 | ✓ | 📦 Installation To install the latest stable version, run: Optional Dependencies This package has some optional features that can be enabled using the extra dependencies described below: • LLM providers (at least one is required for RAG and KG Builder Pipeline): • **ollama**: LLMs from Ollama • **openai**: LLMs from OpenAI (including AzureOpenAI) • **google**: LLMs from Vertex AI • **cohere**: LLMs from Cohere • **anthropic**: LLMs from Anthropic • **mistralai**: LLMs from MistralAI • **sentence-transformers** : to use embeddings from the Python package • Vector database (to use :ref: ): • **weaviate**: store vectors in Weaviate • **pinecone**: store vectors in Pinecone • **qdrant**: store vectors in Qdrant • **experimental**: experimental features mainly related to the Knowledge Graph creation pipelines. • **nlp**: installs spaCy for NLP pipelines, used by in the experimental KG builder components. • **fuzzy-matching**: installs RapidFuzz, used by in the experimental KG builder components. > Note: The ** ** extra is currently **not supported on Python 3.14** due to an upstream spaCy import-time issue (spaCy #13895). Use Python **3.13 or earlier** for spaCy-based features until that is resolved upstream. Install package with optional dependencies with (for instance): 💻 Example Usage The scripts below demonstrate how to get started with the package and make use of its key features. To run these examples, ensure that you have a Neo4j instance up and running and update the , , and variables in each script with the details of your Neo4j instance. For the examples, make sure to export your OpenAI key as an environment variable named . Additional examples are available in the folder. Knowledge Graph Construction **NOTE: The APOC core library must be installed in your Neo4j instance in order to use this feature** This package offers two methods for constructing a knowledge graph. The class provides extensive customization options, making it ideal for advanced use cases. See the folder for examples of how to use this class. For a more streamlined approach, the class offers a simplified abstraction layer over the , making it easier to build knowledge graphs. Both classes support working directly with text and PDFs. > Warning: In order to run this code, the Python package needs to be installed: Example knowledge graph created using the above script: Creating a Vector Index When creating a vector index, make sure you match the number of dimensions in the index with the number of dimensions your embeddings have. Populating a Vector Index This example demonstrates one method for upserting data in your Neo4j database. It's important to note that there are alternative approaches, such as using the Neo4j Python driver. Ensure that your vector index is created prior to executing this example. Performing a Similarity Search Please note that when querying a Neo4j vector index _approximate_ nearest neighbor search is used, which may not always deliver exact results. For more information, refer to the Neo4j documentation on limitations and issues of vector indexes. In the example below, we perform a simple vector search using a retriever that conducts a similarity search over the vector index. This library provides more retrievers beyond just the . See the folder for examples of how to use these retrievers. Before running this example, make sure your vector index has been created and populated. 🤝 Contributing You must sign the contributors license agreement in order to make contributions to this project. Install Dependencies Our Python dependencies are managed using uv. If uv is not yet installed on your system, you can follow the instructions here to set it up. To begin development on this project, start by cloning the repository and then install all necessary dependencies, including the development dependencies, with the following command: Reporting Issues If you have a bug to report or feature to request, first search to see if an issue already exists. If a related issue doesn't exist, please raise a new issue using the issue form. If you're a Neo4j Enterprise customer, you can also reach out to Customer Support. If you don't have a bug to report or feature request, but you need a hand with the library; community support is available via Neo4j Online Community and/or Discord. Workflow for Contributions • Fork the repository. • Install Python and uv. • Create a working branch from and start with your changes! Code Formatting and Linting Our codebase follows strict formatting and linting standards using Ruff for code quality checks and Mypy for type checking. Before contributing, ensure that all code…