A hands-on, illustrated guide to Microsoft GraphRAG. No prior graph database knowledge needed.
Click any node to explore, toggle community coloring, and read GraphRAG's auto-generated cluster summaries. No setup required β runs straight in your browser.
- What Problem Does GraphRAG Solve?
- How GraphRAG Works β A Visual Tour
- Setup
- Run Your First Index
- Query the Knowledge Graph
- Visualizing the Graph
- Understanding the Output Files
- Local vs Global Search β When to Use Which
- Configuration Guide
- Add Your Own Documents
- Going to Production
- Resources
Standard RAG (Retrieval-Augmented Generation) works by converting your documents into floating-point vectors and doing a similarity search when you ask a question. Think of it as a very smart Ctrl+F.
YOUR QUESTION
|
v
[Find the 3 chunks most similar to your question]
|
v
[Paste those chunks into the LLM prompt]
|
v
ANSWER (based only on those 3 chunks)
This works great for specific, local questions like:
- "What does the refund policy say?"
- "What is the boiling point of water?"
But it breaks down for questions that require connecting dots across many documents:
Question: "What competitive dynamics shaped the AI document industry?"
Classic RAG finds:
Chunk A (from page 2): "Nova AI was founded in 2018..."
Chunk B (from page 7): "DocuMind raised $40 million..."
Chunk C (from page 15): "The IPO raised $420 million..."
Problem: These chunks are ISOLATED ISLANDS.
The LLM has no idea how Nova AI and DocuMind are related,
who competed with whom, or what events connected them.
GraphRAG reads all your documents and builds a knowledge graph β a web of entities (people, companies, events) connected by relationships.
βββββββββββββββββββββββ
β DOCUMENTS β
ββββββββββββ¬βββββββββββ
β GraphRAG reads
β & understands
βΌ
βββββββββββββββββββββββββββββββββββββββββββββ
β KNOWLEDGE GRAPH β
β β
β [Nova AI]ββFOUNDED_BYββ[Priya Kapoor] β
β β β β
β COMPETED_WITH PITCHED_TO β
β β β β
β [DocuMind] [Horizon Ventures] β
β β β β
β ACQUIREDββ[SearchPro] LED_BYββ[Janet] β
β β
βββββββββββββββββββββββββββββββββββββββββββββ
β
β When you ask a question,
β GraphRAG traverses these
β connections intelligently
βΌ
βββββββββββββββββββββββ
β RICH, CONNECTED β
β ANSWER β
βββββββββββββββββββββββ
The analogy: Classic RAG is like reading random pages from a book. GraphRAG is like having a brilliant research assistant who has read the whole book, built a mind-map of everything, and can explain how all the pieces fit together.
GraphRAG runs a pipeline of steps. Here is what happens under the hood:
ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β THE GRAPHRAG PIPELINE β
β β
β STEP 1: CHUNK β
β βββββββββββββ β
β Big documents β smaller text chunks (300 tokens each, 100 overlap) β
β β
β "Nova AI was founded β "Marcus presented the β "The IPO raised β
β in 2018 by Priya..." β GraphMind paper at..." β $420 million..."β
β β
β β β
β STEP 2: ENTITY EXTRACTION (via LLM) β
β βββββββββββββββββββββββββββββββββ β
β Each chunk β LLM finds entities and relationships β
β β
β Person: Priya Kapoor (CEO of Nova AI) β
β Org: Nova AI (AI startup, founded 2018) β
β Org: Horizon Ventures (venture capital firm) β
β Event: Series A ($12M, 2019) β
β Rel: Priya FOUNDED Nova AI β
β Rel: Horizon Ventures INVESTED_IN Nova AI β
β β
β β β
β STEP 3: BUILD KNOWLEDGE GRAPH β
β ββββββββββββββββββββββββββββ β
β All extracted entities & relationships β one big connected graph β
β Duplicate entities (e.g. "Nova AI" appearing in 20 chunks) β merged β
β β
β β β
β STEP 4: COMMUNITY DETECTION (Leiden algorithm) β
β βββββββββββββββββββββββββββββββββββββββββββββ β
β Nodes that are tightly connected β grouped into "communities" β
β β
β Community A: Nova AI ecosystem β
β (Nova AI, Priya, Marcus, Sofia, Horizon Ventures, DataBridge...) β
β β
β Community B: DocuMind ecosystem β
β (DocuMind, Trevor Blake, SearchPro, Cognify...) β
β β
β Community C: Healthcare AI β
β (Stellar Systems, Leila Nouri, MedReader, HealthTech Partners...) β
β β
β β β
β STEP 5: SUMMARIZE COMMUNITIES (via LLM) β
β βββββββββββββββββββββββββββββββββββββββ β
β Each community β LLM writes a rich summary paragraph β
β These summaries power Global Search queries later β
β β
β β β
β STEP 6: EMBED EVERYTHING β
β ββββββββββββββββββββββββ β
β Entities, relationships, summaries β vector embeddings stored β
β These power Local Search queries later β
β β
ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
This whole process (steps 1β6) is called indexing. You run it once. After that, querying is fast.
- Python 3.10 or 3.11
- An OpenAI API key (get one at platform.openai.com)
- ~$0.50β$2.00 in OpenAI credits for the sample document
Step 1 β Clone / open the repo
cd graph-rag # you're already here
Step 2 β Create a virtual environment
python -m venv .venv # Activate it: source .venv/bin/activate # macOS / Linux .venv\Scripts\activate # Windows PowerShell
You should see (.venv) appear in your terminal prompt.
Step 3 β Install dependencies
pip install -r requirements.txt
This installs graphrag (Microsoft's library) and python-dotenv.
Step 4 β Set your API key
cp .env.example .env
Open .env in any text editor and replace the placeholder:
# Before:
GRAPHRAG_API_KEY=sk-...your-openai-api-key-here...
# After (your real key):
GRAPHRAG_API_KEY=sk-proj-abc123...
Never commit your
.envfile β it's already in.gitignore.
Step 5 β Initialize GraphRAG prompts
python -m graphrag.index --init --root .This creates a prompts/ folder with the default LLM prompts that GraphRAG
uses for entity extraction, community summarization, etc. You can customize
these later, but the defaults work great.
graph-rag/
βββ prompts/ β NEW: created by --init
β βββ entity_extraction.txt
β βββ summarize_descriptions.txt
β βββ community_report.txt
The input/ folder already contains a sample story β Silicon Valley Chronicles,
a fictional narrative about AI startups, founders, investors, and competitive
battles. It's deliberately rich in entities and relationships so you can see
GraphRAG's power clearly.
graph-rag/
βββ input/
βββ silicon_valley_chronicles.txt β 10-chapter story, full of entities
Run the indexing pipeline:
python -m graphrag.index --root .You'll see progress logs like this:
β Ή GraphRAG Indexer
βββ Loading Input (text) β
βββ Chunking β
βββ Extracting Entities β (calls GPT-4o for each chunk)
βββ Summarizing Descriptions β (merges duplicate entities)
βββ Building Knowledge Graph β
βββ Detecting Communities (Leiden) β
βββ Generating Community Reports β (calls GPT-4o per community)
βββ Embedding Everything β
How long does it take? For the sample document: roughly 3β8 minutes. For large corpora (hundreds of documents): can be 30β60 minutes. The cache (in
cache/) means re-runs skip already-processed chunks.
When finished, you'll see an output/ directory appear:
output/
βββ 20240516-143022/ β timestamped run
βββ artifacts/ β parquet files (the actual graph data)
βββ reports/ β indexing run logs
Once indexing finishes, you can ask questions. Use query.py (a simple wrapper)
or the GraphRAG CLI directly.
Querying is not just a database lookup β every question makes two OpenAI API calls, so you need an internet connection and your API key set:
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β YOU: "Who founded Nova AI?" β
β β
β β β
β βΌ β
β ββββββββββββββββββββββββββββ ββββββββββββββββββββββββββββ β
β β 1. Embed the question βββββΆβ OpenAI β π β
β β into a vector β β text-embedding-3-small β β
β ββββββββββββββββββββββββββββ ββββββββββββββββββββββββββββ β
β β β
β βΌ β
β ββββββββββββββββββββββββββββ β
β β 2. Find similar entitiesβ β reads output/*.parquet β
β β + their neighborhood β β reads output/lancedb/ (LOCAL) β
β ββββββββββββββββββββββββββββ β
β β β
β βΌ β
β ββββββββββββββββββββββββββββ ββββββββββββββββββββββββββββ β
β β 3. Send context + Q βββββΆβ OpenAI β π β
β β to LLM for answer β β gpt-4o β β
β ββββββββββββββββββββββββββββ ββββββββββββββββββββββββββββ β
β β β
β βΌ β
β ANSWER (with [Data: Entitiesβ¦] citations) β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
| Step | Where it runs | Internet? |
|---|---|---|
| Embed the question | OpenAI text-embedding-3-small |
β yes |
| Vector + graph search | Your machine (parquet + LanceDB) | β local |
| Generate the answer | OpenAI gpt-4o |
β yes |
Cost per query (rough): about $0.001β$0.01 for local search, $0.05β$0.20 for global search (which fans out across all community reports via map-reduce).
Both
--method localand--method globalneed the LLM. The graph data is yours and lives inoutput/, but turning it into a natural-language answer requires the model. No LLM = no answer.
Fully offline alternative: swap to a local model by editing settings.yml:
point llm.api_base at Ollama (http://localhost:11434/v1) and change model
to llama3.1:8b or similar. Quality drops vs gpt-4o but everything runs on your
machine. The graph stays the same β only the answering model changes.
# Specific question about a person or company (local search): python query.py "Who founded Nova AI and what were their backgrounds?" --method local # Broad thematic question (global search): python query.py "What were the major competitive dynamics in the AI industry?" # More examples: python query.py "What happened during the DocuMind security crisis?" --method local python query.py "How did the COVID pandemic affect the companies?" --method local python query.py "What are the key themes across this story?" --method global
python -m graphrag.query --root . --method local "Tell me about Priya Kapoor" python -m graphrag.query --root . --method global "Summarize the major events"
Question: "How did Nova AI grow from a startup to a public company?"
Method: local
Answer:
Nova AI was founded in 2018 by Priya Kapoor, Marcus Chen, and Sofia Reyes
in a Palo Alto garage. Their initial product, Lumina, secured a $12M Series A
from Horizon Ventures in 2019. A COVID-era pivot led Marcus Chen to design
GraphMind β a knowledge-graph architecture that differentiated them from
competitors. This attracted a $35M Series B from Horizon Ventures, Apex Capital,
and TechGiant Corp. Through strategic acquisitions (DataBridge), partnerships
(CloudBase), and capitalizing on rival DocuMind's 2022 security scandal, Nova AI
grew to 400 employees and $180M ARR before going public on NASDAQ in February
2024, raising $420M at $28/share.
Notice how the answer connects information from across all 10 chapters of the story β something classic RAG would struggle with.
Global search β thematic question across the whole corpus:
Local search β specific question about a named entity:
demo.html is an interactive D3.js visualization of your knowledge graph.
After indexing, generate the data file once, then open the page:
python build_demo.py # reads output/*.parquet β writes demo_data.js open demo.html # macOS (or: start demo.html / xdg-open demo.html)
Re-run build_demo.py any time you re-index to refresh the demo.
What you can do in the demo:
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β LEFT SIDEBAR β
β β’ Toggle color by Community or Entity Type β
β β’ Filter graph to show/hide individual communities β
β β’ Click each Pipeline Step (1β6) for an explainer banner β
β β
β GRAPH (center) β
β β’ Drag nodes to rearrange the layout β
β β’ Scroll to zoom in/out β
β β’ Hover any node β tooltip with description β
β β’ Click a node β highlights its neighbors, fades the rest β
β β
β RIGHT PANEL β
β β’ Shows the selected node's full description and connections β
β β’ Click neighbor chips to jump to connected entities β
β β
β BOTTOM QUERY BAR β
β β’ One button per community β highlights it and shows the REAL β
β community summary GraphRAG generated for your data (Step 5) β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
After indexing, you have three options for seeing the graph visually. They go from "easiest" to "most powerful":
ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β OPTION A β Interactive HTML (easiest, works in any browser) β
β OPTION B β Gephi desktop app (best for large, complex graphs) β
β OPTION C β pandas in Python (no GUI, just data exploration) β
ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
This generates a single graph.html file you open in Chrome/Firefox/Safari.
No extra software needed beyond pip install.
# Install the visualization library (one-time): pip install pyvis # Generate the interactive graph: python visualize.py
Then open graph.html in your browser. You'll see something like this:
ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β graph.html (in your browser) β
β β
β βββββββββββββββββββββββββββββββββββββββββββ β
β Nova AI COMPETED_WITH DocuMind β
β β β² β± β β
β β β² β± β β
β FOUNDED β² β± ACQUIRED β
β β ββββββββββββββββββββββββββββ β β
β Priya Horizon Ventures SearchPro Trevor β
β Kapoor (teal cluster) (grey) Blake β
β β
β [Hover any node β see its description] β
β [Drag β rearrange] [Scroll β zoom] β
ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
Node COLOR = which community it belongs to (related entities cluster together)
Node SIZE = how many connections (bigger = more important hub)
Edge WIDTH = relationship strength (thicker = stronger link)
Useful flags:
# Too many nodes? Keep only the 50 most-connected ones: python visualize.py --max-nodes 50 # Zoom into just one community (use 0, 1, 2, ...): python visualize.py --community 0 # Color by entity type instead of community: python visualize.py --color type # Save to a custom filename: python visualize.py --output nova_ai_graph.html # Open directly (macOS): python visualize.py && open graph.html
What the colors mean with --color type:
ββ Teal (#4ECDC4) = Organization (companies, firms, institutions)
ββ Red (#FF6B6B) = Person (founders, executives, researchers)
ββ Mint (#95E1D3) = Geo (cities, countries, regions)
ββ Yellow (#F7DC6F) = Event (IPOs, acquisitions, conferences)
ββ Purple (#BB8FCE) = Technology (software, models, architectures)
ββ Amber (#F0A500) = Product (commercial products and platforms)
Gephi is free, open-source, and purpose-built for graph exploration. It handles thousands of nodes smoothly and has built-in layout algorithms, community coloring, and filtering tools.
Step 1 β Enable GraphML export (already done in this repo's settings.yml):
snapshots: graphml: true # β this is already set to true
Step 2 β Re-run indexing to generate the .graphml file:
python -m graphrag.index --root . # After it finishes: ls output/*/artifacts/*.graphml
Step 3 β Open in Gephi:
1. Download Gephi from https://gephi.org/users/download/
2. File β Open β select the .graphml file
3. Run a layout:
Layout panel (bottom-left) β choose "ForceAtlas 2" β click Run
Wait 10-20 seconds, then click Stop
4. Color by community:
Appearance panel β Nodes β Color β Partition β community
5. Size by degree:
Appearance panel β Nodes β Size β Ranking β Degree
What Gephi looks like after layout + coloring:
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β β
β βββββ βββ βββββββββ β
β βββββββ βββββββββ βββββββββββ β
β ββββββ ββββββββ ββββββββββ β
β (blue (green (red cluster) β
β cluster: cluster: Healthcare AI) β
β Nova AI) DocuMind) β
β β
β Each cluster = one community detected by GraphRAG β
β Edges between clusters = cross-community connections β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
No GUI needed β just look at the raw data in a Jupyter notebook or script:
import pandas as pd # Find your latest run: import pathlib artifacts = sorted(pathlib.Path("output").iterdir(), reverse=True)[0] / "artifacts" # Load the graph nodes = pd.read_parquet(artifacts / "create_final_nodes.parquet") edges = pd.read_parquet(artifacts / "create_final_relationships.parquet") # Print all entities and their types print(nodes[["title", "type", "description"]].to_string()) # Print all relationships print(edges[["source", "target", "description"]].to_string()) # Show the 10 most-connected entities (the graph "hubs") degree = pd.concat([edges["source"], edges["target"]]).value_counts() print("Top 10 most-connected entities:") print(degree.head(10)) # Show community membership print(nodes.groupby("community")["title"].apply(list))
After indexing, output/<timestamp>/artifacts/ contains several .parquet files.
Here's what each one contains:
artifacts/
β
βββ create_final_nodes.parquet
β What's inside: Every entity in the graph (people, companies, events, places)
β Key columns: id, title, type, description, community
β Example row: id=42, title="Nova AI", type="ORGANIZATION",
β description="AI startup founded in 2018...", community=0
β
βββ create_final_edges.parquet
β What's inside: Every relationship between entities
β Key columns: source, target, description, weight
β Example row: source="Priya Kapoor", target="Nova AI",
β description="Co-founded and serves as CEO"
β
βββ create_final_communities.parquet
β What's inside: The detected communities (clusters of related entities)
β Key columns: id, title, level
β Example row: id=0, title="Nova AI Ecosystem", level=2
β
βββ create_final_community_reports.parquet
β What's inside: LLM-generated summaries of each community
β Key columns: id, title, summary, findings
β Note: These summaries are used by Global Search
β
βββ create_final_entities.parquet
β What's inside: Entities with their vector embeddings
β Note: Used for semantic similarity search in Local Search
β
βββ create_final_relationships.parquet
β What's inside: All entity relationships (similar to edges but with more metadata)
β
βββ create_final_text_units.parquet
What's inside: The original text chunks (after chunking step)
Note: Used to provide source citations in answers
import pandas as pd # Load and inspect the entities entities = pd.read_parquet("output/<your-timestamp>/artifacts/create_final_nodes.parquet") print(entities[["title", "type", "description"]].head(20)) # Load and inspect the relationships edges = pd.read_parquet("output/<your-timestamp>/artifacts/create_final_edges.parquet") print(edges[["source", "target", "description"]].head(20)) # Load and inspect community summaries reports = pd.read_parquet("output/<your-timestamp>/artifacts/create_final_community_reports.parquet") print(reports[["title", "summary"]].head(5))
This is the most important concept for getting good answers from GraphRAG.
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β LOCAL SEARCH β
β β
β How it works: β
β 1. Embed your question into a vector β
β 2. Find entities whose descriptions are most similar β
β 3. Walk the graph: pull in their neighbors, relationships, β
β community summaries, and source text chunks β
β 4. Feed all of this as context to the LLM β
β β
β Best for: β
β β "Who is [person]?" β
β β "What did [company] do in [year]?" β
β β "Tell me about the [event]" β
β β "What is the relationship between [A] and [B]?" β
β β
β Example: β
β Q: "What was Marcus Chen's contribution to GraphMind?" β
β β Finds Marcus Chen node β walks to Nova AI, GraphMind, β
β NeurIPS, patents β rich specific answer β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β GLOBAL SEARCH β
β β
β How it works: β
β 1. Gather ALL community summaries (the LLM-written paragraphs) β
β 2. Send batches to the LLM: "does this community help answer X?" β
β (called the MAP step) β
β 3. Collect the partial answers and synthesize one final answer β
β (called the REDUCE step) β
β β
β Best for: β
β β "What are the major themes?" β
β β "Give me an overview of the competitive landscape" β
β β "What patterns emerge across the whole story?" β
β β "Compare the different companies' strategies" β
β β
β Example: β
β Q: "What competitive strategies defined the AI document industry?" β
β β Reads Nova AI community + DocuMind community + Stellar β
β community summaries β synthesizes a thematic comparison β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
Quick decision guide:
Named entity in your question? β --method local
Broad / thematic question? β --method global (default)
Not sure? β try both and compare
settings.yml controls the entire pipeline. Here are the most useful knobs:
llm: model: gpt-4o # Change to gpt-4o-mini to cut costs by ~10x # (slightly lower quality entity extraction) max_tokens: 4000 # Max tokens per LLM call concurrent_requests: 25 # Parallel API calls (lower if hitting rate limits) chunks: size: 300 # Tokens per chunk. Smaller = more granular extraction. overlap: 100 # Overlap between chunks. Prevents entities being split. entity_extraction: entity_types: # What kinds of entities to look for. - organization # Add or remove types to match your domain. - person - geo - event - technology - product # Healthcare example: add "disease", "drug", "symptom" # Legal example: add "case", "statute", "court" cluster_graph: max_cluster_size: 10 # Max nodes per community. Larger = broader communities.
# In settings.yml, swap to the cheaper model while testing: llm: model: gpt-4o-mini # ~$0.05 per indexing run vs ~$0.50 for gpt-4o # Also reduce concurrent requests to stay within free-tier rate limits: concurrent_requests: 5
Drop any .txt files into input/ and re-run the indexer.
# Add your files: cp my_document.txt input/ cp another_file.txt input/ # Re-index (the cache skips already-processed chunks): python -m graphrag.index --root .
Good input documents: Poor input documents:
βββββββββββββββββββββ ββββββββββββββββββββ
β Rich in named entities β Pure numerical data (spreadsheets)
β Lots of relationships β Very short snippets < 200 words
β Narrative or prose style β Highly technical jargon with no context
β Multiple interconnected topics β A single narrow topic
β 1,000 β 100,000 words total β Under 500 words (not enough to graph)
# PDF β text (requires pdfminer.six): pip install pdfminer.six python -m pdfminer.high_level -o input/my_doc.txt my_doc.pdf # Word .docx β text (requires python-docx): pip install python-docx python -c " import docx, pathlib doc = docx.Document('my_doc.docx') pathlib.Path('input/my_doc.txt').write_text('\n'.join(p.text for p in doc.paragraphs)) " # Web page β text (requires trafilatura): pip install trafilatura trafilatura --url "https://example.com/article" > input/article.txt
A laptop running python query.py is great for learning. Once real users start
asking questions you'll hit four bottlenecks: cold start, vector latency,
LLM throughput, and storage durability. This section explains why GraphRAG
splits storage into separate layers and what to put in each layer on AWS,
Azure, GCP, or a self-hosted setup.
When indexing finishes, GraphRAG writes four very different kinds of data:
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β output/ β
β βββ entities.parquet β columnar tables (millions of rows) β
β βββ relationships.parquet β
β βββ communities.parquet β
β βββ community_reports.parquet β long-form text blobs (paragraphs) β
β βββ text_units.parquet β raw chunks (rarely read after index) β
β βββ lancedb/ β vector embeddings (similarity search)β
β cache/ β LLM response cache (deduplicates) β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
Each one has a completely different access pattern β that's why production systems don't stuff them into one database:
| Data | Access pattern | What it needs |
|---|---|---|
| Vector embeddings | Approximate nearest-neighbor search at query time | Specialized ANN index (HNSW, IVF). Latency-critical. |
| Graph artifacts (parquet) | Bulk reads when the API starts; rare writes | Columnar storage. Throughput > latency. |
| Community reports | Read N reports per global query as long text blobs | Document store or blob storage. Read-heavy. |
| LLM cache | Hash-keyed reads to skip duplicate LLM calls | Key-value store with TTL. Saves 80%+ on re-indexing. |
Forcing all four into Postgres "works" up to ~100k entities, but each layer is sub-optimal for the others' workloads. Splitting them lets you scale and operate each independently β and pick a managed service for each.
ββββββββββββββββββββββββ
β API service β
β (FastAPI / Express) β
ββββββββββ¬ββββββββββββββ
β
ββββββββββββββ¬βββββββββββββββββΌβββββββββββββββββ¬βββββββββββββ
βΌ βΌ βΌ βΌ βΌ
βββββββββββ βββββββββββ βββββββββββββββ ββββββββββββ ββββββββββ
β Vector β β Object β β Document / β β Cache β β LLM β
β store β β storage β β Graph DB β β (Redis) β β (API) β
βββββββββββ βββββββββββ βββββββββββββββ ββββββββββββ ββββββββββ
entity parquet community LLM answer
embeddings artifacts reports cache generation
ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β Client β API Gateway β ECS Fargate (FastAPI + GraphRAG) β
β β β
β βββ S3 β parquet β
β βββ OpenSearch β vectors β
β βββ DynamoDB β reports β
β βββ ElastiCache Redis β LLM cache β
β βββ Bedrock β LLM β
ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
| Layer | AWS service | Why |
|---|---|---|
| Vector store | OpenSearch Service (k-NN) | Managed HNSW, scales to billions, hybrid search. |
| Aurora / RDS + pgvector | Cheaper for <5M vectors; SQL filters. | |
| MemoryDB for Redis (vector) | Lowest latency; doubles as cache. | |
| Object storage | S3 | Cheap, durable, GraphRAG can read parquet directly. |
| Document store | DynamoDB or S3 | DynamoDB if you need low-latency per-community reads. |
| Cache | ElastiCache for Redis | Standard. |
| LLM | Bedrock (Claude / Llama / Titan) | One API, no key management. |
| Compute | ECS Fargate or App Runner | Long-running container; avoids Lambda cold starts. |
Gotchas on AWS:
- GraphRAG doesn't ship an OpenSearch adapter natively β use pgvector on Aurora, or write a ~150-line custom
VectorStoreadapter. - Bedrock isn't OpenAI-compatible. Easiest fix: run LiteLLM Proxy as a shim and point
llm.api_baseat it. No GraphRAG code changes. - Don't use Lambda for the query path β parquet reload per cold start kills latency.
ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β Client β APIM β Container Apps (FastAPI + GraphRAG) β
β β β
β βββ Azure Blob Storage β parquet β
β βββ Azure AI Search β vectors β
β βββ Cosmos DB β reports/state β
β βββ Azure OpenAI β LLM β
ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
| Layer | Azure service | Why |
|---|---|---|
| Vector store | Azure AI Search | First-class GraphRAG support out of the box. |
| Object storage | Blob Storage | Native parquet support in GraphRAG. |
| Document store | Cosmos DB | Globally distributed; first-class GraphRAG support. |
| Cache | Azure Cache for Redis | Standard. |
| LLM | Azure OpenAI | gpt-4o + embeddings; same API as openai.com. |
| Compute | Container Apps | Auto-scaling containers. |
Zero-friction path: the official GraphRAG Accelerator is a one-click Bicep deployment of the above. If you don't have a strong cloud preference, this is the fastest production start.
ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β Client β Cloud Load Balancer β Cloud Run (FastAPI + GraphRAG) β
β β β
β βββ GCS β parquetβ
β βββ Vertex AI Vector β vectorsβ
β β Search β
β βββ Firestore β reportsβ
β βββ Memorystore Redis β cache β
β βββ Vertex AI Gemini β LLM β
ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
| Layer | GCP service | Why |
|---|---|---|
| Vector store | Vertex AI Vector Search | Managed ScaNN; sub-10ms latency at scale. |
| Cloud SQL + pgvector | Cheaper for small corpora. | |
| Object storage | Cloud Storage (GCS) | Standard. |
| Document store | Firestore | NoSQL; pay-per-read fits low-QPS report lookups. |
| Cache | Memorystore for Redis | Standard. |
| LLM | Vertex AI (Gemini / Claude on Vertex) | Or use Anthropic API directly. |
| Compute | Cloud Run | Serverless containers; min-instances=1 to avoid cold starts. |
Note: GraphRAG has no native Vertex Vector Search adapter β use pgvector or write a thin adapter. For Gemini, LiteLLM Proxy works the same way as on AWS.
ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β Client β Caddy/Nginx β FastAPI (in Docker / Kubernetes) β
β β β
β βββ MinIO or local FS β parquet β
β βββ Qdrant β vectors β
β βββ Postgres β reports β
β βββ Redis β cache β
β βββ Ollama / vLLM β LLM β
ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
| Layer | Self-hosted option | Why |
|---|---|---|
| Vector store | Qdrant | Fast, great filtering, single binary. |
| Weaviate or Milvus | If you need clustering/replication. | |
| Postgres + pgvector | Simplest if you already run Postgres. | |
| Object storage | MinIO (S3-compatible) | Same API as S3 for GraphRAG. |
| Document store | Postgres | One database for reports + state. |
| Cache | Redis | Standard. |
| LLM | Ollama (llama3.1 / qwen2.5) or vLLM | Fully offline; quality < gpt-4o. |
| Compute | Docker Compose or Kubernetes | Your choice. |
This is the right pick when data can't leave your VPC (compliance / on-prem).
| Goal | Stack | Monthly cost |
|---|---|---|
| Demo for stakeholders | Single Aurora Serverless v2 (pgvector) + S3 + App Runner + Bedrock Claude Haiku | $30β80 |
| Internal tool, <1k queries/day | Same as above with ElastiCache + Bedrock Claude Sonnet | $100β250 |
| Customer-facing, <100k queries/day | OpenSearch + S3 + DynamoDB + Redis + ECS Fargate + Bedrock | $500β1500 |
| Fully offline / compliance | Qdrant + MinIO + Postgres + Redis + Ollama (on 1 GPU node) | hardware-only |
GraphRAG supports the storage backend swap declaratively in settings.yml:
# Local development (current setup) vector_store: type: lancedb db_uri: "output/lancedb" # Production on Azure vector_store: type: azure_ai_search url: "https://my-search.search.windows.net" api_key: ${AZURE_SEARCH_KEY} # Production with custom adapter (Qdrant, OpenSearch, Pinecone) vector_store: type: "my_company.vector.qdrant_store" # dotted import path collection_name: "graphrag_entities"
For LLM swap (e.g. to Bedrock via LiteLLM):
llm: type: openai_chat api_base: "http://litellm-proxy:4000/v1" # LiteLLM shim model: "anthropic.claude-sonnet-4-6" api_key: ${LITELLM_KEY}
The graph itself is portable β once indexed, you can move the parquet files to any backend without re-running the LLM-heavy indexing step.
The single biggest perceived-latency win, before swapping any backends, is stop spawning a new Python process per query. Wrap the existing query logic in a FastAPI service so the parquet + LanceDB load once at startup:
# server.py (sketch) from fastapi import FastAPI from graphrag.query import GlobalSearch, LocalSearch # already in your venv app = FastAPI() local = LocalSearch.from_config("./settings.yml") # loads once global_= GlobalSearch.from_config("./settings.yml") # loads once @app.get("/query") def query(q: str, method: str = "local"): engine = local if method == "local" else global_ return engine.search(q)
Run it with uvicorn server:app --workers 4 and you've removed ~3 seconds of
cold start per query β usually enough to defer the whole "should I move to
OpenSearch?" question by another six months.
| Resource | URL |
|---|---|
| Microsoft GraphRAG repo | https://github.com/microsoft/graphrag |
| Original research paper | https://arxiv.org/abs/2404.16130 |
| Official documentation | https://microsoft.github.io/graphrag/ |
| GraphRAG Prompt Tuning guide | https://microsoft.github.io/graphrag/prompt_tuning/overview/ |
graph-rag/
βββ input/ # Your source documents (txt files)
β βββ silicon_valley_chronicles.txt # Sample: rich fictional AI industry story
βββ prompts/ # LLM prompts (created by --init, customizable)
β βββ entity_extraction.txt
β βββ summarize_descriptions.txt
β βββ community_report.txt
βββ output/ # Auto-generated index (gitignored)
β βββ <timestamp>/
β βββ artifacts/ # Parquet files: entities, edges, communities
β βββ reports/ # Run logs
βββ cache/ # LLM call cache β speeds up re-runs (gitignored)
βββ settings.yml # Pipeline configuration
βββ .env # Your API key (gitignored, never commit)
βββ .env.example # Template for .env
βββ requirements.txt # Python dependencies
βββ query.py # Convenience query wrapper script
Error: GRAPHRAG_API_KEY not found
Fix: Make sure .env exists and contains your real key (not the placeholder)
Run: cp .env.example .env then edit .env
Error: No module named 'graphrag'
Fix: Activate your virtual environment first:
source .venv/bin/activate
Error: RateLimitError from OpenAI
Fix: Lower concurrent_requests in settings.yml to 5 or 10
Error: FileNotFoundError: output/ directory not found
Fix: You haven't run the indexer yet.
Run: python -m graphrag.index --root .
Error: The answer is empty or very short
Fix: Your input document may be too short.
GraphRAG works best with 1,000+ words of rich narrative text.