IVF with spilling: every point also lands in a second cell, picked by a rule
that accounts for the residual it carries in its first. Buys recall at a
given nprobe over IvfIndex, but scans about twice the candidates per
probe, so compare the two on query time, not on nprobe. No Manhattan.
References
Sun P, Simcha D, Dopson D, Guo R, Kumar S (2023). SOAR: improved indexing for approximate nearest neighbor search. Advances in Neural Information Processing Systems, 36, 3189-3204. https://arxiv.org/abs/2404.00774
Super class
AnnIndex -> SoarIndex
Methods
Inherited methods
SoarIndex$new()
Build the index.
Arguments
dataNumeric matrix or data.frame. Samples x features. An index pointer is also accepted;
load_ann_index()uses that path.metricString. One of
c("euclidean", "sqeuclidean", "cosine").nlistInteger or
NULL. Number of Voronoi cells.NULLusessqrt(n).nprobeInteger or
NULL. Cells visited per query.NULLusessqrt(nlist). Can be changed after the build.ruleString or
NULL. Secondary assignment rule, one ofc("nearest", "shifted", "orthogonal").NULLpicks orthogonal for cosine and shifted otherwise.rule_paramNumeric or
NULL.mufor the shifted rule,lambdafor the orthogonal one.NULLuses 0.5 and 1.0 respectively.kmeans_itersInteger or
NULL. Lloyd iterations.NULLuses 30.kmeans_balancedBoolean. Reseed starved centroids each iteration.
seedInteger. Fixes the k-means initialisation.
precisionString.
"float"stores the data as f32,"double"as f64..verboseBoolean. Print build progress from Rust.
Examples
x <- generate_clustered_data(1000L, 16L)$data
idx <- SoarIndex$new(x)
res <- idx$predict(x[1:5, ], k = 10L)
