Skip to main content

Fast compressed ANN search via randomized Hadamard transform and optimal Gaussian scalar quantization. NumPy + Cython compiled kernels.

Project description

snapvec

PyPI version Python versions CI Docs License: MIT Downloads

Fast compressed approximate nearest-neighbor search. NumPy + Cython compiled kernels.

Four index types for embedding vector search, each targeting a different point on the accuracy / storage / latency frontier:

Index Training Compression Recall Use when
SnapIndex none 6-12x 0.92+ Any distribution, no corpus sample
ResidualSnapIndex none 4-8x 0.96 Higher recall, still training-free
PQSnapIndex one-off fit 24-96x 0.95 Modern LLM embeddings, aggressive compression
IVFPQSnapIndex one-off fit 24-96x 0.98 Sub-linear search at scale (N > 100k)

Headline number: recall@10 = 0.977 at 441 us/query on BEIR FIQA (N = 57,638, BGE-small), 25-125x faster than sqlite-vec at comparable recall.

Install

pip install snapvec

On macOS you also need brew install libomp to build from source; the wheels on PyPI bundle it.

Quickstart

import numpy as np
from snapvec import SnapIndex

rng = np.random.default_rng(0)
corpus = rng.standard_normal((10_000, 384)).astype(np.float32)

idx = SnapIndex(dim=384, bits=4, seed=0)
idx.add_batch(list(range(10_000)), corpus)

query = rng.standard_normal(384).astype(np.float32)
for doc_id, score in idx.search(query, k=10):
    print(doc_id, score)

idx.save("my.snpv")

Runnable end-to-end scripts for every index live in examples/.

Documentation

Full docs: https://stffns.github.io/snapvec/

Context

snapvec was developed as the quantization layer for vstash, a local-first hybrid retrieval system, to extend it to corpora beyond the float32 memory budget while preserving its dependency-minimal design. It stands alone as a quantization library, but the design constraints (NumPy-only base install, predictable latency, reproducible index files) come from vstash's local-first requirements.

Roadmap

See ROADMAP.md for planned work and explicit non-goals.

Contributing

See CONTRIBUTING.md for dev setup, the test matrix, and the release process. Bugs and feature requests go to issues; questions and usage help to discussions.

License

MIT (c) 2025 Jayson Steffens.

The TurboQuant algorithm is described in arXiv:2504.19874 by Zandieh et al. (Google Research / ICLR 2026). This package is an independent implementation.

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

snapvec-0.10.2.tar.gz (241.1 kB view details)

Uploaded Source

Built Distributions

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

snapvec-0.10.2-cp313-cp313-win_amd64.whl (277.6 kB view details)

Uploaded CPython 3.13Windows x86-64

snapvec-0.10.2-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (718.2 kB view details)

Uploaded CPython 3.13manylinux: glibc 2.17+ x86-64

snapvec-0.10.2-cp313-cp313-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (715.2 kB view details)

Uploaded CPython 3.13manylinux: glibc 2.17+ ARM64

snapvec-0.10.2-cp313-cp313-macosx_14_0_arm64.whl (522.9 kB view details)

Uploaded CPython 3.13macOS 14.0+ ARM64

snapvec-0.10.2-cp312-cp312-win_amd64.whl (277.8 kB view details)

Uploaded CPython 3.12Windows x86-64

snapvec-0.10.2-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (727.0 kB view details)

Uploaded CPython 3.12manylinux: glibc 2.17+ x86-64

snapvec-0.10.2-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (722.7 kB view details)

Uploaded CPython 3.12manylinux: glibc 2.17+ ARM64

snapvec-0.10.2-cp312-cp312-macosx_14_0_arm64.whl (523.7 kB view details)

Uploaded CPython 3.12macOS 14.0+ ARM64

snapvec-0.10.2-cp311-cp311-win_amd64.whl (276.5 kB view details)

Uploaded CPython 3.11Windows x86-64

snapvec-0.10.2-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (730.2 kB view details)

Uploaded CPython 3.11manylinux: glibc 2.17+ x86-64

snapvec-0.10.2-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (727.3 kB view details)

Uploaded CPython 3.11manylinux: glibc 2.17+ ARM64

