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.11.0.tar.gz (248.6 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.11.0-cp313-cp313-win_amd64.whl (281.2 kB view details)

Uploaded CPython 3.13Windows x86-64

snapvec-0.11.0-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (721.8 kB view details)

Uploaded CPython 3.13manylinux: glibc 2.17+ x86-64

snapvec-0.11.0-cp313-cp313-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (718.8 kB view details)

Uploaded CPython 3.13manylinux: glibc 2.17+ ARM64

snapvec-0.11.0-cp313-cp313-macosx_14_0_arm64.whl (526.5 kB view details)

Uploaded CPython 3.13macOS 14.0+ ARM64

snapvec-0.11.0-cp312-cp312-win_amd64.whl (281.5 kB view details)

Uploaded CPython 3.12Windows x86-64

snapvec-0.11.0-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (730.6 kB view details)

Uploaded CPython 3.12manylinux: glibc 2.17+ x86-64

snapvec-0.11.0-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (726.3 kB view details)

Uploaded CPython 3.12manylinux: glibc 2.17+ ARM64

snapvec-0.11.0-cp312-cp312-macosx_14_0_arm64.whl (527.3 kB view details)

Uploaded CPython 3.12macOS 14.0+ ARM64

snapvec-0.11.0-cp311-cp311-win_amd64.whl (280.2 kB view details)

Uploaded CPython 3.11Windows x86-64

snapvec-0.11.0-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (733.8 kB view details)

Uploaded CPython 3.11manylinux: glibc 2.17+ x86-64

snapvec-0.11.0-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (730.8 kB view details)

Uploaded CPython 3.11manylinux: glibc 2.17+ ARM64

snapvec-0.11.0-cp311-cp311-macosx_14_0_arm64.whl (527.5 kB view details)

Uploaded CPython 3.11macOS 14.0+ ARM64

snapvec-0.11.0-cp310-cp310-win_amd64.whl (280.4 kB view details)

Uploaded CPython 3.10Windows x86-64

snapvec-0.11.0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (706.1 kB view details)

Uploaded CPython 3.10manylinux: glibc 2.17+ x86-64

snapvec-0.11.0-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (705.6 kB view details)

Uploaded CPython 3.10manylinux: glibc 2.17+ ARM64

snapvec-0.11.0-cp310-cp310-macosx_14_0_arm64.whl (527.8 kB view details)

Uploaded CPython 3.10macOS 14.0+ ARM64

File details

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

File metadata

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

File hashes

Hashes for snapvec-0.11.0.tar.gz
Algorithm Hash digest
SHA256 fbd6453ff9c86980846c8d6f8ad10ab9f6f55f38d8822c514d90158da2aba0d1
MD5 b2b9ba533b7fa0c70f6d5ef4c5c6a61a
BLAKE2b-256 32e927dfbcd69c82ca063941f0608618a35c3ab0faba46faceb271c649ad4de8

See more details on using hashes here.

Provenance

The following attestation bundles were made for snapvec-0.11.0.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.11.0-cp313-cp313-win_amd64.whl.

File metadata

  • Download URL: snapvec-0.11.0-cp313-cp313-win_amd64.whl
  • Upload date:
  • Size: 281.2 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.11.0-cp313-cp313-win_amd64.whl
Algorithm Hash digest
SHA256 a892e068cd4c35825a681b7e70b0b49415a876b77ee61b8a8424922c5b46c9e5
MD5 f4e53aa8712180681d569e650a509224
BLAKE2b-256 5c39810516ee3f073c620fe53173ea34899b2fe4c41c9c013cb0d80a9ae261f7

See more details on using hashes here.

Provenance

The following attestation bundles were made for snapvec-0.11.0-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.11.0-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for snapvec-0.11.0-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 27cfeb853e42a5a7665770f0ffdc37afe252860513d3c4f40df3497d526f99a0
MD5 71260746bae0a90a106ca0166c6347b0
BLAKE2b-256 5aa5eaced5115d4de9e945d4629576b4f80e2a6d05ba76877db8be7b9572e702

See more details on using hashes here.

Provenance

The following attestation bundles were made for snapvec-0.11.0-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.11.0-cp313-cp313-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.

File metadata

File hashes

Hashes for snapvec-0.11.0-cp313-cp313-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 bee7f02fc6ba6d7b657c3fec5cf22a427c4fc7f9ccb62c1fa4a0f1f5a4bc4017
MD5 c52937ba7cced65ba30a691953d5833a
BLAKE2b-256 49b5e753e5066f2cc60cd0a61f052208cdb2ff6bee72511d6d5bd11b0af02666

See more details on using hashes here.

Provenance

The following attestation bundles were made for snapvec-0.11.0-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.11.0-cp313-cp313-macosx_14_0_arm64.whl.

File metadata

File hashes

Hashes for snapvec-0.11.0-cp313-cp313-macosx_14_0_arm64.whl
Algorithm Hash digest
SHA256 b3ff74e35c0109246d6e4182227db5de35a76eefba122960a1016e86535a4d5e
MD5 0f58b80626bff69b6d9239560c66d9ab
BLAKE2b-256 09e42ca139879900d929b10c1f9939bc762182a6508b461c03a64f331dd0adaf

See more details on using hashes here.

Provenance

The following attestation bundles were made for snapvec-0.11.0-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.11.0-cp312-cp312-win_amd64.whl.

File metadata

  • Download URL: snapvec-0.11.0-cp312-cp312-win_amd64.whl
  • Upload date:
  • Size: 281.5 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.11.0-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 adc9266aae4cc9177e3efc70a1befc563ff03d27918b467e6142351c411aa21e
MD5 744bd8689aa9c74d30ac7aaedbb2d1d4
BLAKE2b-256 9cd7ec176e0c359258b991615f0155e43c339772fa3f470daeed325ef96ea40c

See more details on using hashes here.

Provenance

The following attestation bundles were made for snapvec-0.11.0-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.11.0-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for snapvec-0.11.0-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 dd6320b9aa1f2e94d970ad1700895cddc959b47dd7e850d5bf5893d4d2d77721
MD5 3407fe36716079686e553b6e8b5946e6
BLAKE2b-256 6ab1b6bc62a84f58feb4299308f98ccb6027bad23898d4768b2f272ebd487524

See more details on using hashes here.

Provenance

The following attestation bundles were made for snapvec-0.11.0-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.11.0-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.

File metadata

File hashes

Hashes for snapvec-0.11.0-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 524282b1fe17a383455b81e6b43121b0e0eaa6f734d0cfaea26b601b618cc4c3
MD5 d7c63908917f73bb0fcad78bdf7b89c9
BLAKE2b-256 ddfb35c416878e75ae43145cdd796380b1b06dce77910b608ebf7e77e7fdc861

See more details on using hashes here.

Provenance

The following attestation bundles were made for snapvec-0.11.0-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.11.0-cp312-cp312-macosx_14_0_arm64.whl.

File metadata

File hashes

Hashes for snapvec-0.11.0-cp312-cp312-macosx_14_0_arm64.whl
Algorithm Hash digest
SHA256 2c4003bffe257232df020c96b9785d6372caae8b557a814f7e6f3ecbf542825f
MD5 ea435b9a692f981404b57334c75a0877
BLAKE2b-256 4acb621c2015804509cbba142a8d40c2eed641a4e656c29bb04041e22b18fbb5

See more details on using hashes here.

Provenance

The following attestation bundles were made for snapvec-0.11.0-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.11.0-cp311-cp311-win_amd64.whl.

File metadata

  • Download URL: snapvec-0.11.0-cp311-cp311-win_amd64.whl
  • Upload date:
  • Size: 280.2 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.11.0-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 c1e739cf69d7d1b59780b325efbef77c7c707fe2952a01c9b94dfd903e5f4979
MD5 e452ab2f136b24a571d3725f33c53cda
BLAKE2b-256 74490c5d47cf0ac04d8b4d03dc2d06f1f210b66ed2907102304e8e2dfbb9e90d

See more details on using hashes here.

Provenance

The following attestation bundles were made for snapvec-0.11.0-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.11.0-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for snapvec-0.11.0-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 79a849a60fd65545804ff5164cbba52777c61332931da3e88b1c50c169ff3eda
MD5 23b7f11e3b5c77b88ed8fab976a0c89f
BLAKE2b-256 c3a3deaf87123b3ded54493a89260c87c4599cf87435ebb832faa01500a85469

See more details on using hashes here.

Provenance

The following attestation bundles were made for snapvec-0.11.0-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.11.0-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.

File metadata

File hashes

Hashes for snapvec-0.11.0-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 631635f9253a2bbb4e5a32245ed22f2f3fafbee42371b4877aba04b6602d6533
MD5 6dc0919f819c938a8be7075f2b4d2c94
BLAKE2b-256 457e6ab0a8debff568cac4d79d863c06f421b6ae8b02419174af360ab27e2f59

See more details on using hashes here.

Provenance

The following attestation bundles were made for snapvec-0.11.0-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.11.0-cp311-cp311-macosx_14_0_arm64.whl.

File metadata

File hashes

Hashes for snapvec-0.11.0-cp311-cp311-macosx_14_0_arm64.whl
Algorithm Hash digest
SHA256 22314d6caa434641e7deef1c7c6c9ee8df5d1c4f9ee58f30499f8289d3b9943d
MD5 6b8b7e2dc5040d0e1eaab694b58b4792
BLAKE2b-256 c084191c57b5162da9b12ccc9bf2e5cc7e13d608b71955fe686e6f2525c613bf

See more details on using hashes here.

Provenance

The following attestation bundles were made for snapvec-0.11.0-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.11.0-cp310-cp310-win_amd64.whl.

File metadata

  • Download URL: snapvec-0.11.0-cp310-cp310-win_amd64.whl
  • Upload date:
  • Size: 280.4 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.11.0-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 cc3fb25094812756bc8f243994e624a73148f70f8e2167244a25317695ad04bc
MD5 3ce6bc9b1d9e30c93901532b36b46196
BLAKE2b-256 349e218cb8acd24228ab2eb39736cf1437cfb4e7d98c9949aec74e7fc804d153

See more details on using hashes here.

Provenance

The following attestation bundles were made for snapvec-0.11.0-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.11.0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for snapvec-0.11.0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 61ec7c065d6294de739e0490357afbdfab95c93798057b20a112e7d8ef01be08
MD5 5ace912e9edfab56b231a3df4d7f82eb
BLAKE2b-256 52d78889f701430e90caf32563b80ad3444844c9cee3c2d6971f0188085011ce

See more details on using hashes here.

Provenance

The following attestation bundles were made for snapvec-0.11.0-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.11.0-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.

File metadata

File hashes

Hashes for snapvec-0.11.0-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 9d4733d739b1ab3d19236956b3c46c5a457088867a922474f146149b634c2f79
MD5 35e4ac87c084987447a27197b6eb9fd5
BLAKE2b-256 dd84d6f84609698b80c61346d43bea7347c4ea2b24af43a17ce6584ea7fb2815

See more details on using hashes here.

Provenance

The following attestation bundles were made for snapvec-0.11.0-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.11.0-cp310-cp310-macosx_14_0_arm64.whl.

File metadata

File hashes

Hashes for snapvec-0.11.0-cp310-cp310-macosx_14_0_arm64.whl
Algorithm Hash digest
SHA256 a81af5fc6202889c3c8bc144048ad4386b234fdca480bfc5d3ee492db86d22ae
MD5 d9dd28e8ed0c48f9b367fc71c401efb0
BLAKE2b-256 e72edfef49c2069c92268351c9ffd3fcd8b4870c56c01173e570baa926428e45

See more details on using hashes here.

Provenance

The following attestation bundles were made for snapvec-0.11.0-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