RAG vs Graph RAG, explained visually
RAG vs Graph RAG, explained visually.
(it's a popular LLM interview question)
Imagine you have a long document, say a biography, about an individual (X) who has accomplished several things in this life.
↳ Chapter 1: Talks about Accomplishment-1.
↳ Chapter 2: Talks about Accomplishment-2.
...
↳ Chapter 10: Talks about Accomplishment-10.
Summarizing all these accomplishments via RAG might never be possible since...
...it must require the entire context...
...but one might only be fetching the top-k relevant chunks from the vector db.
Moreover, since traditional RAG systems retrieve each chunk independently, this can often leave the LLM to infer the connections between them (provided the chunks are retrieved).
Graph RAG solves this.
The idea is to first create a graph (entities & relationships) from the documents and then do traversal over that graph during the retrieval phase.
See how Graph RAG solves the above problems.
- First, a system (typically an LLM) will create the graph by understanding the biography.
- This will produce a full graph of nodes entities & relationships, and a subgraph will look like this:
↳ X → → Accomplishment-1.
↳ X → → Accomplishment-2.
...
↳ X → → Accomplishment-N.
When summarizing these accomplishments, the retrieval phase can do a graph traversal to fetch all the relevant context related to X's accomplishments.
This context, when passed to the LLM, will produce a more coherent and complete answer as opposed to traditional RAG.
Another reason why Graph RAG systems are so effective is because LLMs are inherently adept at reasoning with structured data.
Graph RAG instills that structure into them with their retrieval mechanism.
👉 Over to you: What are some other issues with traditional RAG systems that Graph RAG solves?
____
Find me → Avi Chawla
Every day, I share tutorials and insights on DS, ML, LLMs, and RAGs. | 24 comments on LinkedIn
RAG vs Graph RAG, explained visually