Using StarRocks Vector Store with LangChain
Posted: Nov 16, 2024.
StarRocks is a high-performance analytical database that can be used as a vector store in LangChain. This guide will show you how to use the StarRocks vector store integration to store and search document embeddings.
What is StarRocks Vector Store?
StarRocks vector store is a LangChain integration that allows you to use StarRocks as a storage backend for document embeddings. It provides functionality for:
- Storing document embeddings and metadata in StarRocks tables
- Performing similarity search using cosine similarity
- Supporting metadata filtering
- Async operations for better performance
The main benefit of using StarRocks as a vector store is its excellent query performance thanks to its vectorized execution engine.
Reference
Here are the main methods available in the StarRocks vector store:
Method | Description |
---|---|
add_texts() | Add text documents to the vector store |
add_documents() | Add Document objects to the vector store |
similarity_search() | Search for similar documents using a text query |
similarity_search_with_score() | Search with similarity scores |
similarity_search_by_vector() | Search using embedding vectors directly |
delete() | Delete documents by ID |
drop() | Drop the vector store table |
How to Use StarRocks Vector Store
Setting up the Connection
First, you need to configure the connection to your StarRocks instance:
Adding Documents
You can add documents in two ways:
Searching Documents
Perform similarity search queries:
Async Operations
StarRocks vector store also supports async operations for better performance:
Using as a Retriever
The vector store can be used as a retriever in LangChain chains:
StarRocks vector store provides a robust solution for storing and searching document embeddings, especially when you need high query performance. The integration with LangChain makes it easy to use StarRocks in your LLM applications.
An alternative to LangSmith
Open-source LangChain monitoring, prompt management, and magic. Get started in 2 minutes.
LangChain DocsJoin 10,000+ subscribers
Every 2 weeks, latest model releases and industry news.
An alternative to LangSmith
Open-source LangChain monitoring, prompt management, and magic. Get started in 2 minutes.