Upstash Vector
Upstash Vector is a serverless vector database that can be used to store and query vectors.Installation
Create a new serverless vector database at the Upstash Console. Select your preferred distance metric and dimension count according to your model. Install the Upstash Vector Python SDK withpip install upstash-vector
.
The Upstash Vector integration in langchain is a wrapper for the Upstash Vector Python SDK. That’s why the upstash-vector
package is required.
Integrations
Create aUpstashVectorStore
object using credentials from the Upstash Console.
You also need to pass in an Embeddings
object which can turn text into vector embeddings.
UpstashVectorStore
is to pass embedding=True
. This is a unique
feature of the UpstashVectorStore
thanks to the ability of the Upstash Vector indexes
to have an associated embedding model. In this configuration, documents we want to insert or
queries we want to search for are simply sent to Upstash Vector as text. In the background,
Upstash Vector embeds these text and executes the request with these embeddings. To use this
feature, create an Upstash Vector index by selecting a model
and simply pass embedding=True
:
Namespaces
You can use namespaces to partition your data in the index. Namespaces are useful when you want to query over huge amount of data, and you want to partition the data to make the queries faster. When you use namespaces, there won’t be post-filtering on the results which will make the query results more precise.Inserting Vectors
Embeddings
object.
Most embedding models can embed multiple documents at once, so the documents are batched and embedded in parallel.
The size of the batch can be controlled using the embedding_chunk_size
parameter.
The embedded vectors are then stored in the Upstash Vector database. When they are sent, multiple vectors are batched together to reduce the number of HTTP requests.
The size of the batch can be controlled using the batch_size
parameter. Upstash Vector has a limit of 1000 vectors per batch in the free tier.
Querying Vectors
Vectors can be queried using a text query or another vector. The returned value is a list of Document objects.filter
parameter which will allow you to filter by metadata:
Deleting Vectors
Vectors can be deleted by their IDs.Getting information about the store
You can get information about your database like the distance metric dimension using the info function. When an insert happens, the database an indexing takes place. While this is happening new vectors can not be queried.pendingVectorCount
represents the number of vector that are currently being indexed.
Upstash Redis
This page covers how to use Upstash Redis with LangChain.Installation and Setup
- Upstash Redis Python SDK can be installed with
pip install upstash-redis
- A globally distributed, low-latency and highly available database can be created at the Upstash Console
Integrations
All of Upstash-LangChain integrations are based onupstash-redis
Python SDK being utilized as wrappers for LangChain.
This SDK utilizes Upstash Redis DB by giving UPSTASH_REDIS_REST_URL and UPSTASH_REDIS_REST_TOKEN parameters from the console.