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.1.0.tar.gz (25.3 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.1.0-cp311-abi3-win_amd64.whl (152.1 kB view details)

Uploaded CPython 3.11+Windows x86-64

goldenmatch_hnsw-0.1.0-cp311-abi3-manylinux_2_28_x86_64.whl (278.5 kB view details)

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

goldenmatch_hnsw-0.1.0-cp311-abi3-manylinux_2_28_aarch64.whl (278.6 kB view details)

Uploaded CPython 3.11+manylinux: glibc 2.28+ ARM64

goldenmatch_hnsw-0.1.0-cp311-abi3-macosx_11_0_arm64.whl (251.1 kB view details)

Uploaded CPython 3.11+macOS 11.0+ ARM64

goldenmatch_hnsw-0.1.0-cp311-abi3-macosx_10_12_x86_64.whl (257.3 kB view details)

Uploaded CPython 3.11+macOS 10.12+ x86-64

File details

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

File metadata

  • Download URL: goldenmatch_hnsw-0.1.0.tar.gz
  • Upload date:
  • Size: 25.3 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.1.0.tar.gz
Algorithm Hash digest
SHA256 faadf09428c47313abf14a20c2368e2708e68438e7ebb8f0ccb90f5f22beb886
MD5 dc05dac8c3c86b86eb3b40640b79f5d5
BLAKE2b-256 68a2f5eba9959bfed8c3c3a0012d60b148bae72f2c8d6e2ae6a37b1f948e187c

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for goldenmatch_hnsw-0.1.0-cp311-abi3-win_amd64.whl
Algorithm Hash digest
SHA256 df112620e11c6d496996a091fe1eacfee68c141b8361cd2d28ba36c2c3c9ecde
MD5 4f1feae8fa963fa091361564d4582e0d
BLAKE2b-256 e0f92e6ef72568c940bf4f62f5d591f25837589b1b8c41ab0f403bba5bf54564

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for goldenmatch_hnsw-0.1.0-cp311-abi3-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 dfdcd5d8d3391f02ffd8437765c5dc69be7b5b11fa8d38405402a2845745c496
MD5 e0b2086d83d012321e61ac85a2411c08
BLAKE2b-256 e78613d9cbdd21a746be6eab35a64a337011e30990da65f82aeea16ff9298e98

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for goldenmatch_hnsw-0.1.0-cp311-abi3-manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 5602e8e3c450ee5eeb491eada1dee75eddb07306e73875c1a516bc79d147e907
MD5 f1de23cf141d7d9478a1ae133c75e67e
BLAKE2b-256 13bc801955207f6e9bedea878d3dc5bb09e64d0767fc24e6c15600207a524caf

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for goldenmatch_hnsw-0.1.0-cp311-abi3-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 1164bc02277902741a5e9b2fd93f5f064195ba6e619e1fa4800c0dcd5ee61504
MD5 f3890b4d18326f5adaba9333ba8708e3
BLAKE2b-256 022e8ae53db45ade7d1467698ffcee97eaef62be33c07f1378f0602c34f83582

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for goldenmatch_hnsw-0.1.0-cp311-abi3-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 8d638f4df3a93b1df3f590e69d5776dcd1a35be15b83065ed1e474865c149eb7
MD5 b35a307c4cf34855348ae635b895b534
BLAKE2b-256 af02b88b6321c68c73d50a91229dd0b061d3e8ab0ba5e778f3aa378dfcaca831

See more details on using hashes here.

Release history Release notifications | RSS feed

0.2.0

6 files

This release

0.1.0 This release

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