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.5.tar.gz (31.1 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.5-cp312-cp312-win_amd64.whl (380.7 kB view details)

Uploaded CPython 3.12Windows x86-64

vctrs-0.1.5-cp312-cp312-macosx_11_0_arm64.whl (465.2 kB view details)

Uploaded CPython 3.12macOS 11.0+ ARM64

vctrs-0.1.5-cp312-cp312-macosx_10_12_x86_64.whl (487.6 kB view details)

Uploaded CPython 3.12macOS 10.12+ x86-64

vctrs-0.1.5-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (504.4 kB view details)

Uploaded CPython 3.8manylinux: glibc 2.17+ x86-64

vctrs-0.1.5-cp38-cp38-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (488.3 kB view details)

Uploaded CPython 3.8manylinux: glibc 2.17+ ARM64

File details

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

File metadata

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

File hashes

Hashes for vctrs-0.1.5.tar.gz
Algorithm Hash digest
SHA256 bd15c44b7e8aa7d2eb731e7552c1781c63c49052350a4489271d8cf2ff171692
MD5 6c4583e4b9045d15f2ed898bdba82012
BLAKE2b-256 e676f6a16973384cdc899988254e0ee74597b64037647b522609d4d572c8543f

See more details on using hashes here.

File details

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

File metadata

  • Download URL: vctrs-0.1.5-cp312-cp312-win_amd64.whl
  • Upload date:
  • Size: 380.7 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.5-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 f75d9b14dd3b9be5c045ed4e99d524706fd89942472c186059b4c1542a51e0ac
MD5 eb2bb5310c1492ccf670ee07bd759150
BLAKE2b-256 54c52cf86d99bf52ca3d96952742e18e873ef2bb2aba96bb50fff2d26aa7bf9a

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for vctrs-0.1.5-cp312-cp312-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 06421ac6a7257dca5200a49d3c98b203ea0f68e0da37d3238d55d95cdc2218dd
MD5 7e3748a42adfaac81ca3be7c0e18e535
BLAKE2b-256 5320b396ecba5a507fc38e67505138edf3ef0f04e8dfc687308b476b45560788

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for vctrs-0.1.5-cp312-cp312-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 46dd8c05f256b0ef7a667d1c42b271652b02979437a9cd99a0d68e0848c3e697
MD5 c6f3e324f2d15ef24258a35b49378458
BLAKE2b-256 0c2795cf8f2d60bafbb929a637a3e697884311687821df3e50c92b38a3d409dd

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for vctrs-0.1.5-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 a0d122f682837184f1cc1c8dcdb6426a5a52865d54917fb35d04501661fafc7d
MD5 650b02ac4daaeedfe42ecb8ecab75326
BLAKE2b-256 ae4a20360c2f4aae2e239589bd7039e0df69d84bd398a08980c2f6c8130f280c

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for vctrs-0.1.5-cp38-cp38-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 1f09428cef53d2aa7d39de122d8254fb77fab46b153974f3424200dd7b215f06
MD5 30a0d2b80accce70172439abeef21e6f
BLAKE2b-256 5582bda211fafa5d9c4bc984e8825fe27e1f080c16b1c74638f38db1c8a9a06e

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