Skip to main content

A fast embedded vector database. Rust core, Python API. 4-10x faster than ChromaDB.

Project description

vctrs

A fast embedded vector database. Rust core, Python API.

Built for apps that need vector search without running a separate server — RAG pipelines, desktop apps, CLI tools, notebooks.

Install

pip install vctrs

Usage

import numpy as np
from vctrs import Database

# Create or open a database
db = Database("./mydb", dim=384, metric="cosine")

# Add vectors (accepts lists or numpy arrays)
db.add("doc1", np.random.rand(384).astype(np.float32), {"title": "hello"})

# Batch insert (much faster)
ids = [f"doc{i}" for i in range(10000)]
vectors = np.random.rand(10000, 384).astype(np.float32)
db.add_many(ids, vectors)

# Search
results = db.search(query_vector, k=10)
for id, distance, metadata in results:
    print(f"{id}: {distance:.4f}")

# Update
db.update("doc1", vector=new_vector, metadata={"title": "updated"})

# Delete
db.delete("doc1")

# Check membership
"doc1" in db
len(db)

# Persist to disk (graph structure saved — instant reload)
db.save()

Metrics

  • "cosine" (default) — cosine distance
  • "euclidean" / "l2" — squared L2 distance
  • "dot" / "dot_product" — negative dot product

Tuning search

# ef_search controls recall vs speed. Higher = better recall, slower.
results = db.search(query, k=10, ef_search=300)

Benchmarks

100,000 vectors, 384 dimensions, Apple M-series:

Speed

Operation vctrs ChromaDB numpy brute-force
Insert 100k 39s 70s
Search k=10 0.89ms 2.04ms 3.44ms
Search k=100 0.72ms 2.49ms
Load from disk 323ms
Get by id <0.01ms

3-4x faster than ChromaDB on search, 4x faster than numpy brute-force.

Recall (search quality)

Measured against brute-force ground truth at 10k vectors (higher is better):

k vctrs ChromaDB
1 92% 76%
10 91% 76%
50 85% 68%

vctrs is both faster and more accurate than ChromaDB out of the box.

How it works

  • HNSW index for O(log n) approximate nearest neighbor search
  • SimSIMD for hardware-accelerated distance computation (ARM NEON, x86 AVX2/512)
  • Rayon for parallel index construction
  • Graph serialization — saves the full HNSW structure so loading is instant (no rebuild)
  • PyO3 + maturin for zero-copy Python bindings with numpy support

Building from source

pip install maturin
git clone https://github.com/yang-29/vctrs.git
cd vctrs
python -m venv .venv && source .venv/bin/activate
pip install numpy maturin
maturin develop --release

License

MIT

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

vctrs-0.1.3.tar.gz (28.8 kB view details)

Uploaded Source

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

vctrs-0.1.3-cp312-cp312-win_amd64.whl (350.4 kB view details)

Uploaded CPython 3.12Windows x86-64

vctrs-0.1.3-cp312-cp312-macosx_11_0_arm64.whl (437.6 kB view details)

Uploaded CPython 3.12macOS 11.0+ ARM64

vctrs-0.1.3-cp312-cp312-macosx_10_12_x86_64.whl (456.5 kB view details)

Uploaded CPython 3.12macOS 10.12+ x86-64

vctrs-0.1.3-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (473.2 kB view details)

Uploaded CPython 3.8manylinux: glibc 2.17+ x86-64

vctrs-0.1.3-cp38-cp38-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (460.2 kB view details)

Uploaded CPython 3.8manylinux: glibc 2.17+ ARM64

File details

Details for the file vctrs-0.1.3.tar.gz.

File metadata

  • Download URL: vctrs-0.1.3.tar.gz
  • Upload date:
  • Size: 28.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: maturin/1.12.6

File hashes

Hashes for vctrs-0.1.3.tar.gz
Algorithm Hash digest
SHA256 7bdb00ea7d16cecbba1462aa97834e0c9d081a60c2f4b9a9377952bfd7f07004
MD5 bb947a6751013756fa2ad489d90899fd
BLAKE2b-256 93f3d526a7d8f1ffddbd634a399adc8e8845f6f3b5eed128f0ddde4bc949d2d4

See more details on using hashes here.

File details

Details for the file vctrs-0.1.3-cp312-cp312-win_amd64.whl.

File metadata

  • Download URL: vctrs-0.1.3-cp312-cp312-win_amd64.whl
  • Upload date:
  • Size: 350.4 kB
  • Tags: CPython 3.12, Windows x86-64
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: maturin/1.12.6

File hashes

Hashes for vctrs-0.1.3-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 b39386e7d4cb2887d725bd8c3b0c6c44208ba54afe00864014b9bb34ccf1a1b3
MD5 401cd4337a41c2f637e3c1031cf454f7
BLAKE2b-256 fe73600402e12de79a396e1903f37c40db39a93ba196ad2ae451343b8c87a579

See more details on using hashes here.

File details

Details for the file vctrs-0.1.3-cp312-cp312-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for vctrs-0.1.3-cp312-cp312-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 7067dabb125f1e01f21fb1c0234701b55b15ecd637120cd27234c5b3227de357
MD5 f4d09ac902789d7fdedfffb265d953dd
BLAKE2b-256 cf7dab9f12145abe60612db232f4cdeca343b067204ffbe633c6f6015c78d855

See more details on using hashes here.

File details

Details for the file vctrs-0.1.3-cp312-cp312-macosx_10_12_x86_64.whl.

File metadata

File hashes

Hashes for vctrs-0.1.3-cp312-cp312-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 b14ce5274a88bd855980d1fcc591875ad24655c02507c23abab8e186037169f2
MD5 91b7e76976195f8f643c5ebc2b28c8f9
BLAKE2b-256 abdeb1f28efa66a33d23e34b48d2e0cef18b31e1634b8058bcaa67e1b282d43a

See more details on using hashes here.

File details

Details for the file vctrs-0.1.3-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for vctrs-0.1.3-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 246efff786f95e0b70363f4026f3997f0369498035daf09a6eec45034599bcf3
MD5 188d8e85ced6b828bb2bfc635fcf7a8f
BLAKE2b-256 cc94da695881421ecb1f1355d2990d4752f7043e395ef08a7df6790c3d48b7b5

See more details on using hashes here.

File details

Details for the file vctrs-0.1.3-cp38-cp38-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.

File metadata

File hashes

Hashes for vctrs-0.1.3-cp38-cp38-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 4e4259991566da2d5f531347ac96794311c5cee43de66ff1ab451c369ed9f5fa
MD5 3df7e61d1842785d638351dd086ad5f4
BLAKE2b-256 5fc64e2418c9fcfcf715c27f349b4fb72578f9791588ed818692ea9fcdff2680

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page