Create a local Docker instance
Generating multimodal vectors is currently only possible with local models, and as a result this course uses a local, Docker instance of Weaviate. If you are generating vectors outside of Weaviate, you can use a cloud instance. See the Work with: your own vectors course for more information.
Here, you will create a Weaviate instance and a multi-modal vectorizer container using Docker.
Download and run the docker-compose file
Install Docker on your machine. We recommend following the official Docker installation guide.
Create a new directory and navigate to it in your terminal. Then, create a new file called docker-compose.yml
and add the following content:
---
services:
weaviate:
command:
- --host
- 0.0.0.0
- --port
- '8080'
- --scheme
- http
image: cr.weaviate.io/semitechnologies/weaviate:1.27.5
ports:
- 8080:8080
- 50051:50051
volumes:
- weaviate_data:/var/lib/weaviate
restart: on-failure:0
environment:
CLIP_INFERENCE_API: 'http://multi2vec-clip:8080'
OPENAI_APIKEY: $OPENAI_APIKEY
QUERY_DEFAULTS_LIMIT: 25
AUTHENTICATION_ANONYMOUS_ACCESS_ENABLED: 'true'
PERSISTENCE_DATA_PATH: '/var/lib/weaviate'
DEFAULT_VECTORIZER_MODULE: 'multi2vec-clip'
ENABLE_MODULES: 'multi2vec-clip,generative-openai,generative-cohere'
CLUSTER_HOSTNAME: 'node1'
multi2vec-clip:
image: cr.weaviate.io/semitechnologies/multi2vec-clip:sentence-transformers-clip-ViT-B-32-multilingual-v1
environment:
ENABLE_CUDA: '0'
volumes:
weaviate_data:
...
Create a Weaviate instance
Run the following command to start Weaviate:
docker compose up
Your Weaviate instance details
Once the instance is created, you can access it at http://localhost:8080
.
Connect to your Weaviate instance
To connect to the Weaviate instance, use the connect_to_local
function.
import weaviate
client = weaviate.connect_to_local()
Provide inference API keys
Some Weaviate modules can use inference APIs for vectorizing data or large language model integration. You can provide the API keys for these services to Weaviate at instantiation.
This course uses OpenAI (for retrieval augmented generation), so you can provide the OpenAI API key to Weaviate through headers={"X-OpenAI-Api-Key": <YOUR_KEY>}
as shown below:
import weaviate
import os
headers = {
"X-OpenAI-Api-Key": os.getenv("OPENAI_APIKEY")
} # Replace with your OpenAI API key
client = weaviate.connect_to_local(headers=headers)
Questions and feedback
If you have any questions or feedback, let us know in the user forum.