Zvec - A lightweight embedded vector database open-sourced by Alibaba.
Zvec is a lightweight, embedded vector database open-sourced by Alibaba, built on its internal Proxima engine. Unlike traditional standalone deployment solutions, Zvec runs directly within the application process, requiring no additional servers or configuration; installation is straightforward...
What is Zvec?
Zvec is an open-source project by Alibaba.Lightweight embedded vector databaseBuilt on the internal Proxima engine, Zvec differs from traditional standalone deployment solutions in that it runs directly within the application process, requiring no additional servers or configurations—it's ready to use immediately after installation. Zvec supports millisecond-level search of billions of vectors, mixed queries of dense and sparse vectors, and provides a concise Python API. Zvec is suitable for AI scenarios such as RAG and image/code search.
Zvec's main functions
-
In-process architectureIt runs directly in the application process as an embedded library, without the need to deploy a separate server or manage external infrastructure.
-
High-performance vector retrievalBased on Alibaba's Proxima engine, it can complete similarity searches on billions of vectors in milliseconds.
-
Multi-type vector supportIt supports both dense and sparse vectors, and allows mixed search to be performed in a single query.
-
Filtering and grouping queriesIt supports combining semantic search with attribute filtering conditions, as well as grouping and aggregating search results by specified dimensions.
-
Minimalist development experienceIt provides an intuitive Python API, and can be configured and used within 60 seconds after installation via pip.
-
Wide deployment capabilityIt can run in various environments such as laptops, servers, CLI tools and edge devices, and is suitable for AI application scenarios such as RAG, image search and code retrieval.
How to use Zvec
- Install
pip install zvec # Python 3.10-3.12 环境下执行 pip 命令安装 zvec 库。
- Define data structure
import zvec
schema = zvec.CollectionSchema(name="my_db", vectors=zvec.VectorSchema("vec", zvec.DataType.VECTOR_FP32,
128))
# 创建名为 my_db 的集合结构,定义 128 维 32 位浮点向量字段 vec。
- Create/Open Database
collection = zvec.create_and_open(path="./data", schema=schema)
# 在本地 ./data 目录创建并打开数据库,若已存在则直接打开。
- Insert vector data
collection.insert(zvec.Doc(id="1", vectors={"vec":
[0.1,
0.2,
...]}))
# 将包含 ID 为 "1" 的 128 维向量数据插入到集合中。
- Perform a similarity search
results = collection.query(zvec.VectorQuery("vec", vector=[0.1,
0.2,
...]), topk=10)
# 用查询向量在集合中搜索最相似的 10 条结果并返回。
Zvec's project address
- Project official websitehttps://zvec.org/
- GitHub repositoryhttps://github.com/alibaba/zvec
Application scenarios of Zvec
- RAG Knowledge Base Q&ADocument slices are generated into vectors and stored in Zvec. When a user asks a question, relevant fragments are retrieved and injected into the context of a large model to achieve accurate knowledge augmentation generation.
- E-commerce product searchThe system converts product images and descriptions into multimodal vectors, allowing users to quickly return visually or semantically similar products when they upload reference images or enter keywords.
- Intelligent code searchEncode code snippets and comments into vectors, allowing developers to describe requirements in natural language and locate similar code implementations.
- Recommendation system recallVectorize user behavior and item features, and retrieve similar users or items in real time as a candidate set to support the first round of recall for personalized recommendations.
- Bioinformatics AnalysisEncode protein sequence or gene expression data into vectors and quickly discover functionally similar biomolecules or disease targets through similarity search.