Understanding GraphRAG
This section describes GraphRAG, a retrieval approach that combines vector similarity search with knowledge graph traversal. GraphRAG is designed for questions that require connected facts from multiple chunks or documents.
What Is GraphRAG
Retrieval-augmented generation retrieves relevant information before generating a response. In a typical vector retrieval workflow, documents are divided into chunks, converted into vector embeddings, and searched for semantic similarity.
During knowledge graph creation, entities and relationships are extracted from source chunks. At query time, vector search identifies relevant starting points, and graph traversal expands retrieval to include connected information.
You can create, query, and manage knowledge graphs using the DBMS_AI_GRAPHRAG PL/SQL package. For information about the subprograms provided by this package, see DBMS_AI_GRAPHRAG.
Why Use GraphRAG
Vector search finds text that is semantically similar to a question. However, the information needed to answer a question might be distributed across multiple chunks.
For example, consider the question:
Who is the spouse of the author of Young Man Luther?
The answer requires two connected facts:
-
Chunk C1: “Young Man Luther: A Study in Psychoanalysis and History is a 1958 book by psychologist Erik Erikson.”
This identifies the author of the book as Erik Erikson.
-
Chunk C2: “Erik Erikson collaborated with Joan Erikson, his wife.”
This identifies Joan Erikson as Erik Erikson’s spouse.
GraphRAG connects these facts through the following path:
Young Man Luther
|
written by
|
Erik Erikson
|
husband of
|
Joan Erikson
A vector search might retrieve Chunk C1 because it mentions Young Man Luther, the book named in the question. Chunk C2 identifies Joan Erikson as Erik Erikson’s spouse, but does not mention the book or identify Erik Erikson as its author. Therefore, vector search might rank Chunk C2 too low to include in the retrieved results.
GraphRAG can follow the extracted relationships from Young Man Luther to its author, Erik Erikson, and then to his spouse, Joan Erikson, thereby connecting evidence from both chunks.
The final answer is Joan Erikson.
This demonstrates how GraphRAG supports questions that require multiple connected facts rather than a single matching text fragment.
GraphRAG Components
GraphRAG represents source information using the following components:
- Entities represent identifiable objects, such as people, books, organizations, products, or dates. Example: Young Man Luther is a book; Erik Erikson and Joan Erikson are people; 1958 is a date.
- Relationships and Edges describe how entities are connected and are represented by labeled edges in the graph. For example,
Young Man Luther — written by→ Erik Erikson. - Chunks contain the source text from which entities and relationships are extracted. Example: Chunk C1 says Young Man Luther is a 1958 book by psychologist Erik Erikson. Chunk C2 says Erik Erikson collaborated with Joan Erikson, his wife.
- Embeddings are numerical representations of text that help vector search find semantically similar information. Example: The question “Who is the spouse of the author of Young Man Luther?” can lead vector search to relevant chunks about the book, its author, and Erik Erikson’s spouse.