Local graphrag pipeline using Ollama and polars
0
stars
54
commits
Python
primary language
Aug 28, 2026
updated
An end-to-end GraphRAG pipeline built from scratch: extract entities and relations from a text corpus, cluster them into a knowledge graph, generate descriptions, embed everything, and answer questions via local search over the graph.
Runs on an NVIDIA A40 with 16GB of system ram.
Targets a slice of the wiki_dpr corpus (~21M passages) (for now) and runs entirely on local infrastructure — no external LLM API calls.
EntityRelationExtractor.py) — chunks the corpus, runs GLiNER-Relex for joint NER/RE, deduplicates entities by embedding similarity, and writes entities/relations to Parquet.DescriptionGenerator.py) — async LLM-based summarization for both entities and detected communities, with TF-IDF clustering to downsample excerpts for entities that appear too often.GraphGenerator.py) — builds the graph in igraph, runs Leiden community detection, and embeds entities and communities into ChromaDB.GraphRAG.py) — GraphRagQueryEngine performs local search: retrieves relevant entities/communities, expands via graph hops, and asks the LLM to answer using only the retrieved context (with citations).conda env create -f environment.yml
conda activate graphrag
./start_ollama.sh # starts Ollama and creates the forced-gpu-model from ./modelfile
Tested on an A40 GPU (48GB VRAM). start_ollama.sh disables llama.cpp's RAM cache and caps parallelism to avoid the OOM issues that come with default settings.
cd graphrag_src
python main.py
This builds the graph from wiki_dpr end-to-end, then runs a sample local-search query. Intermediate artifacts (chunks, entities, relations, communities, ChromaDB collections) are cached under ./data.
For a quick sanity check after building the graph, run sample_generated_data.py to print random entity/relation/community samples.
pytest tests/
Covers EntityRelationExtractor and GraphGenerator.
Will eventually integrate BenchmarkQED AutoQ/AutoE for automated question generation and answer evaluation.
54 commits
Python
99.6%
Local graphrag pipeline using Ollama and polars
0
stars
54
commits
Python
primary language
Aug 28, 2026
updated
An end-to-end GraphRAG pipeline built from scratch: extract entities and relations from a text corpus, cluster them into a knowledge graph, generate descriptions, embed everything, and answer questions via local search over the graph.
Runs on an NVIDIA A40 with 16GB of system ram.
Targets a slice of the wiki_dpr corpus (~21M passages) (for now) and runs entirely on local infrastructure — no external LLM API calls.
EntityRelationExtractor.py) — chunks the corpus, runs GLiNER-Relex for joint NER/RE, deduplicates entities by embedding similarity, and writes entities/relations to Parquet.DescriptionGenerator.py) — async LLM-based summarization for both entities and detected communities, with TF-IDF clustering to downsample excerpts for entities that appear too often.GraphGenerator.py) — builds the graph in igraph, runs Leiden community detection, and embeds entities and communities into ChromaDB.GraphRAG.py) — GraphRagQueryEngine performs local search: retrieves relevant entities/communities, expands via graph hops, and asks the LLM to answer using only the retrieved context (with citations).conda env create -f environment.yml
conda activate graphrag
./start_ollama.sh # starts Ollama and creates the forced-gpu-model from ./modelfile
Tested on an A40 GPU (48GB VRAM). start_ollama.sh disables llama.cpp's RAM cache and caps parallelism to avoid the OOM issues that come with default settings.
cd graphrag_src
python main.py
This builds the graph from wiki_dpr end-to-end, then runs a sample local-search query. Intermediate artifacts (chunks, entities, relations, communities, ChromaDB collections) are cached under ./data.
For a quick sanity check after building the graph, run sample_generated_data.py to print random entity/relation/community samples.
pytest tests/
Covers EntityRelationExtractor and GraphGenerator.
Will eventually integrate BenchmarkQED AutoQ/AutoE for automated question generation and answer evaluation.
54 commits
Python
99.6%