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
Bessa S, Mazaré P-E, Szilvasy G, Touvron H, Picard D, Douze M, Jégou H (2026). e-means: outperforming k-means (in one-tenth the epochs). arXiv. https://arxiv.org/abs/2611.09501
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.NULLtrains the centroids with e-means at its own epoch budget. An integer switches to Lloyd's with that many iterations.kmeans_balancedBoolean. Reseed starved centroids each iteration. Only affects Lloyd's k-means, i.e. when
kmeans_itersis set. Ignored otherwise: e-means, the default, has no balancing option.seedInteger. Fixes the k-means initialisation.
precisionString.
"float"stores the data as f32,"double"as f64..verboseBoolean or integer. Build progress from Rust:
0orFALSEsilent,1orTRUEprogress,2adds timed build stages.
Examples
x <- generate_clustered_data(1000L, 16L)$data
idx <- SoarIndex$new(x)
res <- idx$predict(x[1:5, ], k = 10L)