snapvec-0.10.2-cp311-cp311-macosx_14_0_arm64.whl (523.9 kB view details)

Uploaded CPython 3.11macOS 14.0+ ARM64

snapvec-0.10.2-cp310-cp310-win_amd64.whl (276.7 kB view details)

Uploaded CPython 3.10Windows x86-64

snapvec-0.10.2-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (702.5 kB view details)

Uploaded CPython 3.10manylinux: glibc 2.17+ x86-64

snapvec-0.10.2-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (702.0 kB view details)

Uploaded CPython 3.10manylinux: glibc 2.17+ ARM64

snapvec-0.10.2-cp310-cp310-macosx_14_0_arm64.whl (524.2 kB view details)

Uploaded CPython 3.10macOS 14.0+ ARM64

File details

Details for the file snapvec-0.10.2.tar.gz.

File metadata

  • Download URL: snapvec-0.10.2.tar.gz
  • Upload date:
  • Size: 241.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for snapvec-0.10.2.tar.gz
Algorithm Hash digest
SHA256 fcac0daf65abe2decdac534f2c3309757caa753dad7c3d4a410bf024930574dc
MD5 bd90db1f08dd26706639115f6842a01c
BLAKE2b-256 a46ddc87acb9120ad0c4364385481493b29338f5a832190bf39a8e27d2ad5432

See more details on using hashes here.

Provenance

The following attestation bundles were made for snapvec-0.10.2.tar.gz:

Publisher: release.yml on stffns/snapvec

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file snapvec-0.10.2-cp313-cp313-win_amd64.whl.

File metadata

  • Download URL: snapvec-0.10.2-cp313-cp313-win_amd64.whl
  • Upload date:
  • Size: 277.6 kB
  • Tags: CPython 3.13, Windows x86-64
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for snapvec-0.10.2-cp313-cp313-win_amd64.whl
Algorithm Hash digest
SHA256 305bbb0fb38cb1b28c63527c64bad554875329bc6c885818518d95a059c4097e
MD5 9d3db7f7ab977350a5119eec4b724297
BLAKE2b-256 0e6c0ff50bd383f9f146fefb15dc55c535b699530368e3b1672838cbfb8087f7

See more details on using hashes here.

Provenance

The following attestation bundles were made for snapvec-0.10.2-cp313-cp313-win_amd64.whl:

Publisher: release.yml on stffns/snapvec

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file snapvec-0.10.2-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for snapvec-0.10.2-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 707e5901e9b97869d6ef83fdc9cff862b71bde57cc408d927c2fa6d81398db0e
MD5 0cda0f0a5964618e3cbd2783c2eab676
BLAKE2b-256 7f2c5bb7307429cf2cb79b031405ce810d34b9714aea98e01061d3917ea9340a

See more details on using hashes here.

Provenance

The following attestation bundles were made for snapvec-0.10.2-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl:

Publisher: release.yml on stffns/snapvec

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file snapvec-0.10.2-cp313-cp313-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.

File metadata

File hashes

Hashes for snapvec-0.10.2-cp313-cp313-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 0d8dac4db9158cc4b43e89a137992a7417efad316ab1f7756b0218296c368de7
MD5 4f15fe15187f2def680542d9eab685d1
BLAKE2b-256 907df3b34eac637a23d3034ae54a74f82e5768918108ae5d2ff112c77370a883

See more details on using hashes here.

Provenance

The following attestation bundles were made for snapvec-0.10.2-cp313-cp313-manylinux_2_17_aarch64.manylinux2014_aarch64.whl:

Publisher: release.yml on stffns/snapvec

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file snapvec-0.10.2-cp313-cp313-macosx_14_0_arm64.whl.

File metadata

File hashes

Hashes for snapvec-0.10.2-cp313-cp313-macosx_14_0_arm64.whl
Algorithm Hash digest
SHA256 24708967cb86c095077dae4f1973588806c0a3935f35da22291234de9d89886c
MD5 174600724eaf42407d327b9773007cef
BLAKE2b-256 7e28f0a310413c2b9ce2c2ee45a68b82d8190d886170cfb5c3079c2c32acd717

