Graph RAG: Answering Questions with Connected Facts
Graph RAG answers complex questions by exploring a map of connected facts (a knowledge graph) instead of just searching flat text. Use it for queries needing synthesis, like finding drugs for a disease made by companies in a specific country.
WHY IT EXISTS: Standard Retrieval-Augmented Generation (RAG) retrieves chunks of text, which often lack the precise, explicit relationships needed to answer complex questions. An LLM might get documents about a company and a location, but not the explicit 'is headquartered in' link. Graph RAG was created to provide this structured, relational context, enabling more sophisticated reasoning.
THE MENTAL MODEL: Think of standard RAG as asking a librarian to pull relevant books off a shelf based on keywords. Graph RAG is like asking that librarian to also consult a detailed concept map that connects all the ideas, people, and events within those books. It retrieves not just information, but the explicit connections between pieces of information.
HOW IT WORKS: When a user asks a question, the system first translates the natural language into a formal query for the knowledge graph (e.g., using a language like Cypher or SPARQL). This query traverses the graph to find relevant entities and their relationships. The retrieved subgraph—the specific nodes and edges that answer the query—is then serialized into text and fed to the LLM as context, along with the original prompt. The LLM then synthesizes an answer based on this highly structured information.
WHEN TO USE IT: Use Graph RAG for domains where relationships are key. Three places this shows up: first, in fraud detection, for connecting accounts, transactions, and devices; second, in drug discovery, for linking genes, proteins, and diseases; third, in complex Q&A systems where queries involve multiple hops, like 'What are the side effects of medications prescribed for conditions related to protein X?'.
WHEN NOT TO USE IT: Avoid it for simple fact retrieval from unstructured text where keyword search is sufficient. The overhead of building and maintaining a high-quality knowledge graph is substantial. If your data is a collection of independent documents (like news articles or support tickets), standard vector-based RAG is often more practical and cost-effective.
ONE CANONICAL EXAMPLE: A user asks, 'Which movies directed by James Cameron were nominated for an Oscar for Best Picture?' A Graph RAG system would parse the query to identify entities ('James Cameron') and relationships ('directed', 'nominated for'). It would then query the knowledge graph to find the 'James Cameron' node, follow the 'DIRECTED' edges to movie nodes, and then check which of those movie nodes have a 'NOMINATED_FOR' edge pointing to the 'Oscar for Best Picture' node. The resulting list of movies is then passed to the LLM to formulate a natural language answer.
Read the original → en.wikipedia.org
Get five bites like this every day.
Tezvyn delivers a daily feed of 60-second tech bites with quizzes to lock in what you learn.