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.2.tar.gz (28.7 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.2-cp312-cp312-win_amd64.whl (350.4 kB view details)

Uploaded CPython 3.12Windows x86-64

vctrs-0.1.2-cp312-cp312-macosx_11_0_arm64.whl (437.7 kB view details)

Uploaded CPython 3.12macOS 11.0+ ARM64

vctrs-0.1.2-cp312-cp312-macosx_10_12_x86_64.whl (456.6 kB view details)

Uploaded CPython 3.12macOS 10.12+ x86-64

vctrs-0.1.2-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (473.3 kB view details)

Uploaded CPython 3.8manylinux: glibc 2.17+ x86-64

vctrs-0.1.2-cp38-cp38-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (460.1 kB view details)

Uploaded CPython 3.8manylinux: glibc 2.17+ ARM64

File details

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

File metadata

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

File hashes

Hashes for vctrs-0.1.2.tar.gz
Algorithm Hash digest
SHA256 13257bf827f50b9c9c37905ae91febfd90b79a67dff3e1613d6aa7e3c1fb09a9
MD5 702500ba3e59584ab015e24e97efbced
BLAKE2b-256 103a7b8f8f12656619a25f4a759bbf43ad7ccec0dff6a53768dacf2240bcc35f

See more details on using hashes here.

File details

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

File metadata

  • Download URL: vctrs-0.1.2-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.2-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 c9dda53114fd400dc418a7c64e418d22a2d48e0530d3cb17e2bda3e190e1c5f9
MD5 dd5359cad21ee4f78c371ed44bef6324
BLAKE2b-256 b69ed540066edad6090297e442deb0897631cbbcab1f443794e754f933da753a

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for vctrs-0.1.2-cp312-cp312-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 ed438c9716d2cbc21c026dbdcb82c698bd432eadda7d2e8b21b7498a5e44ebe9
MD5 44d15e2dbb3e3e7b9b8bf0584f5a2f3f
BLAKE2b-256 fa2c15e36804533685bab8396daf6e4000d11d05a2792967feb95d7ac7e333a2

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for vctrs-0.1.2-cp312-cp312-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 64b4df360d627842fe3465e564a45ffc330f467c4c0e7a9b5e890ae50b665e54
MD5 12379552591263231e4b8c94b75d4e75
BLAKE2b-256 c261b96ae8fce47467ec824ddd4593d3b5a6c4a5842814414a2826e18c2ce685

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for vctrs-0.1.2-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 ae42bbb17f3d66e81ff219d5c82933e5581bc7577f62ac1ecf516f8aac739e18
MD5 2b1258b4ae932c853d7c2ad909bd37eb
BLAKE2b-256 77b4d1e6383aa3f3ff7ea6936e915f5178c09c901f1ecce2e87a3c863a0a783d

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for vctrs-0.1.2-cp38-cp38-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 e383c28c2d5459cacdd2c171346440eb99e5e21ff3e412766d2054733613c773
MD5 2e9c6fbcbcc13b23b1a009d4dc6ef5cf
BLAKE2b-256 208a293bb25081594b22dfdfcfd47702ab06a49cf9f8610a6901c5a613fe02ed

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