Skip to content

datastax/graph-rag

Repository files navigation

Graph RAG

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

Status Coverage Contributors Forks Stargazers Issues License


Logo

Graph RAG - Combining Vector and Graph for better RAG

Library providing Graph RAG combining vector search and traversal of metadata relationships.
Explore the docs » -->

Report Bug · Request Feature

Table of Contents
  1. About The Project
  2. Getting Started with LangChain
  3. Roadmap
  4. Contributing
  5. License

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-specific functionality.

(back to top)

Getting Started with LangChain

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

    pip install langchain-graph-retriever
  2. Wrap your existing vector store to enable graph retrieval:

    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?")

Roadmap

Graph RAG is under active development. This is an overview of our current roadmap - please 👍 issues that are important to you. Don't see a feature that would be helpful for your application - create a feature request!

  • Support more vector stores
  • Support Lazy Graph RAG on the retrieved documents.

Contributing

Contributions are what make the open source community such an amazing place to learn, inspire, and create. Any contributions you make are greatly appreciated.

If you have a suggestion that would make this better, please fork the repo and create a pull request. You can also simply open an issue with the tag "enhancement". Don't forget to give the project a star! Thanks again!

  1. Fork the Project
  2. Create your Feature Branch (git checkout -b feature/AmazingFeature)
  3. Commit your Changes (git commit -m 'Add some AmazingFeature')
  4. Push to the Branch (git push origin feature/AmazingFeature)
  5. Open a Pull Request

See CONTRIBUTING.md for more information on development.

(back to top)

License

Distributed under the Apache 2 License. See LICENSE.txt for more information.

(back to top)