Neo4j Graphrag Python is Neo4j's first-party Python package for building graph retrieval-augmented generation (GraphRAG) applications on a Neo4j database. It covers two jobs: building a knowledge graph from unstructured text or PDFs, and retrieving context from an existing graph to ground an LLM's answer. It is the renamed continuation of the deprecated neo4j-genai package.
Knowledge graph construction runs through a configurable Pipeline class or the simpler SimpleKGPipeline, which takes a schema of node types, relationship types, and allowed patterns, has an LLM extract matching entities and relations, and writes them with embeddings into Neo4j. Entity resolution components (fuzzy matching and spaCy-based semantic matching) are available in an experimental namespace.
For retrieval, the package creates and populates Neo4j vector indexes and provides several retrievers: vector search, vector search enriched with graph traversal, hybrid vector and full-text search, and Text2Cypher, which turns a question into a Cypher query. A GraphRAG class combines a retriever with an LLM to answer questions. External retrievers can also read vectors stored in Weaviate, Pinecone, or Qdrant.
LLM and embedding providers are optional extras: OpenAI (including Azure OpenAI), Anthropic, Google Vertex AI and Gemini, Mistral, Cohere, Amazon Bedrock, Ollama, and sentence-transformers embeddings.
Features
- Knowledge graph builder: extracts entities and relations from text or PDFs into Neo4j, guided by a schema
- Pipeline customization: a configurable Pipeline class plus a simpler SimpleKGPipeline wrapper
- Vector indexes: creates and populates Neo4j vector indexes for chunk embeddings
- Retrievers: vector, vector plus graph traversal, hybrid vector and full-text, and Text2Cypher retrievers
- GraphRAG generation: combines a retriever with an LLM to answer questions from the graph
- External vector stores: retrievers for vectors kept in Weaviate, Pinecone, or Qdrant
- Model providers: OpenAI, Azure OpenAI, Anthropic, Vertex AI, Gemini, Mistral, Cohere, Bedrock, and Ollama
- Entity resolution (experimental): fuzzy and spaCy-based matching to merge duplicate entities