See more details on using hashes here.

Provenance

The following attestation bundles were made for snapvec-0.10.2-cp313-cp313-macosx_14_0_arm64.whl:

Publisher: release.yml on stffns/snapvec

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file snapvec-0.10.2-cp312-cp312-win_amd64.whl.

File metadata

  • Download URL: snapvec-0.10.2-cp312-cp312-win_amd64.whl
  • Upload date:
  • Size: 277.8 kB
  • Tags: CPython 3.12, Windows x86-64
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for snapvec-0.10.2-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 b83be1c17d34ccc35175e921a5a052c2ec90b8988e2eaddc77be2bddcfc83a73
MD5 e36b423d0f2ad304a8814b70aea9df0a
BLAKE2b-256 12d0157b9923b8f7c109d60a8677ccec72e3dc3b8c40e8dd046717839c1034d2

See more details on using hashes here.

Provenance

The following attestation bundles were made for snapvec-0.10.2-cp312-cp312-win_amd64.whl:

Publisher: release.yml on stffns/snapvec

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file snapvec-0.10.2-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for snapvec-0.10.2-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 a1051a3e8a0b735ac6459ba2e9106ad1710fec4947a4a550c7a8a0713ff0629b
MD5 cd770b365d5c6f75da6e619d5f67688b
BLAKE2b-256 9e3dfab0ee3301d0f409abae34bc645ac20d6975f505f4d753c491d40ea26d2c

See more details on using hashes here.

Provenance

The following attestation bundles were made for snapvec-0.10.2-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl:

Publisher: release.yml on stffns/snapvec

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file snapvec-0.10.2-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.

File metadata

File hashes

Hashes for snapvec-0.10.2-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 e4d4e3b16592ca8c017ad9d8e56bd38f7deaaeb6acd040093294c5be5870a11a
MD5 5cd016fe29eb27748c51a20297be3019
BLAKE2b-256 36bac8083b5386995b84aca57dc11d675760344a850c3ce72f43c315e4855700

See more details on using hashes here.

Provenance

The following attestation bundles were made for snapvec-0.10.2-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl:

Publisher: release.yml on stffns/snapvec

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file snapvec-0.10.2-cp312-cp312-macosx_14_0_arm64.whl.

File metadata

File hashes

Hashes for snapvec-0.10.2-cp312-cp312-macosx_14_0_arm64.whl
Algorithm Hash digest
SHA256 7ba3ab869a602a74bc0ee3a15f00fa5a1bfcb7c1c763d3e70ec35973579afe8d
MD5 560d0e7d0e800b6e080094564732ac54
BLAKE2b-256 38a7fc2e310b2f6678c441a98e5754c1a811becffa79ef978ac20ae9dd99e4ea

See more details on using hashes here.

Provenance

The following attestation bundles were made for snapvec-0.10.2-cp312-cp312-macosx_14_0_arm64.whl:

Publisher: release.yml on stffns/snapvec

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file snapvec-0.10.2-cp311-cp311-win_amd64.whl.

File metadata

  • Download URL: snapvec-0.10.2-cp311-cp311-win_amd64.whl
  • Upload date:
  • Size: 276.5 kB
  • Tags: CPython 3.11, Windows x86-64
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for snapvec-0.10.2-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 23bf867d3f4efc47dc19b083fce6d2f681e7fbbbc2966a1589fa2b70ed311326
MD5 f35a25f9f3decd593ae6d0554ec9e14b
BLAKE2b-256 df1fdc2c8c0e4b98b0de2b97f677bb761c7abeab5bd4970afff49dcd127022f6

See more details on using hashes here.

Provenance

The following attestation bundles were made for snapvec-0.10.2-cp311-cp311-win_amd64.whl:

Publisher: release.yml on stffns/snapvec

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file snapvec-0.10.2-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for snapvec-0.10.2-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 e482bedbfb582e7c08f72413a24e64f67a4add8e39185b1c30b0ca1d26eebf48
MD5 d7f57b5a1bdc72f556656cd8c2f50c68
BLAKE2b-256 ba2b5b1cfd3ecc4e521a94f4b6442f3f1cf75f6e8d82dab22b09c8afd3e25374

