siann 1.0.0

Serve nearest-neighbor indexes built by the siann Python package (exact, IVF, CAGRA graphs) from Rust, on the CPU, with the same results
Documentation

siann (Rust)

Serve the nearest-neighbor indexes that the siann Python package builds: load the file index.save(path) wrote, and search it on the CPU from a Rust service, with the same neighbors, in the same order and with the same scores, as the Python package's own search on the CPU. Build and calibrate where building is fast (on a GPU, through siann's own builder, NVIDIA's cuVS or mlxvs on the Mac); serve the saved index on any machine.

let index = siann::Index::load("approx.siann")?;
let found = index.search(&queries, 10)?;      // queries: row by row, index.dim() values each
// found.ids, found.scores: queries x 10, best first; -1 where fewer than 10 were found
  • Methods: exact search, the IVF and CAGRA graphs, for L2, cosine, inner product, L1 and L-infinity; vectors stored as float32 or bytes (and, for the graph's search from 256 dimensions, float16 copies, as the file says), and the index's own ids.
  • The same choices as Python: each batch takes the CPU path the index measured fastest for its size when it was built, at the calibrated widths (nprobe, the graph's ef); search_with names a method and a width instead, or one path (Method::Path, Index::paths), as Python's search(path=...) does.
  • Scores are each metric's natural value: the distance for L2, L1 and L-infinity, the similarity for cosine and inner product.
  • Checked against Python: the Python package's tests save indexes of every kind and metric and compare this crate's results with index.search(..., device="cpu"), which must be identical (python/tests/test_rust_serving.py).

It needs Rust 1.88 or later. cargo run --release --example search -- index.siann loads a file and searches it. This crate is also the Python package's CPU engine (bound as siann._cpu by crates/siann-py); its other modules are internal.