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.
goldenhnswcarries the algorithm and no CPython, so it can also be linked from the pgrxpostgrescrate 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 rayonLockLatchfutex-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_searchauto-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
Built Distributions
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
faadf09428c47313abf14a20c2368e2708e68438e7ebb8f0ccb90f5f22beb886
|
|
| MD5 |
dc05dac8c3c86b86eb3b40640b79f5d5
|
|
| BLAKE2b-256 |
68a2f5eba9959bfed8c3c3a0012d60b148bae72f2c8d6e2ae6a37b1f948e187c
|
File details
Details for the file goldenmatch_hnsw-0.1.0-cp311-abi3-win_amd64.whl.
File metadata
- Download URL: goldenmatch_hnsw-0.1.0-cp311-abi3-win_amd64.whl
- Upload date:
- Size: 152.1 kB
- Tags: CPython 3.11+, Windows x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via:
twine/6.1.0 CPython/3.13.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
df112620e11c6d496996a091fe1eacfee68c141b8361cd2d28ba36c2c3c9ecde
|
|
| MD5 |
4f1feae8fa963fa091361564d4582e0d
|
|
| BLAKE2b-256 |
e0f92e6ef72568c940bf4f62f5d591f25837589b1b8c41ab0f403bba5bf54564
|
File details
Details for the file goldenmatch_hnsw-0.1.0-cp311-abi3-manylinux_2_28_x86_64.whl.
File metadata
- Download URL: goldenmatch_hnsw-0.1.0-cp311-abi3-manylinux_2_28_x86_64.whl
- Upload date:
- Size: 278.5 kB
- Tags: CPython 3.11+, manylinux: glibc 2.28+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via:
twine/6.1.0 CPython/3.13.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
dfdcd5d8d3391f02ffd8437765c5dc69be7b5b11fa8d38405402a2845745c496
|
|
| MD5 |
e0b2086d83d012321e61ac85a2411c08
|
|
| BLAKE2b-256 |
e78613d9cbdd21a746be6eab35a64a337011e30990da65f82aeea16ff9298e98
|
File details
Details for the file goldenmatch_hnsw-0.1.0-cp311-abi3-manylinux_2_28_aarch64.whl.
File metadata
- Download URL: goldenmatch_hnsw-0.1.0-cp311-abi3-manylinux_2_28_aarch64.whl
- Upload date:
- Size: 278.6 kB
- Tags: CPython 3.11+, manylinux: glibc 2.28+ ARM64
- Uploaded using Trusted Publishing? No
- Uploaded via:
twine/6.1.0 CPython/3.13.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
5602e8e3c450ee5eeb491eada1dee75eddb07306e73875c1a516bc79d147e907
|
|
| MD5 |
f1de23cf141d7d9478a1ae133c75e67e
|
|
| BLAKE2b-256 |
13bc801955207f6e9bedea878d3dc5bb09e64d0767fc24e6c15600207a524caf
|
File details
Details for the file goldenmatch_hnsw-0.1.0-cp311-abi3-macosx_11_0_arm64.whl.
File metadata
- Download URL: goldenmatch_hnsw-0.1.0-cp311-abi3-macosx_11_0_arm64.whl
- Upload date:
- Size: 251.1 kB
- Tags: CPython 3.11+, macOS 11.0+ ARM64
- Uploaded using Trusted Publishing? No
- Uploaded via:
twine/6.1.0 CPython/3.13.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
1164bc02277902741a5e9b2fd93f5f064195ba6e619e1fa4800c0dcd5ee61504
|
|
| MD5 |
f3890b4d18326f5adaba9333ba8708e3
|
|
| BLAKE2b-256 |
022e8ae53db45ade7d1467698ffcee97eaef62be33c07f1378f0602c34f83582
|
File details
Details for the file goldenmatch_hnsw-0.1.0-cp311-abi3-macosx_10_12_x86_64.whl.
File metadata
- Download URL: goldenmatch_hnsw-0.1.0-cp311-abi3-macosx_10_12_x86_64.whl
- Upload date:
- Size: 257.3 kB
- Tags: CPython 3.11+, macOS 10.12+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via:
twine/6.1.0 CPython/3.13.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
8d638f4df3a93b1df3f590e69d5776dcd1a35be15b83065ed1e474865c149eb7
|
|
| MD5 |
b35a307c4cf34855348ae635b895b534
|
|
| BLAKE2b-256 |
af02b88b6321c68c73d50a91229dd0b061d3e8ab0ba5e778f3aa378dfcaca831
|