Graph RAG¶
Graph RAG provides retrievers that combine unstructured similarity-search on vectors and structured traversal of metadata properties. These retrievers are implemented using the metadata search functionality of existing vector stores, allowing you to traverse your existing vector store!
-
Link based on existing metadata
Use existing metadata fields without additional processing. Retrieve more from your existing vector store!
-
Change links on demand
Edges can be specified on-the-fly, allowing different relationships to be traversed based on the question.
-
Pluggable Traversal Strategies
Use built-in traversal strategies like Eager or MMR, or define your own logic to select which nodes to explore.
-
Broad compatibility
Adapters are available for a variety of vector stores with support for additional stores easily added.
Example: LangChain Retriever combining Vector and Graph traversal¶
from langchain_graph_retriever import GraphRetriever
from graph_retriever.edges import Id
retriever = GraphRetriever(
store = store,
edges = [("mentions", Id()), ("entities", "entities")], # (1)!
)
retriever.invoke("where is Santa Clara?")
edges
configures traversing from a node to other nodes listed in themetadata["mentions"]
field (to the correspondingid
) and to other nodes with overlappingmetadata["entities"]
.
See Examples for more complete examples.