# Weaviate

> Vector database with built-in ML models.

- Category: AI & Machine Learning
- Difficulty: intermediate
- Components: weaviate
- Tags: weaviate, vector-db, semantic-search, ml
- Source: https://docker.recipes/ai-ml/weaviate

## Overview

Weaviate is an open-source vector database that combines the power of traditional databases with modern machine learning capabilities. Developed by SeMI Technologies, Weaviate stores both objects and their vector representations, enabling semantic search and AI-powered applications. Unlike traditional databases that rely on exact matches, Weaviate understands the meaning and context of data through vector embeddings, making it possible to find similar concepts even when exact keywords don't match.

This Docker configuration deploys a standalone Weaviate instance with persistence enabled and anonymous access configured for development purposes. The setup exposes both REST and GraphQL APIs on port 8080, along with a high-performance gRPC interface on port 50051 for intensive operations. With the default vectorizer module set to 'none', you have complete control over how your data gets vectorized, whether through external services like OpenAI's API or self-hosted models.

This stack is ideal for developers building AI applications, researchers working with semantic search, and organizations looking to implement intelligent knowledge bases. The configuration balances simplicity with functionality, providing a solid Weaviate deployment that can handle everything from prototype development to production workloads. Data scientists and ML engineers will particularly appreciate Weaviate's ability to combine vector similarity search with traditional filtering and its support for multi-modal data types.

## Features

- Built-in ML modules including text2vec-openai, text2vec-huggingface, and img2vec for automatic vectorization
- Hybrid search capabilities combining vector similarity with traditional keyword-based filtering
- Hierarchical Navigable Small World (HNSW) indexing for fast approximate nearest neighbor search
- GraphQL API with automatic schema generation and complex query support
- Multi-tenancy support allowing data isolation within a single Weaviate instance
- Real-time CRUD operations with immediate vector index updates
- Support for multi-modal data including text, images, and custom object types
- Modular architecture with pluggable vectorizer and reader modules

## Use cases

- Semantic search engines that understand context and meaning rather than just keywords
- Recommendation systems for e-commerce, content platforms, or product catalogs
- Knowledge bases and FAQ systems with intelligent question-answer matching
- Document similarity detection and duplicate content identification
- Multi-modal search applications combining text and image data
- AI-powered chatbots and virtual assistants with contextual understanding
- Research and academic projects requiring semantic analysis of large text corpora

## Prerequisites

- Minimum 4GB RAM recommended for production use, 1GB sufficient for development
- Docker and Docker Compose installed with sufficient disk space for vector indices
- Port 8080 available for REST/GraphQL API access and port 50051 for gRPC
- Understanding of vector embeddings and semantic search concepts
- API keys for external vectorization services if using text2vec-openai or similar modules
- Basic knowledge of GraphQL or REST API interaction for data operations

## docker-compose.yml

```yaml
services:
  weaviate:
    image: semitechnologies/weaviate:latest
    container_name: weaviate
    restart: unless-stopped
    environment:
      QUERY_DEFAULTS_LIMIT: 25
      AUTHENTICATION_ANONYMOUS_ACCESS_ENABLED: "true"
      PERSISTENCE_DATA_PATH: /var/lib/weaviate
      DEFAULT_VECTORIZER_MODULE: none
      CLUSTER_HOSTNAME: node1
    volumes:
      - weaviate_data:/var/lib/weaviate
    ports:
      - "8080:8080"
      - "50051:50051"

volumes:
  weaviate_data:
```

## .env

```bash
# Enable modules as needed
```

## Usage notes

- Docs: https://weaviate.io/developers/weaviate
- REST API at http://localhost:8080/v1, GraphQL at /v1/graphql
- gRPC at localhost:50051 for high-performance operations
- Python client: pip install weaviate-client
- Built-in vectorizers: text2vec-openai, text2vec-huggingface, etc.
- Supports hybrid search (vector + keyword) and multi-tenancy

## Troubleshooting

- Out of memory errors during large imports: Increase Docker memory allocation and consider batch processing data uploads
- Slow query performance with large datasets: Check HNSW index parameters and consider increasing efConstruction and maxConnections
- Module loading failures: Verify vectorizer module configuration and ensure required API keys are properly set
- Connection refused on gRPC port: Ensure port 50051 is properly exposed and not blocked by firewall rules
- Schema creation errors: Validate property types and ensure vectorizer module compatibility with your data structure
- High memory usage during indexing: Monitor HNSW index size and consider using ef parameter tuning for memory optimization

