Expand description
Serving indexes that the siann Python package built: load the file
index.save(path) wrote, and search it on the CPU from Rust, with the same neighbors, in the same order, as
the Python package’s search on the CPU. Build and calibrate where building is fast (a GPU, through siann’s
own builder, NVIDIA’s cuVS or mlxvs); serve the saved index from a Rust service on any machine.
let index = siann::Index::load("approx.siann")?;
let queries = vec![0.0f32; 10 * index.dim()]; // ten queries, row by row
let found = index.search(&queries, 10)?; // each query's 10 nearest
println!("{:?} {:?}", &found.ids[..10], &found.scores[..10]);Exact search, the IVF and CAGRA graphs, for L2, cosine, inner product, L1 and L-infinity; each batch takes
the path the index measured fastest on the CPU for its size, at the calibrated widths, unless
Index::search_with names one. Scores are each metric’s natural value (the distance for L2, L1 and
L-infinity; the similarity for cosine and inner product). The same code is the Python package’s CPU engine;
its other modules are internal.
Structs§
- Error
- An error loading or searching an index.
- Index
- An index searched on the CPU: loaded from a file the siann Python package saved, or built from its parts.
- Neighbors
- Each query’s k nearest:
idsandscores, row-major (queries * k), best first; -1 and the metric’s worst score (infinity for a distance, minus infinity for a similarity) where fewer than k were found.
Enums§
- Method
- How a search runs: as the index routes its batch size on the CPU (
Auto), or by one method. - Search
Path - A search path on the CPU, as the Python package names them in
index.pathsand takes them insearch(path=...): exact search (“cpu-exact”), the graph (“cpu-graph”), and the IVF’s scans, which find the same neighbors by different loops: query-major (“cpu-query”), query-major with each query’s lists found through BLAS (“cpu-query-blas”), a single query split over 4 threads (“cpu-split”), list-major (“cpu-list”).