Rockset is a real-time search and analytics database built for the cloud. Rockset uses a Converged Index™ with an efficient store for vector embeddings to serve low latency, high concurrency search queries at scale. Rockset has full support for metadata filtering and handles real-time ingestion for constantly updating, streaming data.This notebook demonstrates how to use
Rockset
as a vector store in LangChain. Before getting started, make sure you have access to a Rockset
account and an API key available. Start your free trial today.
You’ll need to install langchain-community
with pip install -qU langchain-community
to use this integration
Setting Up Your Environment
-
Leverage the
Rockset
console to create a collection with the Write API as your source. In this walkthrough, we create a collection namedlangchain_demo
. Configure the following ingest transformation to mark your embeddings field and take advantage of performance and storage optimizations: (We used OpenAItext-embedding-ada-002
for this examples, where #length_of_vector_embedding = 1536)
-
After creating your collection, use the console to retrieve an API key. For the purpose of this notebook, we assume you are using the
Oregon(us-west-2)
region. -
Install the rockset-python-client to enable LangChain to communicate directly with
Rockset
.
LangChain Tutorial
Follow along in your own Python notebook to generate and store vector embeddings in Rockset. Start using Rockset to search for documents similar to your search queries.1. Define Key Variables
2. Prepare Documents
3. Insert Documents
4. Search for Similar Documents
5. Search for Similar Documents with Filtering
6. [Optional] Delete Inserted Documents
You must have the unique ID associated with each document to delete them from your collection. Define IDs when inserting documents withRockset.add_texts()
. Rockset will otherwise generate a unique ID for each document. Regardless, Rockset.add_texts()
returns the IDs of inserted documents.
To delete these docs, simply use the Rockset.delete_texts()
function.
Summary
In this tutorial, we successfully created aRockset
collection, inserted
documents with OpenAI embeddings, and searched for similar documents with and without metadata filters.
Keep an eye on rockset.com/ for future updates in this space.