Skip to main content

LangChain retriever for traversing document graphs on top of vector-based similarity search.

Project description

LangChain Graph Retriever

LangChain Graph Retriever is a Python library that supports traversing a document graph on top of vector-based similarity search. It works seamlessly with LangChain's retriever framework and supports various graph traversal strategies for efficient document discovery.

Features

  • Vector Search: Perform similarity searches using vector embeddings.
  • Graph Traversal: Apply traversal strategies such as breadth-first (Eager) or Maximal Marginal Relevance (MMR) to explore document relationships.
  • Customizable Strategies: Easily extend and configure traversal strategies to meet your specific use case.
  • Multiple Adapters: Support for various vector stores, including AstraDB, Cassandra, Chroma, OpenSearch, and in-memory storage.
  • Synchronous and Asynchronous Retrieval: Supports both sync and async workflows for flexibility in different applications.

Installation

Install the library via pip:

pip install langchain-graph-retriever

Getting Started

Here is an example of how to use LangChain Graph Retriever:

from langchain_graph_retriever import GraphRetriever
from langchain_core.vectorstores import Chroma

# Initialize the vector store (Chroma in this example)
vector_store = Chroma(embedding_function=your_embedding_function)

# Create the Graph Retriever
retriever = GraphRetriever(
    store=vector_store,
    # Define edges based on document metadata
    edges=[("keywords", "keywords")],
)

# Perform a retrieval
documents = retriever.retrieve("What is the capital of France?")

# Print the results
for doc in documents:
    print(doc.page_content)

License

This project is licensed under the Apache 2 License. See the LICENSE file for more details.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

langchain_graph_retriever-0.5.1.tar.gz (33.5 kB view details)

Uploaded Source

Built Distribution

File details

Details for the file langchain_graph_retriever-0.5.1.tar.gz.

File metadata

File hashes

Hashes for langchain_graph_retriever-0.5.1.tar.gz
Algorithm Hash digest
SHA256 b6bd563e1761d13bf3b7316ccb1fd68320347b33e81f0b8e3b7119917e92c656
MD5 d55f56c14f8c68de91d3854df4cc39ba
BLAKE2b-256 77c48663bf0a30f09c1ce5c79a54cb9d9a7c4aa666be86c4748925ebe4191dd9

See more details on using hashes here.

File details

Details for the file langchain_graph_retriever-0.5.1-py3-none-any.whl.

File metadata

File hashes

Hashes for langchain_graph_retriever-0.5.1-py3-none-any.whl
Algorithm Hash digest
SHA256 4d9c1f39d88c293a7f0a46aa3ebe2e8359465fd2c002ba56cd386338fdb56f4d
MD5 6df5f801af5e7c7ada917c6ba29a19c6
BLAKE2b-256 063e0f9e45aa9ea415a0f6cfdbf2d15dd9b54799146f5f4cbcd34f9bbd18eb57

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page