graphrag
Hybrid search engine: vector embeddings + knowledge graph over Markdown notes.
A single Rust binary β no Python, no npm, no servers. 100% local and private.
π§ GraphRAG for absolute beginners
(If you already know what RAG, vectors, and knowledge graphs are, skip ahead to What is Graph RAG?)
The problem: hundreds of notes, can't find anything
Imagine you've been taking notes about Linux for years. You have a ~/linux-notes/
folder with 500 Markdown files on topics like:
linux-notes/
βββ apt-comandos-basicos.md
βββ systemd-crear-servicio.md
βββ docker-compose-nginx.md
βββ particionar-disco-gpt.md
βββ script-bash-backup.md
βββ firewall-ufw-reglas.md
βββ kernel-compilar-modulo.md
βββ ssh-tunel-inverso.md
βββ lvm-redimensionar.md
βββ nginx-proxy-inverso.md
βββ rsync-incremental-backup.md
βββ ... (500 files)
When you need to find something, you do the usual:
And it works... until it doesn't. Because:
- You search "partitions" but the note is titled "resizing LVM" and never uses that word
- You search "network monitoring" but your note talks about "ntopng" and "iftop" without saying "monitoring"
- You search "high availability" and get one note, but you miss the "keepalived" and "nginx load balancing" notes that are closely related
Your knowledge is there. The problem is you don't know it's there.
The solution: a search engine that understands relationships, not just words
GraphRAG scans your 500 Linux notes, automatically extracts key concepts (apt, systemd, LVM, Nginx, Docker, firewalld...) and builds a knowledge map that knows how they relate to each other.
Now, when you search:
GraphRAG doesn't just find the note mentioning "partitions". It also shows you:
- The note about LVM (because LVM and partitions are neighboring concepts in the graph)
- The note about GPT vs MBR (connected through
partitioning) - The note about mounting filesystems (connected by
diskβstorage)
This is Graph RAG: a search engine that uncovers connections you didn't even know existed.
Real-world example: how it works with your Linux notes
1. Build the knowledge map
# One command scans all your notes and builds the graph
Under the hood, GraphRAG:
- Reads each note and splits it into sections
- Sends sections to a local AI (Ollama) that extracts entities like
systemd,docker,nginx,partitioning,firewall - Detects which entities appear together in the same notes (co-occurrence)
- Builds a graph where each entity is a node and each co-occurrence is a connection
- Computes embeddings (vectors) for each note and entity
The result is a SQLite database that knows:
[Docker] ββco-occursββ [Nginx] ββco-occursββ [reverse-proxy]
ββco-occursββ [certbot-ssl]
ββco-occursββ [load-balancing]
2. Search for something specific
Results:
1. Nginx as reverse proxy Score: 0.92
Connections: nginx, reverse-proxy, http
2. Certbot: SSL certificates with Let's Encrypt Score: 0.67
Connections: ssl, certbot, nginx
β Appears because it shares "nginx" with the previous note
3. Fail2ban: protecting SSH and services Score: 0.45
Connections: fail2ban, firewall, security
β Appears because "security" is connected to "nginx" in the graph
Note 3 never mentions "secure web server" β but GraphRAG knows that fail2ban is used to protect web servers, because both notes share entities in the graph. grep would never have shown you that note.
3. Explore connections
# What does Docker have to do with systemd?
# β Docker β containers β systemd β services
# What entities surround "firewall"?
# Neighbors: ufw, iptables, nftables, fail2ban, security, ports
# General statistics
# β 500 notes, 1200 entities, 3400 connections
And all this without internet?
Yes. GraphRAG is a single Rust binary that:
- Doesn't need Python, Node.js, or Docker
- Runs entirely on your machine, 100% local
- Never sends your data to any server
- If you don't have Ollama, uses synthetic embeddings (no external AI needed)
- The SQLite database is smaller than an MP3 and fully portable
In summary: If you have hundreds of Markdown notes and you're tired of searching with grep or missing notes you know exist but can't find, GraphRAG is the search engine that turns your file chaos into an explorable knowledge map.
π What is Graph RAG?
Graph RAG (Retrieval-Augmented Generation with Graphs) is a retrieval technique that improves on plain vector search by incorporating graph structure into relevance ranking.
Instead of just finding notes that mention your query, it discovers notes connected through shared concepts and entities β even if those notes never use the same words.
Why it matters
| Search method | What it finds | What it misses |
|---|---|---|
| FTS (full-text) | Exact keyword matches | Synonyms, typos, related concepts |
| Vector search | Semantically similar content | Indirect relationships |
| Graph RAG | Semantic matches + graph-connected content | Nothing β it's strictly better |
Concrete example: You have notes about "Docker Compose", "PostgreSQL", and "Patroni HA clusters". Vector search for "PostgreSQL replication" finds the PostgreSQL note. Graph RAG also surfaces the Patroni note β not because it mentions PostgreSQL, but because both connect through the entity high-availability in the knowledge graph.
The three-phase pipeline
Query "Python databases"
β
βΌ
ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β PHASE 1 β Vector Search β
β Cosine similarity: query vs every note/entity embedding β
β β Top-K candidates ranked by semantic proximity β
ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ€
β PHASE 2 β Reranking β
β Boost: title match (+0.1) β’ note type (+0.2) β
β Combine vector score + graph score via Ξ± (default 0.7) β
ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ€
β PHASE 3 β Graph Expansion β
β From top candidates, traverse the knowledge graph β
β via recursive CTE (SQLite). Neighbors get decaying score β
β β Discovers notes connected through shared entities β
ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ€
β Results: hybrid score β’ note content β’ neighbors β
ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
TL;DR: Vector search tells you what's similar. Graph expansion tells you what's connected. Together they find what you didn't know to look for.
When to use it
- π§ Personal knowledge bases β connect ideas across hundreds of notes
- π Technical documentation β find related tools, libraries, and concepts
- π¬ Research workflows β discover papers and notes linked by shared entities
- π± Zettelkasten / digital gardens β surface implicit links between atomic notes
- π₯ Team wikis β find documents connected through shared terminology
β¨ Features
| Feature | Why it matters | |
|---|---|---|
| π | Hybrid search (vectors + graph) | Finds relevant notes and connected content you didn't explicitly search for |
| π§© | Entity extraction via Ollama LLM | Automatically builds the knowledge graph from your notes β no manual tagging |
| ποΈ | Community detection (Leiden algorithm) | Groups related entities into clusters for higher-level understanding |
| π | Narrative answers (--answer) |
Get LLM-generated summaries grounded in community context, not just result lists |
| π | FTS5 full-text search | Classic keyword search when you know exactly what you're looking for |
| π | Path finding | Shortest path between any two nodes β discover surprising connections |
| π | Graph statistics | Understand your knowledge base structure at a glance |
| π₯οΈ | Concept map TUI (map) |
Interactive terminal UI to visually explore the knowledge graph β navigate nodes, inspect details, filter by type |
| β‘ | Incremental builds | Only processes new/modified files (SHA256). Second build is instant |
| π | Parallel NER | N worker threads for entity extraction, 1 serial writer β no SQLite lock contention |
| π€ | MCP server | Claude Desktop, Cline, and other AI assistants can query your graph in real-time |
| π | Neovim plugin | Search and insert related notes without leaving your editor |
| π« | Zero external deps | SQLite compiled statically. No Python, Node, Docker, or servers needed |
| π | 100% local & private | Everything runs on your machine. No data ever leaves your computer |
π Quick start (under 2 minutes)
# 1. Install
# 2. Populate demo data (44 nodes, ~113 edges)
# 3. Search β finds notes semantically related to "Python"
# 4. Path β discovers how two technologies connect
# β Docker β virtualization β embedded-database β SQLite
# 5. Graph β see what's connected to a concept
# 6. Stats β understand your graph
Sample output
$ graphrag search "Python" demo.db -k 3
Results for "Python" (Ξ±=0.70, depth=2):
ββββββββββββββββββββββββββββββββββββββββββββ
1. Python: A versatile language
Score: 0.982 | Type: note
Python is widely used in data science, web development, and automation.
Neighbors: pandas, flask, machine-learning, data-science
2. pandas: Data analysis library
Score: 0.623 | Type: note
pandas provides high-performance, easy-to-use data structures.
Neighbors: Python, numpy, data-science, jupyter
3. Data Science overview
Score: 0.412 | Type: note
An introduction to data science concepts and tooling.
Neighbors: Python, R, machine-learning, statistics
Full demo walkthrough
# Create a database with demo data
# Hybrid search with graph expansion (depth 2)
# Search with narrative answer (requires community detect + summarize)
# Exact text search
# Explore the graph
# Interactive concept map
# Clean up when done
π¦ Installation
From crates.io (recommended)
From source
# Binary at:
# target/release/graphrag (~6.5 MB)
Requirements: Rust β₯ 1.75 only. SQLite is compiled statically via rusqlite bundled feature β no system libraries needed.
Optional: Ollama setup
GraphRAG works without Ollama using synthetic (deterministic hash-based) embeddings. For better results, install Ollama and pull the models you need:
# Minimal setup (fast, works on any hardware)
# Recommended setup (best quality)
βοΈ Configuration
GraphRAG auto-creates a config file at ~/.config/graphrag/config.toml on first run.
All fields are optional β CLI flags always override config values.
# =============================================
# GraphRAG configuration
# =============================================
# --- Database ---
= "graph.db" # Default DB path
# --- Ollama connection ---
= "http://localhost:11434"
= "bge-m3:latest" # Embedding model
= "gemma4:e2b" # Entity extraction model
# --- Search defaults ---
= 5 # Results count
= 2 # Graph expansion hops
= 0.7 # Vector weight (0=graph only, 1=vector only)
# --- Notes directory ---
= "~/notes" # Used by `graphrag build` when no dir is given
# --- Build ---
= 4 # Parallel NER workers
Practical config examples
= "search.db"
= "~/notes"
= 10
= 2
# No Ollama fields β uses deterministic synthetic embeddings automatically
= "~/kb/search.db"
= "~/kb/notes"
= "gemma4:e2b"
= "bge-m3:latest"
= 10
= 2
= 0.7
= 6
π οΈ CLI commands
graphrag <COMMAND> [ARGS] [OPTIONS]
Core commands
| Command | Description |
|---|---|
build |
π₯ Scan .md files β extract entities β build knowledge graph |
search |
π Hybrid vector + graph search |
ask |
π‘ RAG: answer questions with sources (retrieval + LLM) |
fts |
π Exact full-text search (FTS5) |
graph |
πΈοΈ Show neighbors of a node |
map |
π₯οΈ Interactive concept map TUI |
path |
π Shortest path between two nodes |
seed |
π± Populate demo data |
stats |
π Graph statistics |
reset |
ποΈ Delete DB and recreate empty |
Advanced commands
| Command | Description |
|---|---|
community detect |
ποΈ Leiden community detection |
community summarize |
π LLM summaries per community |
mcp |
π€ MCP server for AI assistants |
init db |
π Create empty database |
init neovim |
π Generate Neovim plugin config |
completions |
β¨οΈ Shell completions (bash/zsh/fish) |
graphrag init db [DB]
Create an empty SQLite database with the GraphRAG schema.
graphrag init neovim [--output <path>]
Generate Neovim plugin Lua config ready for lazy.nvim.
# Print to stdout
# Save directly
graphrag community detect [DB]
Run Leiden community detection on the entity graph β groups related entities into clusters.
# Coarser communities (lower resolution = fewer, larger groups)
# Finer communities (higher resolution = more, smaller groups)
| Flag | Default | Description |
|---|---|---|
--resolution |
1.0 | CPM quality function resolution parameter |
graphrag community summarize [DB]
Generate LLM summaries for all detected communities. Requires community detect first.
| Flag | Default | Description |
|---|---|---|
--ollama-url |
http://localhost:11434 |
Ollama server URL |
--summary-model |
llama3.2:3b |
LLM for generating summaries |
--embed-model |
nomic-embed-text |
Embedding model |
After summarizing, use graphrag search --answer to get narrative answers grounded in community context.
graphrag completions <bash|zsh|fish>
Generate shell completion scripts.
graphrag seed [DB]
Populate a database with demo data (44 nodes: notes, entities, tags; ~113 edges).
| Flag | Default | Description |
|---|---|---|
--ollama-url |
http://localhost:11434 |
Ollama server URL |
--embed-model |
nomic-embed-text |
Embedding model |
graphrag build [REPO] [DB]
The heart of GraphRAG β scan .md files, extract entities via Ollama, and build the graph.
Optimized for large repos:
| Optimization | How it works |
|---|---|
| β‘ Incremental | Skips unchanged files via SHA256 hash. Second builds are near-instant |
| π§΅ Parallel NER | N worker threads extract entities in parallel |
| βοΈ Serial writer | Single thread writes to SQLite β no lock contention |
| π¦ Batch NER | All chunks of a file sent in one Ollama call |
| π Retry with backoff | 3 attempts (2s, 4s, 8s) on connection errors |
| π§Ή Auto-cleanup | Deleted notes and orphaned entities pruned automatically |
# Build from configured notes directory
# Build from a specific directory
# Build with specific model
| Flag | Default | Description |
|---|---|---|
--embed-model |
nomic-embed-text |
Embedding model |
--ner-model |
llama3.2:3b |
Entity extraction model |
--ollama-url |
http://localhost:11434 |
Ollama server URL |
graphrag reset [DB]
Delete the database and recreate it empty (equivalent to rm + init).
graphrag search <QUERY> [DB]
Hybrid search β semantic vectors + graph expansion. This is what makes GraphRAG special.
| Flag | Default | Description |
|---|---|---|
-k |
5 | Number of results |
-d |
2 | Graph expansion depth (hops from initial results) |
-a |
0.7 | Vector weight (0.0 = pure graph, 1.0 = pure vector) |
--ollama-url |
http://localhost:11434 |
Ollama server URL |
--embed-model |
nomic-embed-text |
Embedding model |
--notes-only |
β | Show only notes (hide entities and tags) |
--min-weight |
β | Minimum edge weight for graph expansion |
--filter |
β | Filter by metadata (repeatable). Format: 'field op value' e.g. --filter 'date >= 2023' |
--answer |
β | Narrative answer using community context (requires community detect + summarize) |
--format |
table |
Output format: table, list, or json |
graphrag ask <QUERY> [DB]
RAG in one command: hybrid retrieval + community summaries + chunk evidence β a grounded natural-language answer generated with Ollama, with cited sources.
| Flag | Description |
|---|---|
-k, --k |
Retrieval results used as evidence (default 5) |
-d, --depth |
Graph expansion depth (default 2; 0 = vector-only) |
-a, --alpha |
Vector weight, 0.0β1.0 (default 0.7) |
--min-weight |
Minimum edge weight for expansion |
--notes-only |
Only notes (hide entities and tags) |
--filter |
Metadata filter (repeatable), e.g. 'date >= 2023' |
--communities |
Max community summaries in the context (default 3) |
--model |
Ollama model for generation (default: summary_model from config) |
--format |
Output format: table | list | json |
If Ollama is unreachable, ask degrades to plain retrieval and exits 0. Community context requires graphrag community detect followed by graphrag community summarize. With --format json the output is { "answer", "sources", "results" }.
graphrag similar --label <LABEL> --file <PATH> [DB]
Find semantically similar notes. Two modes:
--label: find notes similar to an existing indexed note (no Ollama needed β uses stored embeddings)--file: find notes similar to an external.mdfile (chunks and embeds via Ollama)
Both modes use match individual: each chunk of the source is compared independently, and each target note is scored by its best-matching chunk pair.
# Find notes similar to an existing note
# Find notes similar to an external file
| Flag | Default | Description |
|---|---|---|
--label |
β | Label of an existing note in the database |
--file |
β | Path to an external .md file |
-k |
5 | Number of results |
-d |
2 | Graph expansion depth |
--notes-only |
β | Show only notes (no entities/tags) |
--min-weight |
β | Minimum edge weight for expansion |
--filter |
β | Filter by metadata field (--filter "category = tutorial") |
--format |
table |
Output format: table, list, or json |
Note: --label and --file are mutually exclusive. Use exactly one.
graphrag fts <QUERY> [DB]
Exact full-text search via SQLite FTS5 β classic keyword search.
| Flag | Default | Description |
|---|---|---|
-l |
10 | Number of results |
--notes-only |
β | Show only notes (no entities/tags) |
--format |
table |
Output format: table, list, or json |
graphrag graph <LABEL> [DB]
Show neighbors of a node in the knowledge graph. Great for exploring.
graphrag map [DB]
Interactive concept map TUI β visually explore the knowledge graph in the terminal.
# Full graph
# Subgraph centered on a node
| Flag | Default | Description |
|---|---|---|
--from |
β | Starting node label (omit for full graph) |
-d |
2 | Graph expansion depth from starting node |
Controls:
| Key | Action |
|---|---|
ββββ / hjkl |
Navigate between nodes |
Enter |
Select node (details in right panel) |
t |
Cycle filter: all β notes β entities β tags |
/ |
Search nodes by name |
q / Esc |
Quit |
| Mouse click | Select node |
graphrag path <FROM> <TO> [DB]
Shortest path between two nodes β discovers how concepts connect.
# β Python β web-development β containerization β Docker
| Flag | Default | Description |
|---|---|---|
-d |
10 | Maximum traversal depth |
graphrag stats [DB]
Graph statistics. Omits the DB path to use the configured default.
Output example:
Graph Statistics
βββββββββββββββββββββββββββββββββββββββ
Nodes: 156
β’ notes: 89
β’ entities: 52
β’ tags: 15
Edges: 342
Density: 0.028
Communities: 12
graphrag mcp
Start an MCP server over stdio for AI assistant integration (see MCP section).
| Flag | Default | Description |
|---|---|---|
--db |
graphrag.db |
Path to SQLite database |
--ollama-url |
http://localhost:11434 |
Ollama server URL |
--embed-model |
nomic-embed-text |
Embedding model |
π― Use cases & examples
π Personal knowledge base
You have 300 notes about programming, DevOps, and system design. You search for "async Rust" and get back notes about tokio and async/await β plus a note about the "actor model" that never mentions those words.
# Build the graph
# Hybrid search β finds connected content you didn't explicitly search for
# Example result you wouldn't get with vector-only search:
# "Actor Model in Distributed Systems" β Score: 0.34 (from graph expansion)
# Connected via: concurrency (shared entity with async Rust notes)
π Technical documentation
Search across multiple project docs and discover cross-project connections.
# β Kubernetes β container-orchestration β Docker β embedded-database β SQLite
π§ͺ Research paper collection
200 ML paper summaries. Find cross-disciplinary connections.
# Searching for "transformer attention" also surfaces a paper about
# "sparse mixture of experts" β both connect through "self-attention"
# Explore concepts
π Hidden connections
Discover how seemingly unrelated topics connect through your graph.
# CSS to PostgreSQL? There's a path through web development
# β CSS β frontend β web-development β backend β PostgreSQL
# Explore an entity's neighborhood
# Get a narrative answer about a topic
π€ AI assistant integration (MCP)
Let Claude, Cline, or any MCP-compatible AI assistant query your knowledge base in real-time during conversations.
Claude can now use tools to explore your knowledge graph:
searchβ hybrid semantic + graph search πgraphβ explore neighbors of a node πΈοΈpathβ find connections between concepts πstatsβ understand graph structure π
π Neovim plugin
Search and insert related notes without leaving your editor.
Installation
lazy.nvim loads it automatically from lua/plugins/.
Commands & keymaps
| Command | Keymap | Description |
|---|---|---|
:GraphRAG related |
,gr |
Find notes related to current buffer (floating window) |
:GraphRAG insert |
,gi |
Find related and insert ## Related links at end of file |
:GraphRAG search <q> |
β | Hybrid search from command line |
:GraphRAG fts <q> |
β | Full-text search |
:GraphRAG path <A> <B> |
β | Shortest path |
:GraphRAG stats |
β | Graph statistics |
π€ MCP server
Expose your knowledge graph to any MCP-compatible AI assistant (Claude Desktop, Cline, etc.).
Claude Desktop configuration
Tools exposed
| Tool | Description |
|---|---|
build |
Build or update the graph from your notes directory |
search |
Hybrid search (vectors + graph) |
fts |
Full-text search |
graph |
Show neighbors of a node |
path |
Shortest path between two nodes |
stats |
Graph statistics |
seed |
Populate demo data |
Resources exposed
| URI | Content |
|---|---|
graphrag://stats |
Graph statistics |
graphrag://nodes |
All nodes |
graphrag://notes |
Notes only |
graphrag://entities |
Entities only |
graphrag://edges |
All edges |
graphrag://nodes/<label> |
Single node details |
ποΈ Architecture
Module map
π¦ graphrag (single ~6.5 MB binary)
βββ src/
β βββ main.rs β CLI entrypoint (clap, 12 subcommands)
β βββ config.rs β TOML config (auto-created, all fields optional)
β βββ mcp/mod.rs β MCP server (stdio, JSON-RPC 2.0)
β βββ db/
β β βββ schema.rs β SQLite schema + FTS5 virtual table
β βββ graph/
β β βββ build.rs β Incremental build (parallel NER, serial writer)
β β βββ expand.rs β Recursive CTE expansion + shortest path
β βββ search/
β β βββ hybrid.rs β 3-phase hybrid search engine
β βββ embed/
β β βββ ollama.rs β Ollama HTTP client (blocking reqwest)
β βββ vector/
β β βββ mod.rs β f32 β BLOB, cosine similarity
β β βββ synthetic.rs β Deterministic hash-based embeddings
β βββ chunking/
β β βββ markdown.rs β Frontmatter parsing + section chunking
β βββ ner/
β β βββ ollama_ner.rs β LLM entity extraction (batch mode)
β βββ map/
β β βββ mod.rs β Data loading (load_graph, cmd_map)
β β βββ layout.rs β Force-directed layout algorithm
β β βββ tui.rs β Interactive TUI (ratatui)
β βββ seed/
β βββ demo_data.rs β Demo data generator (44 nodes, 113 edges)
How data flows
BUILD PIPELINE:
ββββββββββββ ββββββββββββ ββββββββββββββββββββββββ ββββββββββββ
β .md filesβ β β SHA256 β β β N worker threads: β β β 1 writer β
β β β pre-scan β β frontmatter β chunk β β thread β
β β β β β β NER batch (Ollama) β β β SQLite β
ββββββββββββ ββββββββββββ ββββββββββββββββββββββββ ββββββββββββ
β β
Entities + co-occurrence Nodes + Edges
β
βββββββββββββββββββββββββββββββββββ
β
ββββββββββββ
β Prune β β Repopulate FTS5
β deleted β
ββββββββββββ
SEARCH PIPELINE:
Query β Embed β Cosine similarity β Rerank β Graph expansion β Results
β β β β β β
β Ollama or Top-K scores +title Recursive Hybrid score
β synthetic by semantic +type CTE from + content
β similarity +alpha candidates + neighbors
Database schema
ββββββββββββββββββββ βββββββββββββββββββββββββ
β nodes β β edges β
ββββββββββββββββββββ€ βββββββββββββββββββββββββ€
β id INT PK ββββ β source_id INT FK β
β key TEXT UQβ ββββββ€ target_id INT FK β
β label TEXT β ββββββ€ type TEXT β
β type TEXT β ββββββ€ type TEXT β
β embedding BLOB β β β weight REAL β
β metadata JSON β β β context TEXT β
β created_at INT β β βββββββββββββββββββββββββ
ββββββββββββββββββββ β
β βββββββββββββββββββββββββ
notes_fts β β node_types β
(FTS5 virtual) β βββββββββββββββββββββββββ€
β β note β
β β entity β
β β tag β
ββββββ€ β
βββββββββββββββββββββββββ
Node identity: every node has a unique key. Notes use key = "note:" + <relative path>; entities, tags and directories use key = "node:" + <label>. This means two notes with the same title β and even a note whose title matches an entity β are stored as separate nodes instead of overwriting each other, so incremental builds converge.
β‘ Performance
Recommended Ollama models
| Purpose | Model | Params | VRAM | Quality |
|---|---|---|---|---|
| NER | gemma4:e2b |
5.1B | ~5GB | βββ Very good |
| NER | gemma4:12b |
11.9B | ~7GB | βββ Excellent |
| NER | llama3.2:3b |
3.2B | ~2GB | ββ Good (fast) |
| Embeddings | bge-m3 |
566M | ~1GB | βββ Excellent |
| Embeddings | nomic-embed-text |
137M | ~0.5GB | ββ Good |
Build throughput
| Scenario | Files | Time | Notes |
|---|---|---|---|
| First build | 100 | ~20 min | With gemma4:e2b, 4 threads |
| First build | 6254 | ~22 h | Large docs repo |
| Incremental | 1 changed | ~2 s | Only re-processes modified files |
| No Ollama | any | ~5 s | Synthetic embeddings, no NER |
Tip: The first build is the slowest (NER is LLM-bound). Subsequent builds are near-instant because only new/modified files are processed.
Memory
| Setup | RAM | Notes |
|---|---|---|
| No Ollama (synthetic) | ~15 MB | Minimal |
With nomic-embed-text |
~500 MB | + Ollama process |
With bge-m3 |
~1.5 GB | + Ollama process |
With gemma4:e2b (NER) |
~5 GB | + Ollama process |
π§ͺ Tests
# All tests (123 tests, no external services needed)
# Ollama-dependent tests (2 tests, requires Ollama running)
# Lint
# Format check
Tests use tempfile for temporary databases β no cleanup needed.
π§ Troubleshooting
"Ollama is not running"
Error: connection refused
GraphRAG works without Ollama using synthetic embeddings. If you want Ollama for better results:
# Start Ollama
# Verify it's running
"Model not found"
WARN: model "gemma4:e2b" not found, skipping...
Pull the model:
Build is slow
The first build runs NER (entity extraction) via LLM on every file. This is expected β LLMs are slow. After the first build, only changed files are processed.
Tips:
- Increase
num_threadsin config (watch your VRAM) - Use a smaller NER model:
llama3.2:3bis 2Γ faster thangemma4:e2b - Use
--ollama-urlto point to a remote Ollama server on a GPU machine
"No entities found for any chunks"
Some models don't support Ollama's format: json mode. Try:
# Switch to a model that handles JSON output well
# Or use gemma4 which has excellent JSON support
"graphrag.db" uses config but I wanted a literal file
If you pass graphrag.db (the default), GraphRAG substitutes the path from
your config file. To force a literal graphrag.db file, use the config path:
# In config.toml
= "graphrag.db"
β FAQ
π€ Contributing
Contributions are welcome! Here's how to get started:
# Clone and build
# Run tests
# Check lint
# Format
Development tips
- Use
RUST_LOG=debug graphrag buildto see detailed build logs - The demo data seed is at
src/seed/demo_data.rsβ great starting point - All CLI commands are in
src/main.rsβ easy to add new ones - SQLite schema is in
src/db/schema.rs
π Further reading
- Microsoft GraphRAG paper β the original research
- SQLite FTS5 documentation β full-text search engine
- Leiden algorithm β community detection used by GraphRAG
- Ollama β local LLM server
π License
MIT β see LICENSE.