# Zvec

> An in-process vector database from Alibaba that embeds directly into your app

- Category: Retrieval & Knowledge (RAG) / Vector Databases
- Language: Python
- Licence: Apache-2.0
- Repository: https://github.com/alibaba/zvec
- Canonical page: https://ai-tldr.dev/tools/zvec/

## In short

Zvec is an open-source vector database that runs inside your application process instead of as a separate server. You install it as a library, point it at a local path, and start storing and searching vectors right away. It sits in the Vector Databases category of the Retrieval & Knowledge (RAG) tools and is open-source, written in Python and licensed Apache-2.0.

## Overview

Zvec is an open-source vector database that runs inside your application process instead of as a separate server. You install it as a library, point it at a local path, and start storing and searching vectors right away. It was built and used within Alibaba Group before being released as open source.

It is aimed at developers who want similarity search without operating a standalone database. Because it runs wherever your code runs, it fits notebooks, backend services, CLI tools, and edge devices. SDKs are available for Python, Node.js, Go, Rust, and Dart/Flutter.

As an embedded / in-process vector store, Zvec handles dense and sparse vectors, scalar filters, and native full-text search, and can combine them in a single hybrid query. It uses write-ahead logging for durability and supports multiple concurrent readers, with writes limited to a single process.

## What it does

- In-process and local: no separate server, config, or network setup required
- Dense and sparse vector support, plus multiple index types that scale from memory to disk (including an on-disk DiskANN index)
- Native full-text search on string fields using natural-language or structured expressions
- Hybrid retrieval that fuses vector similarity, full-text search, and scalar filters in one MultiQuery
- Write-ahead logging (WAL) for durable storage that survives process crashes
- Concurrent reads across processes; official SDKs for Python, Node.js, Go, Rust, and Dart/Flutter

## Getting started

Install the Python SDK, then create a collection, insert documents, and run a vector query against a local path.

1. Install Zvec

   Install the Python package from PyPI. Python 3.10 to 3.14 is required. Node.js (npm install @zvec/zvec) and Flutter (flutter pub add zvec) packages are also available.

```bash
pip install zvec
```

2. Create a collection and search

   Define a schema, create and open a collection at a local path, insert a few documents, then query by vector similarity.

```python
import zvec

# Define collection schema
schema = zvec.CollectionSchema(
    name="example",
    vectors=zvec.VectorSchema("embedding", zvec.DataType.VECTOR_FP32, 4),
)

# Create collection
collection = zvec.create_and_open(path="./zvec_example", schema=schema)

# Insert documents
collection.insert([
    zvec.Doc(id="doc_1", vectors={"embedding": [0.1, 0.2, 0.3, 0.4]}),
    zvec.Doc(id="doc_2", vectors={"embedding": [0.2, 0.3, 0.4, 0.1]}),
])

# Search by vector similarity
results = collection.query(
    zvec.VectorQuery("embedding", vector=[0.4, 0.3, 0.3, 0.1]),
    topk=10
)

print(results)
```

## When to use it

- Adding similarity search to an app without running and maintaining a separate vector database server
- Building local or offline RAG and semantic search in notebooks, CLI tools, or edge devices
- Combining keyword full-text search, vector similarity, and scalar filters in a single hybrid query
- Storing large vector datasets on disk with the DiskANN index to keep memory usage low
