How tomasonjo/neo4j-graphrag-python works
Neo4j GraphRAG is a Python library for building knowledge graphs and using graph-aware retrieval to ground generated answers. The main user path is query → retrieval → context-augmented generation. A separate construction path turns text or PDFs into graph data; the README identifies both a configurable pipeline and a simpler builder. The package also exposes vector-index management, multiple retrieval strategies, external vector-store retrievers, and provider adapters. Several implementation details are unsampled, so the graph shows documented capabilities but omits uncertain internal wiring.
Main entry points: kg_builder.py Simple KG builder · llm LLM adapters · tools_retriever.py Tools retriever · graphrag.py GraphRAG search
Components 21
Graph construction
- Simple KG builder
src/neo4j_graphrag/experimental/pipeline/kg_builder.py - Text and PDF loaders
src/neo4j_graphrag/components - Text splitters
src/neo4j_graphrag/components/text_splitters - Entity extraction
src/neo4j_graphrag/components/entity_relation_extractor.py - Entity resolution
src/neo4j_graphrag/components/resolver.py - Graph writer
src/neo4j_graphrag/components/kg_writer.py
Retrieval
- Vector index API
src/neo4j_graphrag/indexes.py - Neo4j retrievers
src/neo4j_graphrag/retrievers - External vector retrievers
src/neo4j_graphrag/retrievers/external - Tools retriever
src/neo4j_graphrag/retrievers/tools_retriever.py
Answer generation
- GraphRAG search
src/neo4j_graphrag/generation/graphrag.py
Model integrations
- LLM adapters
src/neo4j_graphrag/llm - Embedding adapters
src/neo4j_graphrag/embeddings
Pipeline runtime
- Pipeline engine
src/neo4j_graphrag/experimental/pipeline/pipeline.py - Component tasks
src/neo4j_graphrag/experimental/pipeline/component.py
Other components
- Application developer
- Questioner
- Neo4j database
- LLM provider
- Embedding provider
- External vector store
Connections 25
- Application developer → Simple KG builder: configures build
- Application developer → Vector index API: creates index
- Simple KG builder → Pipeline engine: runs pipeline
- Pipeline engine → Component tasks: executes tasks
- Simple KG builder → Text and PDF loaders: accepts text or PDF
- Simple KG builder → Neo4j database: builds graph
- Simple KG builder → LLM adapters: uses model
- Simple KG builder → Embedding adapters: uses embedder
- Text and PDF loaders → Text splitters: splits text
- Text splitters → Entity extraction: provides chunks
- Entity extraction → Entity resolution: extracts entities
- Entity resolution → Graph writer: resolves entities
- Graph writer → Neo4j database: writes graph
- Questioner → GraphRAG search: asks question
- GraphRAG search → Neo4j retrievers: retrieves context
- Neo4j retrievers → Neo4j database: queries graph
- GraphRAG search → LLM adapters: generates answer
- LLM adapters → LLM provider: calls model
- Embedding adapters → Embedding provider: requests vectors
- Vector index API → Neo4j database: creates index
- Application developer → External vector retrievers: configures retrieval
- External vector retrievers → External vector store: searches vectors
- Application developer → Tools retriever: configures tools
- Tools retriever → LLM adapters: selects tools
- Tools retriever → Neo4j database: runs selected tools