Quick Start: Spin Up Weaviate in 5 Minutes
Spinning up a vector database locally doesn’t need to eat up your afternoon. With Docker Compose, you can stand up a full Weaviate instance paired with an inference container for vectorization in under five minutes.
Create a dedicated folder for your project and add a docker-compose.yml file:
version: '3.4'
services:
weaviate:
image: semitechnologies/weaviate:1.24.10
ports:
- "8080:8080"
- "50051:50051"
restart: on-failure:0
environment:
QUERY_DEFAULTS_LIMIT: 25
AUTHENTICATION_ANONYMOUS_ACCESS_ENABLED: 'true'
PERSISTENCE_DATA_PATH: '/var/lib/weaviate'
DEFAULT_VECTORIZER_MODULE: 'multi2vec-clip'
ENABLE_MODULES: 'multi2vec-clip'
CLIP_INFERENCE_API: 'http://multi2vec-clip:8080'
CLUSTER_HOSTNAME: 'node1'
volumes:
- weaviate_data:/var/lib/weaviate
multi2vec-clip:
image: semitechnologies/multi2vec-clip:sentence-transformers-clip-ViT-B-32-multilingual-v1
environment:
ENABLE_CUDA: '0'
volumes:
weaviate_data:
Notice the port mappings. Port 8080 exposes the REST API, while 50051 handles gRPC traffic for high-throughput batch operations.
This stack links the core Weaviate search engine to the multi2vec-clip inference container. The CLIP model maps both raw strings and image binaries into a shared 512-dimensional vector space. That means you get cross-modal retrieval straight out of the box without building custom embedding pipelines.
Bring up the stack in detached mode:
docker compose up -d
Give it roughly 15 to 30 seconds to download the ViT-B-32 weights. Then verify the engine is ready:
curl http://localhost:8080/v1/.well-known/ready
A simple true response confirms your local cluster is up and ready for schema creation.
Deep Dive: Architecture, Collections, and Ingestion
Relational databases locate records with B-tree indices and exact SQL filters. Weaviate takes a different route. It stores unstructured records alongside dense mathematical vectors, navigating them with the Hierarchical Navigable Small World (HNSW) algorithm. Queries complete in sub-50ms logarithmic time, even across millions of records.
Grab the official Python v4 client in a fresh virtualenv:
pip install -U weaviate-client
Defining the Multimodal Collection
Weaviate v4 adopts native type safety and explicit collection definitions. Here, we tell the engine to vectorize both an image blob and our text fields into a unified vector coordinate:
import weaviate
from weaviate.classes.config import Configure, Property, DataType
client = weaviate.connect_to_local()
try:
# Define the multimodal collection
client.collections.create(
name="ProductCatalog",
vectorizer_config=Configure.Vectorizer.multi2vec_clip(
image_fields=["image"],
text_fields=["title", "description"]
),
properties=[
Property(name="title", data_type=DataType.TEXT),
Property(name="description", data_type=DataType.TEXT),
Property(name="image", data_type=DataType.BLOB),
]
)
print("Collection 'ProductCatalog' created successfully.")
finally:
client.close()
Batch Ingestion
Never write loops that post records one by one. Bulk indexing requires batching to avoid network bottlenecking and keep vectorization queues saturated.
Convert each image to base64 and stream your items into the dynamic batch worker:
import base64
import weaviate
def file_to_base64(filepath: str) -> str:
with open(filepath, "rb") as f:
return base64.b64encode(f.read()).decode("utf-8")
client = weaviate.connect_to_local()
try:
catalog = client.collections.get("ProductCatalog")
sample_items = [
{
"title": "Mechanical Gaming Keyboard",
"description": "Compact 75% hot-swappable layout with tactile switches and per-key RGB backlighting.",
"image": file_to_base64("sample_keyboard.jpg")
}
]
with catalog.batch.dynamic() as batch:
for item in sample_items:
batch.add_object(properties=item)
print("Batch indexing completed.")
finally:
client.close()
Advanced Usage: Running Cross-Modal and Hybrid Queries
Here is where CLIP shines. Because your text and pictures share the same vector coordinate system, you can use text to search images or use images to search catalog metadata.
Scenario 1: Find an Image by Typing Natural Language
Picture a scenario where a shopper forgets product names and types vague descriptive phrases instead. Weaviate projects the query string into the CLIP vector space and locates nearest neighbors instantly:
import weaviate
client = weaviate.connect_to_local()
try:
catalog = client.collections.get("ProductCatalog")
response = catalog.query.near_text(
query="ergonomic desktop peripheral for fast typing",
limit=2,
return_properties=["title", "description"]
)
for obj in response.objects:
print(f"Match: {obj.properties['title']}")
print(f"Description: {obj.properties['description']}\n")
finally:
client.close()
Scenario 2: Find Objects Using an Image as the Query Vector
What if your users want visual reverse-search? Send a phone snapshot encoded as base64 to near_image():
import base64
import weaviate
client = weaviate.connect_to_local()
try:
with open("query_photo.jpg", "rb") as img_file:
b64_query = base64.b64encode(img_file.read()).decode("utf-8")
catalog = client.collections.get("ProductCatalog")
results = catalog.query.near_image(
near_image=b64_query,
limit=3,
return_properties=["title"]
)
for match in results.objects:
print(f"Visually similar product: {match.properties['title']}")
finally:
client.close()
Practical Tips: Performance, Memory, and Workflow Secrets
Running local vector workloads can stress CPU and RAM quickly. Keep these production safeguards in mind:
1. Mind the CLIP Container Footprint
The CLIP container packs a 600MB PyTorch model. On a standard CPU without AVX-512 or CUDA acceleration, encoding a single image takes 150 to 300ms. Batching 50+ images simultaneously will spike CPU utilization to 100% and can cause Docker memory limits (OOM) to trip. Keep batch chunks between 10 and 20 records on local dev environments.
2. Sanitizing Real-World Import Data
Product exports and analytics dumps almost always arrive as dirty CSV files. When you need to parse large dumps into clean JSON payloads without third-party leaks, use toolcraft.app/en/tools/data/csv-to-json. It processes parsing tasks client-side in the browser, keeping catalog pricing and customer records safely on your machine.
3. Keep Volumes Persistent
The volume mapping weaviate_data:/var/lib/weaviate in your compose file guards your data. Running docker compose down stops the containers, but keeps the underlying HNSW graph cache safe. When you run docker compose up -d again, your 50,000 vectors load back up in under 2 seconds without full re-indexing.
4. Tune HNSW Parameters for Scale
Small toy collections under 50,000 records run great on default parameters. As you push toward 500,000+ items, tune the collection’s vector_index_config. Raising efConstruction from 128 to 256 yields higher recall at the expense of slower indexing. Lowering max_connections from 64 to 32 cuts memory overhead by roughly 30% without visible hits to search quality.

