GraphRetriever
from the langchain-graph-retriever
package provides a LangChain
retriever that combines unstructured similarity search
on vectors with structured traversal of metadata properties. This enables graph-based
retrieval over an existing vector store.
Retriever | Source | PyPI Package | Latest | Project Page |
---|---|---|---|---|
GraphRetriever | github.com/datastax/graph-rag | langchain-graph-retriever | Graph RAG |
langchain-graph-retriever
package.
langchain-graph-retriever
package with the astra
extra:ASTRA_DB_API_ENDPOINT
and ASTRA_DB_APPLICATION_TOKEN
credentials,
consult the AstraDB Vector Store Guide.:::note
For faster initial testing, consider using the InMemory Vector Store.
:::habitat
and/or origin
.
start_k=1
), retrieves 5 documents (k=5
) and limits the search to documents
that are at most 2 steps away from the first animal (max_depth=2
).
The edges
define how metadata values can be used for traversal. In this case, every
animal is connected to other animals with the same habitat
and/or origin
.
capybara
, heron
, frog
, crocodile
, and newt
all
share the same habitat=wetlands
, as defined by their metadata. This should increase
Document Relevance and the quality of the answer from the LLM.
max_depth=0
, the graph traversing retriever behaves like a standard retriever:
start_k=5
),
and returns them without any traversal (max_depth=0
). The edge definitions
are ignored in this case.
This is essentially the same as:
.invoke
is used to initiate retrieval on a query.
GraphRetriever
can be incorporated into LLM applications
via chains.