Skip to main content

goldenmatch-hnsw

Native HNSW (IndexHNSWFlat) approximate-nearest-neighbor index for GoldenMatch, shipped as a small maturin/abi3 wheel with zero C dependencies (no FAISS, no ONNX, no OpenSSL).

It is the native ANN backend behind goldenmatch.core.ann_blocker.ANNBlocker. Where the FAISS IndexFlatIP / numpy paths are exact and scale linearly (or worse) in the corpus size, HNSW gives sub-linear queries with recall approaching 1.0 — and installs everywhere the pure-Python package does.

Design

A thin PyO3 wrapper over the pyo3-free goldenhnsw Rust crate, mirroring the sibling goldenmatch-embed / goldenmatch-native wheels:

  • pyo3-free core. goldenhnsw carries the algorithm and no CPython, so it can also be linked from the pgrx postgres crate or a DataFusion FFI surface later without embedding an interpreter.
  • No rayon. Insertion is single-threaded by construction — the Python caller already parallelizes across probes/buckets, and the #688 rayon LockLatch futex-park (see the monorepo CLAUDE.md) cannot recur.
  • Inner-product scores identical to FAISS IndexFlatIP. On the normal GoldenMatch path the embedder emits L2-normalized vectors, so the inner product is the cosine similarity.
  • Deterministic graph for a given (seed, insertion order); ef_search auto-scales to the corpus size for small indexes, so recall is exact at the scales the fallback-parity tests exercise.

Usage

import numpy as np
from goldenmatch_hnsw import HnswIndex

vecs = np.random.randn(10_000, 64).astype("<f4")
vecs /= np.linalg.norm(vecs, axis=1, keepdims=True)

idx = HnswIndex(dim=64, m=16, ef_construction=200, ef_search=64)
idx.add_batch(vecs.tobytes(), n=len(vecs))          # fast bulk load

q = vecs[0]
idx.search(q.tolist(), k=10)                          # -> [(id, inner_product), ...]
idx.search_batch(vecs[:32].tobytes(), n=32, k=10)     # one list per query row

add(vec) (single incremental insert) and __len__ / .size / .dim round out the surface.

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

goldenmatch_hnsw-0.2.0.tar.gz (25.8 kB view details)

Uploaded Source

Built Distributions

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

goldenmatch_hnsw-0.2.0-cp311-abi3-win_amd64.whl (149.1 kB view details)

Uploaded CPython 3.11+Windows x86-64

goldenmatch_hnsw-0.2.0-cp311-abi3-manylinux_2_28_x86_64.whl (279.4 kB view details)

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

goldenmatch_hnsw-0.2.0-cp311-abi3-manylinux_2_28_aarch64.whl (280.3 kB view details)

Uploaded CPython 3.11+manylinux: glibc 2.28+ ARM64

goldenmatch_hnsw-0.2.0-cp311-abi3-macosx_11_0_arm64.whl (252.3 kB view details)

Uploaded CPython 3.11+macOS 11.0+ ARM64

goldenmatch_hnsw-0.2.0-cp311-abi3-macosx_10_12_x86_64.whl (253.2 kB view details)

Uploaded CPython 3.11+macOS 10.12+ x86-64

File details

Details for the file goldenmatch_hnsw-0.2.0.tar.gz.

File metadata

  • Download URL: goldenmatch_hnsw-0.2.0.tar.gz
  • Upload date:
  • Size: 25.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.13

File hashes

Hashes for goldenmatch_hnsw-0.2.0.tar.gz
Algorithm Hash digest
SHA256 6fb356537e7a9b8082dff0f59f861c6651ba1c538088c3110bb68a8c0ab1f3a6
MD5 4fe3297a86268cf3cd2c6cbf7edb7ac5
BLAKE2b-256 0d67525b43ed40acdd3733e8979afc57f8ce2a1219429ce88f9043695a3fc796

See more details on using hashes here.

File details

Details for the file goldenmatch_hnsw-0.2.0-cp311-abi3-win_amd64.whl.

File metadata

File hashes

Hashes for goldenmatch_hnsw-0.2.0-cp311-abi3-win_amd64.whl
Algorithm Hash digest
SHA256 88f119302e3f01c1235158b0fc3c28ce7e29c3b7eb565e283f6a35c7d5b8905e
MD5 7d4574b211b39fb46985787bfa64ae66
BLAKE2b-256 2810706c9b4632f9379ed86db67306b5bfa67554991a12053f1c514ce220b648

See more details on using hashes here.

File details

Details for the file goldenmatch_hnsw-0.2.0-cp311-abi3-manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for goldenmatch_hnsw-0.2.0-cp311-abi3-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 a3b1951aa9acd5bcfce760e900695a45678f74ea0bd8c17096b5338fa48b2997
MD5 06f1f4f2d28e83fd064fcb025d1651f3
BLAKE2b-256 a423f8efb5fe4e070183a05f76d12032d559494c1894d3d94ced3c1823923622

See more details on using hashes here.

File details

Details for the file goldenmatch_hnsw-0.2.0-cp311-abi3-manylinux_2_28_aarch64.whl.

File metadata

File hashes

Hashes for goldenmatch_hnsw-0.2.0-cp311-abi3-manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 7d007a680d62d5ccb6e803ba55e3935a59c26d2dd3e7c8f8b78de5123762acc6
MD5 41bff484fea690b09774d61a816d5618
BLAKE2b-256 75c7a60d09ab2102f58692c81e881428a607550508c54543ce1335c45976ae7b

See more details on using hashes here.

File details

Details for the file goldenmatch_hnsw-0.2.0-cp311-abi3-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for goldenmatch_hnsw-0.2.0-cp311-abi3-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 f54297ba8476044b9a2404885646812235c66f5bf4b31ee735da8ce212a9c0ed
MD5 365e2bc920c0a3f0344874446870392e
BLAKE2b-256 8565ce1a98ad30acf81c037524dcc487fc857766821e1e28d46190d835a8ab1d

See more details on using hashes here.

File details

Details for the file goldenmatch_hnsw-0.2.0-cp311-abi3-macosx_10_12_x86_64.whl.

File metadata

File hashes

Hashes for goldenmatch_hnsw-0.2.0-cp311-abi3-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 3e4f4bf718c9754b47d13ff82a1d0242959e82cf4245794d9d1b441c8171658d
MD5 f22d5a47532b20b54cc885893f6db30a
BLAKE2b-256 ddfdad3217f7ea83d08e1a3c387b78ab448103f06a69e6ec35382a39331bb3a5

See more details on using hashes here.

Release history Release notifications | RSS feed

This release

0.2.0 This release

6 files

0.1.0

6 files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page