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.3.tar.gz (242.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.10.3-cp313-cp313-win_amd64.whl (278.4 kB view details)

Uploaded CPython 3.13Windows x86-64

snapvec-0.10.3-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (723.3 kB view details)

Uploaded CPython 3.13manylinux: glibc 2.17+ x86-64

snapvec-0.10.3-cp313-cp313-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (716.0 kB view details)

Uploaded CPython 3.13manylinux: glibc 2.17+ ARM64

snapvec-0.10.3-cp313-cp313-macosx_14_0_arm64.whl (523.8 kB view details)

Uploaded CPython 3.13macOS 14.0+ ARM64

snapvec-0.10.3-cp312-cp312-win_amd64.whl (278.6 kB view details)

Uploaded CPython 3.12Windows x86-64

snapvec-0.10.3-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (732.0 kB view details)

Uploaded CPython 3.12manylinux: glibc 2.17+ x86-64

snapvec-0.10.3-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (723.5 kB view details)

Uploaded CPython 3.12manylinux: glibc 2.17+ ARM64

snapvec-0.10.3-cp312-cp312-macosx_14_0_arm64.whl (524.5 kB view details)

Uploaded CPython 3.12macOS 14.0+ ARM64

snapvec-0.10.3-cp311-cp311-win_amd64.whl (277.3 kB view details)

Uploaded CPython 3.11Windows x86-64

snapvec-0.10.3-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (735.1 kB view details)

Uploaded CPython 3.11manylinux: glibc 2.17+ x86-64

snapvec-0.10.3-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (728.1 kB view details)

Uploaded CPython 3.11manylinux: glibc 2.17+ ARM64

snapvec-0.10.3-cp311-cp311-macosx_14_0_arm64.whl (524.7 kB view details)

Uploaded CPython 3.11macOS 14.0+ ARM64

snapvec-0.10.3-cp310-cp310-win_amd64.whl (277.5 kB view details)

Uploaded CPython 3.10Windows x86-64

snapvec-0.10.3-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (706.9 kB view details)

Uploaded CPython 3.10manylinux: glibc 2.17+ x86-64

snapvec-0.10.3-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (702.9 kB view details)

Uploaded CPython 3.10manylinux: glibc 2.17+ ARM64

snapvec-0.10.3-cp310-cp310-macosx_14_0_arm64.whl (525.0 kB view details)

Uploaded CPython 3.10macOS 14.0+ ARM64

File details

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

File metadata

  • Download URL: snapvec-0.10.3.tar.gz
  • Upload date:
  • Size: 242.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.10.3.tar.gz
Algorithm Hash digest
SHA256 792138bcaf1525adca99d4767ac7a73bdd2036fb7e595921437c8c9a6a3cb508
MD5 a679c6d916affc9f58fd6b833278af10
BLAKE2b-256 4616aa3056d234b9bd18af5132be9dc3f07af90ba4eeb51e4be9d5aff3f8885e

See more details on using hashes here.

Provenance

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

File metadata

  • Download URL: snapvec-0.10.3-cp313-cp313-win_amd64.whl
  • Upload date:
  • Size: 278.4 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.3-cp313-cp313-win_amd64.whl
Algorithm Hash digest
SHA256 8bf2996a4cec61b4feff8719cbaaff2c8407eb1dca6cd6da1c9ba7c8792a99fc
MD5 69f4e20fa4cceab6a77de1a858fe41f9
BLAKE2b-256 93be2550fba98ddfce32b94752d7426e26dde8694ee301d4672b4ab1fcdb47f4

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for snapvec-0.10.3-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 802096f7d879d51335c1724de6cde268b63bd426f25051eb5d333cacdf16bd2a
MD5 ba8d45d8eb72ac387abbd7f37a7a4134
BLAKE2b-256 6df77c9a63e9dd8b68a8bd93ccdbb06ceb8114a42726784baed006d1d3e9be0a

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for snapvec-0.10.3-cp313-cp313-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 c7f3bd935b6e10d9ce501a393cf54e9dbc0fbebaa131362c930bc48858a0aee6
MD5 ac8b20c55ef5010e7f411975b773b085
BLAKE2b-256 4f5ebeb7ba988d012d4eee11efd92c2496ece673c10fa84e44971c09b2ee95a2

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for snapvec-0.10.3-cp313-cp313-macosx_14_0_arm64.whl
Algorithm Hash digest
SHA256 7c02095317aeb7dc5e913796de033cd05f5cb724eb60ed3ae28509f0ee8573c2
MD5 543119622bbb3db87dc015665d1fd2f2
BLAKE2b-256 d5168730c42d85ef6abffd5e6934a7c0aeabb417863f5f0c00961a8acd36c8d6

See more details on using hashes here.

Provenance

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

File metadata

  • Download URL: snapvec-0.10.3-cp312-cp312-win_amd64.whl
  • Upload date:
  • Size: 278.6 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.3-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 5603eb3948b4bb162d06e3004a2c3a33fa9e4529b3fdbc5a01d73aee27357cb2
MD5 61f93cf8e9fb35d91747fc9e595f2341
BLAKE2b-256 0c70f8b7fced2d8fc4ff68aea0b44c14c84924f81ae614462f312aa1d4dda96a

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for snapvec-0.10.3-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 db3c0f5e7a9b5d97525b65c5596445959271567acb6659900e65175eff96435d
MD5 2f17f86a03e79bd4b982d95452c05d0c
BLAKE2b-256 a8ee63b0b8a36224c40819f3e3b247fe304274315d41917b6f54a569bb8fe419

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for snapvec-0.10.3-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 9d539cf71ac360dc7b18251a79346e6cffca0a927183d8076a774141d0c78f4d
MD5 fc37f98e3e6226ecd2edc801d44c675b
BLAKE2b-256 9884b3383a5248145cda9224b383d4e8f10dc5778fbbfd8c73eb7d4c48d203a6

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for snapvec-0.10.3-cp312-cp312-macosx_14_0_arm64.whl
Algorithm Hash digest
SHA256 b4c870bc1679050758ccf83f2556f906b245eee4adaa1be1dbcbed7a57f2ee97
MD5 c78c64b64a5e4f8b8f4025c6ef294368
BLAKE2b-256 1ec4752490572247a548c4b3fb9cf09efe9c1f9affc1d42177c8e057adfa5b91

See more details on using hashes here.

Provenance

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

File metadata

  • Download URL: snapvec-0.10.3-cp311-cp311-win_amd64.whl
  • Upload date:
  • Size: 277.3 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.3-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 798213afb31a995a0daee69ac25cf3f4f73eef60ceb33ec7c9f8cf834aa66ae6
MD5 4e8f5f9614ea92e9384759606446c587
BLAKE2b-256 0078e46bafafb1362ff1c30813abd04dda8bf1f57f40a35865774916c9a150f9

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for snapvec-0.10.3-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 98c2c2af187cca749c5be345dd05b142d023502cac5dc1cb7a49a00ff56bf324
MD5 ef0acfb2e1de52a6eb67a64459cca361
BLAKE2b-256 cf51954ff2d7d404552016495c8746dab1bf1b2952ed09bbb5f04ec3d14e6e4f

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for snapvec-0.10.3-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 0b1942cb1229918d2e18de7316b3967476627c815789984d88478f6f44040dbe
MD5 6be7d7503d4c173d2ca427007b7f9cf6
BLAKE2b-256 b238d8d25e4356f2d7020be28d0da9ef6f8a875867c0001f7d6ee705a5071249

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for snapvec-0.10.3-cp311-cp311-macosx_14_0_arm64.whl
Algorithm Hash digest
SHA256 eb83997e6643096db71807eb618a8471f91ca7a50bc7cf1cb969035a48d96351
MD5 78344ba69530ee94c702e0949dc3952e
BLAKE2b-256 b3df419260c6d68e7b1f6d739389eaa4afb1f11703f432a5d831b4712115e5f0

See more details on using hashes here.

Provenance

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

File metadata

  • Download URL: snapvec-0.10.3-cp310-cp310-win_amd64.whl
  • Upload date:
  • Size: 277.5 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.3-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 48c4d0ce81d93a96468590ff82c6991d8b33cdf29e3a69e4b74f8ca456ef2625
MD5 5756be273956eb5362c1e4ec8966c526
BLAKE2b-256 fadad97e17d59dd95dd8572a761b6e8ab779ffe5902ae92ee7f4fa46d4b49bac

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for snapvec-0.10.3-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 4de2f24b47afa90b6fa5c7f17e884bb1ce2a45f21ba53245f895c3995e3fcab6
MD5 75a9b34c2b6d7a087108df83bcfea9ce
BLAKE2b-256 48d1eccdf6c4ffd36188722e01b577b5495c45ff93d2cb560fcffd8dd8561398

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for snapvec-0.10.3-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 20745fa8b8bf4372c4de0c29daed24e93859b6f8d586fdfa49303bd21ad54ccb
MD5 eccbe9201481902c691e54a8aa784605
BLAKE2b-256 62f0cd774991d2c2d69ed8c5913b36e4ef2d6d9e970d2f425091a6f56cad3347

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for snapvec-0.10.3-cp310-cp310-macosx_14_0_arm64.whl
Algorithm Hash digest
SHA256 b27613b9bfa6d278a95cb96fa917c2bcd90669e31d50dbd9daad8174cd6055a1
MD5 a55a13f0067085b46db9187102fb5534
BLAKE2b-256 5a726cda62d7ea3543a170799556375196920c4a41e2456a36612196aa5a530d

See more details on using hashes here.

Provenance

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