Inverted file over k-means Voronoi cells. Cheap to build and easy to tune:
nlist sets how finely the space is cut, nprobe how many cells a query
visits. The smallest of the unquantised approximate indices. No Manhattan.
References
Sivic J, Zisserman A (2003). Video Google: a text retrieval approach to object matching in videos. Proceedings Ninth IEEE International Conference on Computer Vision, 1470-1477. doi:10.1109/ICCV.2003.1238663
Jégou H, Douze M, Schmid C (2011). Product quantization for nearest neighbor search. IEEE Transactions on Pattern Analysis and Machine Intelligence, 33, 117-128. doi:10.1109/TPAMI.2010.57
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 -> IvfIndex
Methods
Inherited methods
IvfIndex$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.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 <- IvfIndex$new(x)
idx$nprobe <- 10L
res <- idx$predict(x[1:5, ], k = 10L)
