Careeroza
GraphRAG Overview
Retrieval over Relationships
Some questions need facts that are connected, not similar: "Which service centre handles the brand of the item in my order?". The answer needs order → item → brand → service centre. GraphRAG extracts entities and relations from documents into a knowledge graph and walks the graph to collect connected facts.
Example
Example
A tiny knowledge graph of triples and a two-hop walk. The collected facts are what you would put in the prompt.
TRIPLES = [
("SE1042", "contains", "Boat Airdopes 141"),
("Boat Airdopes 141", "brand", "boAt"),
("boAt", "service_centre", "boAt Care, Koramangala, Bengaluru"),
("boAt", "warranty", "1 year"),
("SE1077", "contains", "Prestige Svachh 3L"),
]
graph = {}
for s, rel, o in TRIPLES:
graph.setdefault(s, []).append((rel, o))
def walk(start, hops):
facts, frontier = [], [start]
for _ in range(hops):
nxt = []
for node in frontier:
for rel, o in graph.get(node, []):
facts.append(f"{node} --{rel}--> {o}")
nxt.append(o)
frontier = nxt
return facts
for f in walk("SE1042", 3):
print(f)Output
SE1042 --contains--> Boat Airdopes 141 Boat Airdopes 141 --brand--> boAt boAt --service_centre--> boAt Care, Koramangala, Bengaluru boAt --warranty--> 1 year
When It Is Worth It
| Use GraphRAG when | Stay with vector + hybrid RAG when |
|---|---|
| questions need multi-hop links (people, products, suppliers) | answers live in one or two passages |
| you need "global" summaries across many documents | documents are FAQ or policy style |
| you already have structured data (a product catalogue, an org chart) | budget is tight: building the graph costs many LLM calls |
Tools: Microsoft's open-source GraphRAG, Neo4j with vector indexes, LlamaIndex's property graph index. Often a plain SQL join over your own tables is the best "graph".