🕸️ Graph RAG Q8 / 24

What are nodes and edges in a knowledge graph?

AI-Powered Answer ✓ Answered

In the context of knowledge graphs, especially those used for Retrieval Augmented Generation (RAG), the fundamental building blocks are nodes and edges. They represent entities and the relationships between them, structuring information in a highly connected and retrievable manner.

Nodes

Nodes, also known as vertices, are the fundamental entities or concepts within a knowledge graph. They represent discrete pieces of information or real-world objects.

Examples of nodes can include people, organizations, locations, events, documents, specific facts, or even abstract concepts. In a RAG context, a node might represent a document chunk, a key entity extracted from text, or a specific answer.

Edges

Edges, also known as relationships or predicates, connect two nodes and describe the nature of their relationship. They provide context and meaning by indicating how different entities are related to each other.

Edges are directional and often have a type or label. For instance, 'is author of', 'located in', 'has property', 'relates to', 'mentions', or 'is a prerequisite for'. An edge always links a 'source' node to a 'target' node.

Nodes and Edges in a RAG-Graph Context

When building a knowledge graph specifically for RAG, nodes might represent different types of information, such as:<ul><li>Document Chunks: Individual text snippets from source documents.</li><li>Entities: Named entities (persons, organizations, places, dates, products, etc.) extracted from the chunks.</li><li>Concepts: Abstract ideas or topics discussed.</li><li>Questions/Answers: If the graph is built from Q&A pairs.</ul>Edges then define the connections between these, for example:<ul><li>'CONTAINS': A document chunk CONTAINS an entity.</li><li>'MENTIONS': An entity MENTIONS another entity.</li><li>'RELATED_TO': A concept RELATED_TO another concept.</li><li>'ANSWERS': A document chunk ANSWERS a specific question.</ul>

This interconnected structure allows RAG systems to traverse the graph to find not just relevant documents, but also specific facts and their relationships, leading to more accurate, contextual, and explainable responses than traditional vector search alone.