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=200)

Benchmarks

10,000 vectors, 384 dimensions (typical embedding size):

Operation vctrs ChromaDB Speedup
Insert 10k 568ms 2,610ms 4.6x
Search k=10 0.12ms 1.16ms 9.8x
Search k=100 0.31ms 1.27ms 4.1x
Search k=500 0.67ms 4.28ms 6.4x
Load from disk 18ms instant
Get by id <0.01ms 0.12ms ~100x

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

# Rust + Python
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.1.tar.gz (27.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.1-cp312-cp312-win_amd64.whl (344.4 kB view details)

Uploaded CPython 3.12Windows x86-64

vctrs-0.1.1-cp312-cp312-macosx_11_0_arm64.whl (428.0 kB view details)

Uploaded CPython 3.12macOS 11.0+ ARM64

vctrs-0.1.1-cp312-cp312-macosx_10_12_x86_64.whl (447.7 kB view details)

Uploaded CPython 3.12macOS 10.12+ x86-64

vctrs-0.1.1-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (462.8 kB view details)

Uploaded CPython 3.8manylinux: glibc 2.17+ x86-64

vctrs-0.1.1-cp38-cp38-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (451.2 kB view details)

Uploaded CPython 3.8manylinux: glibc 2.17+ ARM64

File details

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

File metadata

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

File hashes

Hashes for vctrs-0.1.1.tar.gz
Algorithm Hash digest
SHA256 17c3351805ad4effcdf07ac54bfb2f7028b9ac0f94664a22ced336ab08eac993
MD5 0e2167fa4d6525062f760e8066ad0060
BLAKE2b-256 e83098f503758b8c4ec48c7f79fe82ba10006d08a843f510a3a93bbc3eb685af

See more details on using hashes here.

File details

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

File metadata

  • Download URL: vctrs-0.1.1-cp312-cp312-win_amd64.whl
  • Upload date:
  • Size: 344.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.1-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 0831ed1e80337984a46632a3ace7379c191ef5abd1f12358971fd30d3415c82a
MD5 e57fbb89c905ebf2cb3b2837106d85cc
BLAKE2b-256 de6465a9022e255b4f905b6fe28aa43cedcc0c416d41003258478ee049629f7a

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for vctrs-0.1.1-cp312-cp312-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 bdf07714d142663e51a73cc30857e22166d70f8487d96260c89be7bcac2e6331
MD5 9bdc5f29722116ea2e613fa1f1c7ab25
BLAKE2b-256 626e8ae1e54a718f692fe1fd4cd44951ac79f9ec37f2f0d93ed47d04c719987e

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for vctrs-0.1.1-cp312-cp312-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 c75cfae4a1c8c7f4682dcbe53e9052c85f5d5044efb1bdbaff3483c496a3e334
MD5 ce0313bc292f2bb6918900896ae64939
BLAKE2b-256 4bd6d5a2431d75eed1e8d14820091a845244aa79e854c61f43784c33342bd67a

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for vctrs-0.1.1-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 6107f3bec25bbe0b9abf177c189e74d6e1dc4dda7192b1683e76f98cba33a2e9
MD5 ae428378b02cad5302bdc9e50446fbbe
BLAKE2b-256 bde465d6fe111b7722b9f0abc557ded99e79a349f43b8ee5a07acf65dbc601a9

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for vctrs-0.1.1-cp38-cp38-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 3b6031bcd59a0c198bca6424dc592b001e0080ec1c95fea106c3c06140d6a1b6
MD5 b2580c7738c1e82461ec796c7bd13012
BLAKE2b-256 0d2e4fc63fea03fceee5e42fe6b6ad361fc560c3859d4182ec191f7a0399a423

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