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 = load?;
let found = index.search?; // 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 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_withnames a method and a width instead. - 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).
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.