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)

Pareto frontier

Three numbers from v0.11.0 on BEIR FIQA (N = 57,638, dim = 384 BGE-small, Apple M4 Pro, single-thread, 200 queries, point area proportional to on-disk footprint):

  • 0.945 recall @ 345 us: IVFPQ + fp16 rerank. Pareto-dominant under 500 us on this corpus.
  • 0.895 recall @ 319 us: IVFPQ at matched FAISS M=192 budget (12.6 MB). 1.4x faster than FAISS at essentially the same recall.
  • 0.649 recall @ 263 us at 4.9 MB: IVFPQ + OPQ at the aggressive M=48 corner. Beats FAISS IVFPQ M=48 on recall (+4.6 pp) at comparable disk; FAISS wins the same corner on latency (144 us).

Scope: one dataset, one hardware class. Run python experiments/bench_competitive.py on your own corpus before citing these as general claims. See benchmarks for the full matched-budget table, OPQ recall-vs-M sweep, threading curve, and N-scaling comparison vs sqlite-vec.

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.1.tar.gz (255.0 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.1-cp313-cp313-win_amd64.whl (283.7 kB view details)

Uploaded CPython 3.13Windows x86-64

snapvec-0.11.1-cp313-cp313-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl (807.7 kB view details)

Uploaded CPython 3.13manylinux: glibc 2.17+ x86-64manylinux: glibc 2.28+ x86-64

snapvec-0.11.1-cp313-cp313-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl (791.8 kB view details)

Uploaded CPython 3.13manylinux: glibc 2.17+ ARM64manylinux: glibc 2.28+ ARM64

snapvec-0.11.1-cp313-cp313-macosx_14_0_arm64.whl (529.1 kB view details)

Uploaded CPython 3.13macOS 14.0+ ARM64

snapvec-0.11.1-cp312-cp312-win_amd64.whl (284.0 kB view details)

Uploaded CPython 3.12Windows x86-64

snapvec-0.11.1-cp312-cp312-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl (812.4 kB view details)

Uploaded CPython 3.12manylinux: glibc 2.17+ x86-64manylinux: glibc 2.28+ x86-64

snapvec-0.11.1-cp312-cp312-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl (796.4 kB view details)

Uploaded CPython 3.12manylinux: glibc 2.17+ ARM64manylinux: glibc 2.28+ ARM64

snapvec-0.11.1-cp312-cp312-macosx_14_0_arm64.whl (529.8 kB view details)

Uploaded CPython 3.12macOS 14.0+ ARM64

snapvec-0.11.1-cp311-cp311-win_amd64.whl (282.7 kB view details)

Uploaded CPython 3.11Windows x86-64

snapvec-0.11.1-cp311-cp311-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl (805.9 kB view details)

Uploaded CPython 3.11manylinux: glibc 2.17+ x86-64manylinux: glibc 2.28+ x86-64

snapvec-0.11.1-cp311-cp311-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl (798.3 kB view details)

Uploaded CPython 3.11manylinux: glibc 2.17+ ARM64manylinux: glibc 2.28+ ARM64

snapvec-0.11.1-cp311-cp311-macosx_14_0_arm64.whl (530.0 kB view details)

Uploaded CPython 3.11macOS 14.0+ ARM64

snapvec-0.11.1-cp310-cp310-win_amd64.whl (282.9 kB view details)

Uploaded CPython 3.10Windows x86-64

snapvec-0.11.1-cp310-cp310-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl (782.0 kB view details)

Uploaded CPython 3.10manylinux: glibc 2.17+ x86-64manylinux: glibc 2.28+ x86-64

snapvec-0.11.1-cp310-cp310-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl (770.1 kB view details)

Uploaded CPython 3.10manylinux: glibc 2.17+ ARM64manylinux: glibc 2.28+ ARM64

snapvec-0.11.1-cp310-cp310-macosx_14_0_arm64.whl (530.3 kB view details)

Uploaded CPython 3.10macOS 14.0+ ARM64

File details

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

File metadata

  • Download URL: snapvec-0.11.1.tar.gz
  • Upload date:
  • Size: 255.0 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.1.tar.gz
Algorithm Hash digest
SHA256 51e05a318ceb9bae8fd9dae10d1cfe056c012befd05314a2d071ef92c5f23775
MD5 741e3885a7b31580f4ff8d4e5c83f86d
BLAKE2b-256 02dc4d1c260c778635e3254864d3d59f80fd77ba4705806494d4d978a727599a

See more details on using hashes here.

Provenance

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

File metadata

  • Download URL: snapvec-0.11.1-cp313-cp313-win_amd64.whl
  • Upload date:
  • Size: 283.7 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.1-cp313-cp313-win_amd64.whl
Algorithm Hash digest
SHA256 7b8894fe1c1c10a941179ea629c13dc23fc7ee6249cf04a823df50b45dafb3c4
MD5 8abe562ca174c485897f01c03c456e94
BLAKE2b-256 02b6478e62e423eb135d03a90cc01bc2d7bb182760ea20846ecd1b0bea63321b

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for snapvec-0.11.1-cp313-cp313-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 68132065e8530b54b0634d3729bde7bc4f01090b2052490554db5f47785bce6b
MD5 1ba8d143796cb39def6082c4c0320716
BLAKE2b-256 a4703ea8cb79848abb76f3d8c43b089b59dc0852bf0d48260e92fb5c5a7873ed

See more details on using hashes here.

Provenance

The following attestation bundles were made for snapvec-0.11.1-cp313-cp313-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_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.1-cp313-cp313-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl.

File metadata

File hashes

Hashes for snapvec-0.11.1-cp313-cp313-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 56f5e3186e7ea31b5a78e31e231355e2ade0681e50b1ff7b878c99e722b8edff
MD5 0505e43edae3a017322771668553de99
BLAKE2b-256 27859fb74ac366844fe2e8617ced7e765ff947a72a31e834b5c0bd81ebc9855b

See more details on using hashes here.

Provenance

The following attestation bundles were made for snapvec-0.11.1-cp313-cp313-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_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.1-cp313-cp313-macosx_14_0_arm64.whl.

File metadata

File hashes

Hashes for snapvec-0.11.1-cp313-cp313-macosx_14_0_arm64.whl
Algorithm Hash digest
SHA256 ff8b8c7d6cf40782df8507833c786f3831062a66e141e6ecb6858885d69a1f84
MD5 5318ab29e69662332392962ffa537d05
BLAKE2b-256 bc514c0e7e262a407a0d0d9bb5873cd054e9398b22bc630bbd5c7519f5f39029

See more details on using hashes here.

Provenance

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

File metadata

  • Download URL: snapvec-0.11.1-cp312-cp312-win_amd64.whl
  • Upload date:
  • Size: 284.0 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.1-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 eb378d6358865d2dc44d7edcd66d39bf1b767225972598996da61f85e6c5efc3
MD5 d4db951224478e3574668aa3eac3801d
BLAKE2b-256 bd6e1bed9f5fe8cc45952090236463efa796a771984b17715e2205453157204d

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for snapvec-0.11.1-cp312-cp312-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 e900cb915c5aa965c5d4241861b89010a271f132bd47a7b018f6d4793da6063e
MD5 6b8708644b9244a773bbc509ea9f6bbd
BLAKE2b-256 25fe257cb63118ac9cffcfbe848b7a1b23af68abcf99c78c467ebd591ee0da08

See more details on using hashes here.

Provenance

The following attestation bundles were made for snapvec-0.11.1-cp312-cp312-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_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.1-cp312-cp312-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl.

File metadata

File hashes

Hashes for snapvec-0.11.1-cp312-cp312-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 8f6f9d380783c8fdca6c61685227aadb66a3998366ffec38317f56e1a5f422d0
MD5 020e97ea742ad1c92ab94361b71daef2
BLAKE2b-256 6418c2d02249365e801059086570c920c7674d416068dacb1e46ba7d95c773ff

See more details on using hashes here.

Provenance

The following attestation bundles were made for snapvec-0.11.1-cp312-cp312-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_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.1-cp312-cp312-macosx_14_0_arm64.whl.

File metadata

File hashes

Hashes for snapvec-0.11.1-cp312-cp312-macosx_14_0_arm64.whl
Algorithm Hash digest
SHA256 275c3b62241c4bd7d51dfbb7ffd47a4a7681caed20c63fe782eb0e6e06414be3
MD5 c762b37403f1f852703a54014497164a
BLAKE2b-256 140a1c1ca7859fe1dfb619880c185b5a4e15fc981a44af9acdc7699c466508cc

See more details on using hashes here.

Provenance

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

File metadata

  • Download URL: snapvec-0.11.1-cp311-cp311-win_amd64.whl
  • Upload date:
  • Size: 282.7 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.1-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 cc1b23792e32a7c688d3feb0e4090137887db7a5e8981a9b9e352865a2399cea
MD5 0a1e45a00025864fd752da248b791a90
BLAKE2b-256 a9ec9a0999922bb8e10074ee65d9b4a9cf63a8c60544aa0c9d793e4b809af608

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for snapvec-0.11.1-cp311-cp311-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 997533dd206379dabcffb151eab82b4373234f6eae87c0f5d83f980b0d75febb
MD5 9cd6a1842995453a974d2d2bca9ecebc
BLAKE2b-256 edcdd889b6f515da7575e3eaed9529bdbff5bb5143ece6fa804e9b842bfea477

See more details on using hashes here.

Provenance

The following attestation bundles were made for snapvec-0.11.1-cp311-cp311-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_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.1-cp311-cp311-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl.

File metadata

File hashes

Hashes for snapvec-0.11.1-cp311-cp311-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 c87f1bb80355cb8c3bf65a3454b1e56012e14c86cf154965f3d9179758a92772
MD5 3fb60c50677a138ff2347fd100505b35
BLAKE2b-256 141501a4a451b045f9413e139014c8dae11e52ee4b2cc8bca1af9768f44d8354

See more details on using hashes here.

Provenance

The following attestation bundles were made for snapvec-0.11.1-cp311-cp311-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_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.1-cp311-cp311-macosx_14_0_arm64.whl.

File metadata

File hashes

Hashes for snapvec-0.11.1-cp311-cp311-macosx_14_0_arm64.whl
Algorithm Hash digest
SHA256 7e96041d0e4c31b6d7360cbcf773e9b6eb545d722ff4486af8571e65723b21ca
MD5 998f2b91bba21f5889b4e40bfc9d5b68
BLAKE2b-256 e242d05cb8b8c26931a0ed412561dd1248eae3f3b5caab08c096a4b61cd3289c

See more details on using hashes here.

Provenance

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

File metadata

  • Download URL: snapvec-0.11.1-cp310-cp310-win_amd64.whl
  • Upload date:
  • Size: 282.9 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.1-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 116231b3ce99c3e6ea7d7bcccb70c59bba4a0e01c1ae36f608e2fac8906a6090
MD5 be2a3dfe7e73db94bc4007d412733747
BLAKE2b-256 35be05050d47e04e8eecd692026c287173b8c71f0bb5cdc41ac7497240e289fb

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for snapvec-0.11.1-cp310-cp310-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 b82c3e271b77328029a1717234e373388b1ae903c0c7d1faa3afc131858da325
MD5 a7392031aa1b24ab01f389f68251ab38
BLAKE2b-256 405bf8a31472b63e8828649c960188d1727d0eea8e1b96d6df1d66a64de1ad33

See more details on using hashes here.

Provenance

The following attestation bundles were made for snapvec-0.11.1-cp310-cp310-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_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.1-cp310-cp310-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl.

File metadata

File hashes

Hashes for snapvec-0.11.1-cp310-cp310-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 cb22a4eac0a402ed796ebd37c56383ccfafc02f22f84cc1dea2c13f6762120a1
MD5 22fed543f3e3d49bc72fa445229815d3
BLAKE2b-256 fde59d80f8725cf76d204fc4f2090d580336e05baf887137154d910ea0c62162

See more details on using hashes here.

Provenance

The following attestation bundles were made for snapvec-0.11.1-cp310-cp310-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_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.1-cp310-cp310-macosx_14_0_arm64.whl.

File metadata

File hashes

Hashes for snapvec-0.11.1-cp310-cp310-macosx_14_0_arm64.whl
Algorithm Hash digest
SHA256 950d1e8c0dfadd90e43b892cf4f891a08fa828e7029105209aad318490d95943
MD5 95e3e861c6b98469889e5cc17947edd1
BLAKE2b-256 8009284a5a192fe60d689978f67dc538e5183e248d1b253d6d8a4fadd258132e

See more details on using hashes here.

Provenance

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