See more details on using hashes here.

Provenance

The following attestation bundles were made for snapvec-0.10.2-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl:

Publisher: release.yml on stffns/snapvec

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file snapvec-0.10.2-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.

File metadata

File hashes

Hashes for snapvec-0.10.2-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 59e5caa666a29a3c17ad0477aaca40d7ad41226b1371013943a2883b43dd793d
MD5 2edf039dc698f1c39016da20eccede2e
BLAKE2b-256 0f163b6869ce3962e33f86923f7ee823976811ec93ae9294d76c1852eb8aacc3

See more details on using hashes here.

Provenance

The following attestation bundles were made for snapvec-0.10.2-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl:

Publisher: release.yml on stffns/snapvec

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file snapvec-0.10.2-cp311-cp311-macosx_14_0_arm64.whl.

File metadata

File hashes

Hashes for snapvec-0.10.2-cp311-cp311-macosx_14_0_arm64.whl
Algorithm Hash digest
SHA256 058740a3de60a645bb966b000ac1e1d3252a9100340512f71b62206d9ee262b3
MD5 54e65e05bda7f851745ce0213e654633
BLAKE2b-256 820dd4ce428148d5ab9643ed896fce852540d496c89af5c347354e6e8759f363

See more details on using hashes here.

Provenance

The following attestation bundles were made for snapvec-0.10.2-cp311-cp311-macosx_14_0_arm64.whl:

Publisher: release.yml on stffns/snapvec

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file snapvec-0.10.2-cp310-cp310-win_amd64.whl.

File metadata

  • Download URL: snapvec-0.10.2-cp310-cp310-win_amd64.whl
  • Upload date:
  • Size: 276.7 kB
  • Tags: CPython 3.10, Windows x86-64
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for snapvec-0.10.2-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 a359e3e6e3fa646e0c2e2bc533afe92f8363f70ad1259537c16748349e0edc76
MD5 c5048d1885935e086d8be869f72534d5
BLAKE2b-256 7e674b5cde59d83933651ebe4120342a6ff47028d5f23d6f937565aaa6451985

See more details on using hashes here.

Provenance

The following attestation bundles were made for snapvec-0.10.2-cp310-cp310-win_amd64.whl:

Publisher: release.yml on stffns/snapvec

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file snapvec-0.10.2-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for snapvec-0.10.2-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 0472d67abfc68f24c42b63d982bf66b7c41ad09600fe95df86d938d4330db699
MD5 58881640d071b9e9f3331d688d3726c5
BLAKE2b-256 d45f259b1823f58afbefc40a5dc192e4a71da55f3e7c320628288ee0dfda1a41

See more details on using hashes here.

Provenance

The following attestation bundles were made for snapvec-0.10.2-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl:

Publisher: release.yml on stffns/snapvec

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file snapvec-0.10.2-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.

File metadata

File hashes

Hashes for snapvec-0.10.2-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 382c3abf92d245a655705b048ae69116e46f60b1480497d31fd91205f1852c39
MD5 a2547602b0844fea7a4973bcaa0927c8
BLAKE2b-256 1655e886c671123dbb7750b28e888ffe3d3977844adeb270e0e6469b79c2de99

See more details on using hashes here.

Provenance

The following attestation bundles were made for snapvec-0.10.2-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl:

Publisher: release.yml on stffns/snapvec

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file snapvec-0.10.2-cp310-cp310-macosx_14_0_arm64.whl.

File metadata

File hashes

Hashes for snapvec-0.10.2-cp310-cp310-macosx_14_0_arm64.whl
Algorithm Hash digest
SHA256 66606832609a222f9cb3ed2e9f72bda2c5fd535304e711786b01ed0ffe1262ae
MD5 02282073fb73838272fecd748eb875b8
BLAKE2b-256 8ba598f29d02e730aac6a9093cc9769c8185033b6b225f299d796cc95a82d2f0

See more details on using hashes here.

Provenance

The following attestation bundles were made for snapvec-0.10.2-cp310-cp310-macosx_14_0_arm64.whl:

Publisher: release.yml on stffns/snapvec

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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