Course contentsShow
← AI Engineering
Lesson 308 of 1,8868. Vector Databases - ToolsFree lesson

Weaviate: Architecture and Setup

Understanding Weaviate's schema-based approach, installing with Docker, and defining your first class with vectorizer.

Weaviate: Architecture and Setup

You'll learn how Weaviate organizes data with schemas, how to get it running with Docker, and how to create your first class with automatic vectorization.

Why Weaviate Uses Schemas

Unlike Chroma's flexible approach, Weaviate requires you to define a schema upfront—think of it as a blueprint for your data. Just like a traditional database table has columns with types, Weaviate uses classes (like "Article" or "Product") with properties (like "title" or "price"). The key difference? Each class automatically gets vector embeddings through a vectorizer you specify.

This schema-first approach trades some initial setup for better organization, type safety, and clearer data management—especially valuable in production environments.

Installing Weaviate with Docker

The quickest way to run Weaviate locally is Docker:

docker run -d \
  -p 8080:8080 \
  -e TRANSFORMERS_INFERENCE_API=http://t2v-transformers:8080 \
  weaviate/weaviate:latest

This spins up Weaviate on localhost:8080. You'll typically add a vectorizer module (like text2vec-transformers) as a separate container.

Defining Your First Class

Once running, you connect and define a class:

import weaviate

client = weaviate.Client("http://localhost:8080")

class_obj = {
    "class": "Article",
    "vectorizer": "text2vec-transformers",
    "properties": [
        {"name": "title", "dataType": ["text"]},
        {"name": "content", "dataType": ["text"]}
    ]
}

client.schema.create_class(class_obj)

Now when you insert articles, Weaviate automatically generates embeddings from the text fields using the specified vectorizer.

Key Takeaway: Weaviate's schema-based architecture requires defining classes with properties and vectorizers upfront, offering structured data management that scales well in production environments.