# Weaviate

> Open-source vector database with built-in hybrid search and RAG

- Category: Retrieval & Knowledge (RAG) / Vector Databases
- Language: Go
- Repository: https://github.com/weaviate/weaviate
- Website: https://weaviate.io
- Canonical page: https://ai-tldr.dev/tools/weaviate/

## In short

Weaviate is an open-source, cloud-native vector database that stores both your objects and their vector embeddings. It lets you run semantic search over large collections, and combines vector similarity with keyword (BM25) filtering, retrieval-augmented generation (RAG), and reranking in a single query interface. It sits in the Vector Databases category of the Retrieval & Knowledge (RAG) tools and is open-source, written in Go.

## Overview

Weaviate is an open-source, cloud-native vector database that stores both your objects and their vector embeddings. It lets you run semantic search over large collections, and combines vector similarity with keyword (BM25) filtering, retrieval-augmented generation (RAG), and reranking in a single query interface.

It is aimed at developers building search and AI features such as RAG systems, semantic and image search, recommendation engines, chatbots, and content classification. You can have Weaviate generate embeddings at import time using integrated model providers like OpenAI, Cohere, and HuggingFace, or import your own pre-computed vectors.

As a vector database, it sits between your application and your model provider: it indexes embeddings for fast retrieval and adds production features such as multi-tenancy, replication, and RBAC authorization. Client libraries are available for Python, JavaScript/TypeScript, Java, Go, and C#/.NET, plus REST, gRPC, and GraphQL APIs.

## What it does

- Stores objects and their vectors together for semantic search at scale, with the core engine written in Go
- Automatic vectorization at import using integrated model providers (OpenAI, Cohere, HuggingFace, Google, and others), or bring your own pre-computed embeddings
- Hybrid search that combines vector similarity with keyword (BM25) search, image search, and filtering in one API call
- Built-in generative search (RAG) and reranking for Q&A systems, chatbots, and summarizers
- Production features including multi-tenancy, replication, and RBAC authorization
- Client libraries for Python, JavaScript/TypeScript, Java, Go, and C#/.NET, plus REST, gRPC, and GraphQL APIs

## Getting started

You can run Weaviate locally with Docker alongside a lightweight embedding model, then connect with the Python client to insert data and run a semantic search.

1. Start Weaviate with Docker Compose

   Create a docker-compose.yml that runs Weaviate plus a local embedding model that vectorizes objects during import.

```yaml
services:
  weaviate:
    image: cr.weaviate.io/semitechnologies/weaviate:1.36.0
    ports:
      - "8080:8080"
      - "50051:50051"
    environment:
      ENABLE_MODULES: text2vec-model2vec
      MODEL2VEC_INFERENCE_API: http://text2vec-model2vec:8080

  # A lightweight embedding model that will generate vectors from objects during import
  text2vec-model2vec:
    image: cr.weaviate.io/semitechnologies/model2vec-inference:minishlab-potion-base-32M
```

2. Bring up the services

   Start Weaviate and the embedding service in the background.

```bash
docker compose up -d
```

3. Install the Python client

   Install the official Python client (other client libraries are also available).

```bash
pip install -U weaviate-client
```

4. Create a collection and run a search

   Connect to your local instance, create a collection with a vectorizer, insert objects, and run a semantic (near-text) query.

```python
import weaviate
from weaviate.classes.config import Configure, DataType, Property

# Connect to Weaviate
client = weaviate.connect_to_local()

# Create a collection
client.collections.create(
    name="Article",
    properties=[Property(name="content", data_type=DataType.TEXT)],
    vector_config=Configure.Vectors.text2vec_model2vec(),  # Use a vectorizer to generate embeddings during import
    # vector_config=Configure.Vectors.self_provided()  # If you want to import your own pre-generated embeddings
)

# Insert objects and generate embeddings
articles = client.collections.get("Article")
articles.data.insert_many(
    [
        {"content": "Vector databases enable semantic search"},
        {"content": "Machine learning models generate embeddings"},
        {"content": "Weaviate supports hybrid search capabilities"},
    ]
)

# Perform semantic search
results = articles.query.near_text(query="Search objects by meaning", limit=1)
print(results.objects[0])

client.close()
```

## When to use it

- Power a retrieval-augmented generation (RAG) pipeline that feeds relevant documents to an LLM-based chatbot or Q&A system
- Add semantic or image search to an app so results match meaning rather than exact keywords
- Build a recommendation engine over product, article, or media embeddings
- Combine vector similarity with keyword (BM25) filtering for hybrid search across structured and unstructured data
