Graph RAG
Some questions are never answered in a single similar paragraph. Graph RAG walks relationships the documents imply but never state together. Extraction and entity resolution cost more than naive RAG — use it when hops matter.
Vector RAG is 'find pages like this question.' Graph RAG is 'start at this company and follow acquired-by until you hit a country.'
Visual Workflows
Start here — scroll inside each diagram frame to explore, then use + / − to zoom up to 200% if needed.
Overview
Scroll inside the frame to explore · use + / − to zoom up to 200%
Scroll inside the frame to explore · use + / − to zoom up to 200%
Microsoft-style GraphRAG idea
Scroll inside the frame to explore · use + / − to zoom up to 200%
Build communities, summarize, then retrieve a subgraph plus text.
Hybrid is common
Scroll inside the frame to explore · use + / − to zoom up to 200%
Vectors find the paragraph. The graph finds the hop the paragraph never states.
Key Takeaways
- 1.Graph RAG retrieves a subgraph (and often text chunks) then generates.
- 2.It is for multi-hop and relational questions, not a default replacement for vector RAG.
- 3.Typical flow: extract a graph from the corpus, resolve entities, optionally cluster communities and summarize (Microsoft GraphRAG-style).
- 4.At query time, identify seed entities, pull a bounded subgraph plus related text, and prompt the LLM with both.
- 5.Hybrid is common: vectors find the seed passage, the graph expands.
Real Example
Scenario
'Which products of companies Acme acquired in 2024 mention GDPR?' needs acquisition edges and then document text — neither store alone is enough.
What you would do
In RAG Engineering, apply Graph RAG to this scenario: 'Which products of companies Acme acquired in 2024 mention GDPR?' needs acquisition edges and then document text — neither store alone is enough. Identify the inputs, run the technique, validate the output, and note one thing you would monitor in production.
Practice Task
Open the Code Walkthrough below and run it locally. Change one parameter related to Graph RAG (e.g. model, temperature, top_k, or tool name), observe the difference in output, and write 2–3 sentences explaining what changed.
Code Walkthrough
Highlighted lines show where Graph RAG happens in the code.
1# Graph RAG — minimal example2from openai import OpenAI3
4client = OpenAI() # create API client5
6# Ask the model to explain this topic7response = client.chat.completions.create( # core API call for Graph RAG8 model="gpt-4o-mini",9 messages=[10 {"role": "system", "content": "You explain graph rag clearly."},11 {"role": "user", "content": f"What is graph rag?"},12 ],13 temperature=0,14)15print(response.choices[0].message.content) # show output for debuggingCommands
Commands to Remember
Graph RAG = retrieve a subgraph (and often chunks), then generateUse it for multi-hop / relational questions, not every FAQExtraction + entity resolution quality bounds the whole systemEval needs multi-hop questions, not only single-paragraph facts
Cheat Sheet
Quick recap
quick ref- •Retrieve subgraph + text, then generate
- •For multi-hop / relational questions
- •Extraction quality bounds the system
- •Eval with hop questions, not only FAQs
Common Mistakes
- ✕Running Graph RAG on every FAQ — expensive and slower
- ✕Skipping entity resolution so hops never connect
- ✕Unbounded traversal that dumps the whole graph into the prompt
