siann
Nearest-neighbor search that decides how to search, on Apple silicon. Tell siann what you need, exact
neighbors or a recall target, for dense NumPy vectors by Euclidean (L2), cosine, inner product, Manhattan
(L1) or Chebyshev (L-infinity) distance. It chooses the method (exact search; an IVF, an index that
clusters the vectors and scans only the clusters nearest each query; or a graph, which links each vector to
near neighbors and walks the links; each calibrated to the target) and the device for each batch size (the
CPU or the Apple GPU) from measurements on your data and machine, says why in index.plan, and keeps
choosing as the index grows and changes.
Each path it chooses between is fast in its own right, through custom GPU kernels and CPU code laid out for the hardware (IMPLEMENTATION); where another library is faster, How it compares says so. Start with the quickstart notebook.
One query's 25 nearest points by Euclidean (L2), Manhattan (L1) and Chebyshev (L-infinity) distance.
Install
uv add siann # or: pip install siann
siann runs on Python 3.12 or later: on the CPU on Linux, macOS and Windows, and on the GPU too on Macs with
Apple silicon, where it installs MLX, Apple's array framework, for it.
Wheels (built packages) cover Linux on x86-64 and ARM, macOS on Apple silicon and Windows on x86-64. The
x86-64 wheels need a processor with AVX2 (Intel from 2013, AMD from 2015); on an older one, pip install --no-binary siann siann builds from source, which takes a Rust toolchain. On Linux and
Windows, import siann before NumPy (TUNING). For graph
searches on the Apple GPU, pip install siann[graph] adds mlxvs;
without it, siann builds its graphs itself and searches them on the CPU.
Python
import numpy as np
import siann
xb = np.random.default_rng(0).standard_normal((100_000, 128), dtype=np.float32)
xq = np.random.default_rng(1).standard_normal((1_000, 128), dtype=np.float32)
index = siann.Index(xb, metric="cosine") # exact; or "l2", "l1", "linf", "ip"
res = index.search(xq, k=10) # res.indices, res.scores: (1000, 10) each, best first
print(index.plan) # what siann chose, and why
approx = siann.Index(xb, metric="cosine", recall=0.95, calibration_queries=xq) # an IVF and a graph
ids = approx.add(xq) # add vectors; searches return their ids
approx.remove(ids[:10]) # remove them by id
approx.save("approx.siann") # siann.Index.load("approx.siann"), on any machine
grown = siann.Index(np.empty((0, 128), np.float32), metric="l2", recall=0.95) # start empty, grow by add()
Scores are each metric's natural value: the distance for L2 (not squared), L1 and L-infinity, the similarity
for cosine and inner product. Every choice can be overridden: device=, kind="exact", "ivf" or "graph",
nlist=, storage=, nprobe= for one search, gpu="torch" for PyTorch's MPS
backend (its Apple GPU backend) instead of MLX, and a profile from siann.tune for the routing
(TUNING).
What siann does for you
It takes a target, not settings. With recall=0.95, siann builds an IVF and a graph, finds how many
lists a query must probe and how wide a graph search must run to reach the target, and times every path,
exact search included, at each batch size. Calibrating on a sample of
your queries (calibration_queries=, or later index.calibrate()) makes the target hold on them
(TUNING).
One index uses both the CPU and the Apple GPU, each search sent where its batch size runs fastest on your data and machine: typically single queries and small batches to the graph on the CPU, large batches to the GPU, and exact search where it wins (TUNING).
Graphs on any machine, by any metric. siann builds its graphs itself where mlxvs is not installed, on Linux and Windows too, as good as mlxvs's and cuVS's; a saved index carries its graph to any machine; and L1 and L-infinity get graphs too, 6.2 times siann's IVF on SIFT1M by L1 at recall 0.95 (IMPLEMENTATION).
Every common metric is fast, L1 and L-infinity included, with kernels of their own on the GPU and in Rust on the CPU (IMPLEMENTATION).
The index keeps choosing as it changes. It can start empty, grow and shrink, keep ids of your own, and be searched from several threads while it changes; siann merges, recalibrates, re-clusters, and switches from exact search to an IVF once that is faster (IMPLEMENTATION).
It explains itself. index.plan lists each choice and the measurement behind it: method, nprobe and
the recall reached, storage, routes, memory, what changed since the build.
It is safe on unified memory. GPU searches stay within a memory budget, so a large batch cannot stall the Mac, and an index too large for the GPU stays on the CPU (IMPLEMENTATION).
How it compares
Measured on an Apple M3 Max: queries per second of siann's routed path divided by the other's, above 1 where siann is faster, with exact search returning the same neighbors and approximate search compared at matched recall. Against FAISS 1.16, Meta's similarity-search library, the standard on the CPU (its faster path, CPU or Metal GPU); and on the GPU against mlxvs 0.16.1, NVIDIA's cuVS GPU search methods ported to MLX. FAISS's HNSW, mlxvs's CAGRA and siann's own graph are graph indexes: each vector is linked to near neighbors, and a search walks the links, touching far fewer vectors than an IVF. siann's approximate rows are its routed path: its graph on the CPU or the GPU, or its IVF, whichever it measured faster for the batch. SIFT1M (image descriptors, L2), GloVe-100 (word embeddings, cosine), Music-100 (inner product) and DBpedia OpenAI embeddings (1,536 dimensions) favor different methods (DATASETS).
| Workload | Against FAISS | Against mlxvs |
|---|---|---|
| Exact, L1 or L-infinity | L1 18.5-25x, L-infinity 47-49x (its CPU; neither GPU library has these metrics) | |
| Exact, L2, cosine or inner product, batches of 100 | 2.7-2.9x (its GPU) | 2.6-3.8x in batches; 1.1-1.2x at 1,536 dimensions |
| Exact, batches of 10,000 | L2 and cosine 5.6-6.0x (its GPU), inner product 3.5x (its CPU) | |
| Approximate, single queries | SIFT 0.93x, Music-100 0.72x, GloVe 1.5-3.1x (HNSW, its fastest variant) | CAGRA on the GPU: SIFT and Music-100 10-14x |
| Approximate, batches of 100 | SIFT 0.96x, Music-100 0.90x, GloVe 1.2-1.8x (HNSW) | CAGRA: SIFT 0.78x, Music-100 0.86x, GloVe level |
| Approximate, batches of 9,000-10,000 | SIFT 3.1x, Music-100 2.8x, GloVe 5.0x (HNSW) | CAGRA: SIFT 0.86x, Music-100 0.94x, GloVe level |
| Approximate, 1,536 dimensions (a million vectors) | single queries 0.36x; batches of 100 3.9x, of 9,000 9.2x (HNSW) | CAGRA: single queries level, batches 0.64-0.95x |
FAISS's GPU IVF is no faster than its HNSW at matched recall in any case measured, so HNSW is FAISS's approximate method on the Mac. Without a GPU, siann's CPU path against FAISS's: exact L1 3.8-4.3x and L-infinity 7.3x, L2 and cosine 1.7-1.9x on 1,000 queries and 3.0-3.6x on 100, inner product 0.9-2.7x. On 4 Linux CPUs, with siann's index and graph built there, against FAISS's HNSW at single queries, batches of 10 and of 100: SIFT 1.16x, 0.84x, 0.99x; Music-100 0.78x, 0.94x, 1.78x. BENCHMARKS has the measurements behind each row and how to rerun them.
Documentation
| Document | What it covers |
|---|---|
| Quickstart notebook | Every feature, hands-on |
| IMPLEMENTATION | How siann chooses, the search methods, the kernels, where other libraries are faster |
| TUNING | What siann measures, on what, and how to measure it on your own queries, data and hardware |
| BENCHMARKS | Every measurement, with the scripts that reproduce them |
| BACKENDS | MLX, PyTorch MPS, FAISS and siann's Rust code: what each offers, and their pitfalls |
| DATASETS | SIFT1M, GloVe-100, Music-100, DBpedia OpenAI and Gaussian vectors |
| DEVELOPMENT | Building, testing, releasing, the rules for changing the code, and the ideas that do not pay |
| API reference | Every public class, method and function |
These pages are also at siann.readthedocs.io.
License
MIT (LICENSE)
Metadata
Release files for siann 0.4.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| siann-0.4.0.tar.gz | 96.5 kB | With provenance | Details for siann-0.4.0.tar.gz |
Built distributions (wheels)
| File | Actions Reset | |||
|---|---|---|---|---|
| siann-0.4.0-cp312-abi3-win_amd64.whl | CPython 3.12 | abi3 | Windows x86-64 | Details for siann-0.4.0-cp312-abi3-win_amd64.whl |
| siann-0.4.0-cp312-abi3-manylinux2014_x86_64.manylinux_2_17_x86_64.whl | CPython 3.12 | abi3 | Linux glibc 2.17+ x86-64 | Details for siann-0.4.0-cp312-abi3-manylinux2014_x86_64.manylinux_2_17_x86_64.whl |
| siann-0.4.0-cp312-abi3-manylinux2014_aarch64.manylinux_2_17_aarch64.whl | CPython 3.12 | abi3 | Linux glibc 2.17+ ARM64 | Details for siann-0.4.0-cp312-abi3-manylinux2014_aarch64.manylinux_2_17_aarch64.whl |
| siann-0.4.0-cp312-abi3-macosx_11_0_arm64.whl | CPython 3.12 | abi3 | macOS 11.0+ ARM64 | Details for siann-0.4.0-cp312-abi3-macosx_11_0_arm64.whl |
Total release size: 2.8 MB
Release files / siann-0.4.0.tar.gz
| Download URL | siann-0.4.0.tar.gz |
|---|---|
| Size | 96.5 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
6f0d0d7d38d1ec4f5a80c607f592c5c25d3c12a1b056a29ea82b1b4646c3100c
|
|
BLAKE2b-256 checksum How to use checksums |
008e1463469ea92e636d34b31567e09415d18bb1012035f6f9495900fe7c9b37
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 26, 2026.
Transparency logRelease files / siann-0.4.0-cp312-abi3-win_amd64.whl
| Download URL | siann-0.4.0-cp312-abi3-win_amd64.whl |
|---|---|
| Size | 635.0 kB |
| Tags | CPython 3.12 Windows x86-64 abi3 |
|
SHA-256 checksum How to use checksums |
19a074f78b49422e8ea4f5e523fea018de9ee2039469a9ed82e92dde39c42a62
|
|
BLAKE2b-256 checksum How to use checksums |
a66a51dd98c026c5a6d1393ca2b436e21fd739a1b050a9e31121a85746b393d6
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 26, 2026.
Transparency logRelease files / siann-0.4.0-cp312-abi3-manylinux2014_x86_64.manylinux_2_17_x86_64.whl
| Download URL | siann-0.4.0-cp312-abi3-manylinux2014_x86_64.manylinux_2_17_x86_64.whl |
|---|---|
| Size | 751.4 kB |
| Tags | CPython 3.12 Linux glibc 2.17+ x86-64 abi3 |
|
SHA-256 checksum How to use checksums |
f91d15ea5b94f004fc4c0b72920427d99fbf50086b86e0a638fa24f2ce83eb5a
|
|
BLAKE2b-256 checksum How to use checksums |
8e8e3a2cdd862693aa4e067513e2e7164241b14db8742bf0432e12afe04ef76e
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 26, 2026.
Transparency logRelease files / siann-0.4.0-cp312-abi3-manylinux2014_aarch64.manylinux_2_17_aarch64.whl
| Download URL | siann-0.4.0-cp312-abi3-manylinux2014_aarch64.manylinux_2_17_aarch64.whl |
|---|---|
| Size | 703.1 kB |
| Tags | CPython 3.12 Linux glibc 2.17+ ARM64 abi3 |
|
SHA-256 checksum How to use checksums |
a1dceb1822c22b7f8f02905bcfb86d4fb58df7ce45faf9625d0b397a5522a671
|
|
BLAKE2b-256 checksum How to use checksums |
fff19bb85f83444bf25dc1d9e4fa5a5beca18eb64f599f0b846af253c4901c16
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 26, 2026.
Transparency logRelease files / siann-0.4.0-cp312-abi3-macosx_11_0_arm64.whl
| Download URL | siann-0.4.0-cp312-abi3-macosx_11_0_arm64.whl |
|---|---|
| Size | 662.8 kB |
| Tags | CPython 3.12 abi3 macOS 11.0+ ARM64 |
|
SHA-256 checksum How to use checksums |
b3491a9751dd29387f4a04f9a9f4b2d66a692aaab06d295348518d3b1a444e06
|
|
BLAKE2b-256 checksum How to use checksums |
f385e8ff5d8d320aa8f6c20cc26a48ff7a32d6dcb30bb8d1a74c25bb08b01951
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 26, 2026.
Transparency logSecurity for siann 0.4.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
Full provenance
All 5 files in this release have been uploaded with provenance metadata.
Attestation for siann-0.4.0.tar.gz
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 26, 2026.
Transparency logA note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.