CodeAlchemy
Jotting one man's journey through software development, programming, and technology
Project maintained by pablogarciaprado
Hosted on GitHub Pages — Theme by mattgraham
GraphRAG
◀️ Home
GraphRAG is RAG where R path includes a Knowledge Graph.

GraphRAG Retrieval Patterns
- Do a vector search to find an initial set of nodes.
- Traverse the graph around those nodes to add context.
- (Optional) Rank the results using the graph and pass the top-k documents to the LLM.
Benefits
- Higher accuracy
- Easier development
- Explainability & Governance
Data semantics
Not competing ways of doing it, but complimentary.

Knowledge Graph Construction
We can have structured, unstructured data, or a mix of both.
Structured Data
Structured Data with short text values.
- Good methodology,
- Good tools,
- Common in enterprises
Unstructured Data
Typically PDFs or other text documents.
- Intrinsically hard,
- Immature tooling,
- “hello world” use case
Mix of Structured & Unstructured Data
Structured Data with long-form text.
- Good methodology,
- Good tools,
- Real-world use case
Two Types of Knowledge Graphs
Lexical Graph
A graph representation of for example the words, paragraphs, chunks, documents, and the relationship between them.
Domain Graph
A graph representation of the real or digital world, i.e. the domain you’re modeling.
These two are not exhaustive. They’re also not mutually exclusive.
Sources: