File size: 1,764 Bytes
1375112
 
 
 
 
 
 
57ab06a
 
1375112
 
be0f180
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
57ab06a
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
---
title: README
emoji: πŸ†
colorFrom: indigo
colorTo: blue
sdk: static
pinned: false
license: apache-2.0
short_description: Smarter vector search with metadata-aware traversal
---

# Graph RAG

Retrievers providing both **unstructured** (similarity-search on vectors) and
**structured** (traversal of metadata properties).

## About The Project

Graph RAG provides retrievers combining vector-search (for unstructured similarity) and traversal (for structured relationships in metadata).
These retrievers are implemented using the metadata search functionality of existing vector stores, **allowing you to traverse your existing vector store**!

The core library (`graph-retriever`) supports can be used in generic Python applications, while `langchain-graph-retriever` provides [langchain](https://python.langchain.com/docs/introduction/)-specific functionality.

<!-- GETTING STARTED -->
## Getting Started with LangChain

1. Install `langchain-graph-retriever` (or add to your Python dependencies).

    ```sh
    pip install langchain-graph-retriever
    ```

1. Wrap your existing vector store to enable graph retrieval:

    ```python
    from langchain_graph_retriever import GraphRetriever

    retriever = GraphRetriever(
        # Adapt AstraDBVectorStore for use with Graph Retrievers.
        # Exposes functionality of the underlying store that is otherwise not available.
        store = store,
        # Define the relationships to navigate:
        #   1. From nodes with a list of `mentions` to the nodes with the corresponding `ids`.
        #   2. From nodes with a list of related `entities` to other nodes with the same entities.
        edges = [("mentions", "id"), "entities"],
    )

    retriever.invoke("where is Santa Clara?")
    ```