Home » Uncategorized

Understanding GraphRAG – 2 addressing the limitations of RAG

  • ajitjaokar 
Screenshot-2024-04-18-20.20.44

Background

We follow on from the last post and explore the limitations of RAG and how you can overcome these limitations using the idea of a GRAPHRAG. The GRAPHRAG combines a knowledge graph with a RAG. Thus, the primary construct of the GRAPHRAG is a knowledge graph.  A Knowledge Graph represents knowledge and its relationships as a set of nodes and edges. The knowledge graph has a very simple but distinct advantage in terms of context: In a knowledge graph, all the context is directly adjacent to the node within the graph.

This property of knowledge graphs, when combined with LLMs, provides two major benefits:

  1. Providing explainability and 
  2. Reducing hallucination

LLMs are black box models. To some extent, you can mitigate some of the issues of LLMs using a RAG. RAG provides context in the form of sources(documents). Additionally, you can reduce hallucination and provide explainability through knowledge GRAPHRAG.

In a nutshell, the Graph RAG enriches the standard LLM approach with structured information from a knowledge graph because the GRAPHRAG includes the knowledge graph as a source for the LLM.

Graphs and LLMs can work together in a variety of ways.

How do Graphs and LLMs work together

The most common way is when you use the graph to provide additional context such as the relationship between concepts based on an ontology, taxonomy etc. But you could also use the knowledge graph to create a subset of the database or use the knowledge graph to summarise the results of the query.

We are now seeing some commercial products in this space. Most recently a partnership between neo4j and Microsoft on integrating graph databases into Azure . This partnership involves the end-to-end implementations of GRAPHRAG using Microsoft Fabric and Azure OpenAI services working with structured and unstructured data. This helps applications like Bill of Materials where we can perform a query combining unstructured documents (like user manuals) and structured documents (like Bill of materials) leveraging both vector and graph databases. 

The OpenAI interface can be used both as a conversation agent and also as a way to extract entities and relations using LLM

Understanding GraphRAG – 2 addressing the limitations of RAG

We can see more as below 

Source Azure – neo4j

There are many use cases possible especially as context changes. For exampe, a new word has been introduced in the Oxford English Dictionary called Porch Pirate

Definition: “A person who steals parcels that have been delivered and left unattended outside the intended recipient’s home”

If we ask the LLM – “I am afraid of porch pirates – as a postman what could I do”? A graphrag could perhaps be designed to answer where else the parcel could be delivered(for example a neighbours house)

We continue this analysis in the third part 3