Important Note on Python Version
Recent Python versions may cause compatibility issues withtorch, a dependency for Hugging Face models. Therefore, we recommend using Python 3.9 to avoid any installation issues.
Installation and Setup
First, we need to set up our environment and install the necessary libraries. Install the dependencies by running the following command:.env file in your project directory with the following content, replacing your_upstash_url and your_upstash_token with your actual Upstash credentials:
Code
We will load our environment variables and initialize the Hugging Face embeddings model along with the Upstash Vector store.Embeddings object. Many embedding models, such as the Hugging Face models, support embedding multiple documents at once. This allows for efficient processing by batching documents and embedding them in parallel.
- The
embedding_chunk_sizeparameter controls the number of documents processed in parallel when creating embeddings.
- The
batch_sizeparameter controls the number of vectors included in each HTTP request when sending to Upstash Vector.
In the Upstash Vector free tier, there is a limit of 1000 vectors per batch.
Notes
- You can specify batch sizes and chunk sizes to control the efficiency of document processing and storage in Upstash Vector.
- Upstash Vector supports namespaces for organizing different types of documents. You can set a namespace while creating the
UpstashVectorStoreinstance.