Source-linked AI summary
Approximate Nearest Neighbor Search on High Dimensional Data --- Experiments, Analyses, and Improvement (v1.0)
Wen Li, Ying Zhang, Yifang Sun, Wei Wang, Wenjie Zhang, Xuemin Lin
TL;DR
High-dimensional ANNS is important, but exact search is costly and the literature lacks comprehensive, comparable evaluation. The paper benchmarks methods across diverse algorithms, datasets, measures, and workloads, then uses the analysis to develop DPG. Under sufficient memory and CPU resources, DPG and HNSW are recommended for robust search performance, while the study remains limited in dataset scale, sparsity, tuning completeness, and distance metrics.
Problem
High-dimensional exact nearest-neighbor search is costly, while many ANNS algorithms have been proposed without comprehensive cross-disciplinary evaluation.
Method
The paper comprehensively evaluates state-of-the-art ANNS algorithms and analyzes their performance to derive practical recommendations and engineer DPG.
Results
With sufficient computing and memory resources, DPG and HNSW are recommended for robust search performance across datasets, result quality, search time, and scalability.
Takeaways & Limitations
The study provides practical guidance for selecting ANNS methods under different settings and identifies Annoy as a trade-off between search performance, index size, and construction time.
Takeaways & Limitations
The study is limited to smaller datasets, dense data, incomplete tuning, and Euclidean distance, with larger, sparse, more exhaustively tuned, and other-metric evaluations left for future work.
Abstract
from arXiv · showhide
Approximate Nearest neighbor search (ANNS) is fundamental and essential operation in applications from many domains, such as databases, machine learning, multimedia, and computer vision. Although many algorithms have been continuously proposed in the literature in the above domains each year, there is no comprehensive evaluation and analysis of their performances. In this paper, we conduct a comprehensive experimental evaluation of many state-of-the-art methods for approximate nearest neighbor search. Our study (1) is cross-disciplinary (i.e., including 16 algorithms in different domains, and from practitioners) and (2) has evaluated a diverse range of settings, including 20 datasets, several evaluation metrics, and different query workloads. The experimental results are carefully reported and analyzed to understand the performance results. Furthermore, we propose a new method that achieves both high query efficiency and high recall empirically on majority of the datasets under a wide range of settings.
1. INTRODUCTION
ANNS addresses the high cost of exact nearest-neighbor search in high-dimensional data, motivating broad algorithmic work. This paper responds with a cross-disciplinary, comprehensive evaluation and practical recommendations, while introducing an empirically effective method.
- Motivation: Exact nearest-neighbor search becomes very costly in high-dimensional Euclidean space, while approximate search can remain efficient and practically useful.Exact methods can rarely outperform brute-force scanning above roughly 20 dimensions.
- Motivation: The study addresses limited systematic comparison across the many algorithms developed in different application domains.The authors identify hundreds of papers but few comprehensive comparisons.
- Motivation: Existing evaluations often use data-distributed query workloads, leaving performance under varied workloads insufficiently understood.The paper evaluates algorithms under a wide variety of settings and measures.
- Study design: The paper groups algorithms into LSH-based, space-partitioning, and neighborhood-based categories for intra- and inter-category analysis.The analyses examine methods’ strengths, weaknesses, dataset difficulty, and practical selection rules.
- Study design: The evaluation compares state-of-the-art methods across research areas using multiple measures, fairness-oriented implementation choices, and reproducible materials.All methods are tested on 20 datasets with hardware-specific optimizations disabled, and source materials are to be published.
- Contributions: The study’s contributions include comprehensive evaluation, rule-of-thumb method-selection guidance, and an empirically designed ANNS algorithm.The new algorithm is engineered from data-based analyses of existing methods.
2. BACKGROUND
The paper defines kNN search for Euclidean vectors and uses recall to measure approximate-result quality. Its focused comparison is motivated by the large, active literature and constrained to representative ANNS methods and Euclidean distance.
- Problem definition: The study considers d-dimensional vectors in R^d and Euclidean distance between query and reference points.Points and vectors are used interchangeably in the formulation.
- Problem definition: A kNN query returns k reference points no farther from the query than any excluded reference point.The definition requires the returned set to contain exactly k points.
- Evaluation: Recall measures the fraction of returned points that belong to the true kNN set.Some papers call this measure precision.
- Scope: The paper restricts its comparison to keep a comprehensive ANNS study focused despite hundreds of proposed algorithms across several literatures.The problem remains active because of both its importance and its challenges.
- Scope: Earlier benchmark studies differ in distance coverage, implementation practices, and overall comprehensiveness relative to this study.The paper emphasizes its larger coverage of algorithms and datasets and disables general implementation tricks.
3. LSH-BASED METHODS
LSH-based methods use hashing or projection to reduce high-dimensional search, with probabilistic guarantees or specialized query-aware and projection-based designs. Their methods target efficient candidate generation while preserving nearby points with varying assumptions.
- LSH: LSH maps high-dimensional points to lower-dimensional representations using random projections and provides probabilistic guarantees on quality, efficiency, and index size.The passage contrasts these guarantees with weaker empirical performance of data-independent methods.
- LSH: An LSH family increases collision probability for closer points and decreases it for points beyond a larger distance threshold.For Euclidean distance, Gaussian 2-stable projections can construct the family.
- Projection-based search: SRS projects data into at most 10 dimensions, retrieves projected-space candidates, and checks original distances with early termination.With constant projected dimension, its space and time complexities are linear in n and independent of d, with constant-probability c-ANN guarantees.
- Query-aware hashing: QALSH makes bucket partitioning query-aware so nearby objects are less likely to be separated into different buckets.It progressively locates farther objects using a range-search-like process.
4. ENCODING-BASED METHODS
Encoding-based methods preserve neighborhood or distance relationships through learned hash codes, graph structure, permutations, or multiple granularities. Their designs trade representation quality and search efficiency against scalability, local-density variation, and metric assumptions.
- Hashing: Unsupervised hashing methods learn compact codes from data distributions, including neighborhood-sensitive, selective, anchor-graph, scalable-graph, NAPP, and product-quantization approaches.These methods aim to make search in hash-code space resemble search in the original space.
- Anchor Graph Hashing: AGH uses local distances and anchor graphs to discover manifold neighborhood structure without requiring a global distance measure.Its approximate graph is constructed in O(n) time, is sparse, and approaches the true kNN graph as anchors increase.
- Scalable Graph Hashing: Graph hashing approximates neighborhood structure but can become memory- and time-consuming because it requires pairwise similarities across data points.For large datasets, approximation or subsampling is necessary, and its accuracy is not guaranteed.
- Scalable Graph Hashing: SGH avoids explicitly forming the similarity matrix by using feature transformation and sequential bit-wise learning to approximate it with hash codes.This avoids O(n^2) computation and storage costs.
- Neighborhood-sensitive hashing: Hashing methods are judged by how well Hamming distances preserve original kNN relationships, while NSH increases projection sensitivity for nearby points and stabilizes it farther away.The altered projection shape emphasizes close pairs rather than uniformly preserving all distances.
- Permutation methods: Permutation methods rank pivots by distance, retrieve candidates with similar permutations, and rerank them using the original distance.They can operate without metric properties, while NAPP indexes each point’s closest pivots for inverted-file retrieval.
- Selective Hashing: Selective Hashing addresses variable local search radii by storing each object in one of multiple LSH indices with different granularities.The selected granularity is intended to suit kNN searches near that object.
5. TREE-BASED SPACE PARTITION METHODS
Tree-based methods partition high-dimensional space hierarchically, using pivots, clusters, or randomized splits to organize approximate search. FLANN selects among tree and linear-scan alternatives by balancing search time, construction time, and memory.
- Tree-based methods hierarchically partition vector space using pivoting or compact schemes such as clusters, approximate Voronoi regions, and random divisions.
- FLANN: FLANN automatically selects randomized kd-trees, hierarchical k-means trees, or linear scan for a dataset.Its selection criterion combines search time, index-building time, and memory overhead.
- FLANN: Randomized kd-trees split data at mean-centered hyperplanes along randomly selected dimensions among the top five by sample variance, building multiple trees.
- FLANN: FLANN searches multiple randomized kd-trees with a heuristic-prioritized depth-first traversal, shared priority queue, and candidate result set.The scoring function favors child nodes closer to the query while maintaining lower-bound distances across trees.
- Annoy: Annoy’s latest version constructs multiple hierarchical 2-means trees by recursively partitioning samples using hyperplanes equidistant from two centers.Earlier versions used multiple random projection trees.
- VP-tree: VP-trees recursively partition points around a random pivot and median radius, using triangle-inequality pruning or a polynomial pruner during search.
6. NEIGHBORHOOD-BASED METHODS
Neighborhood-based methods retain proximity information in graphs and navigate those graphs with greedy heuristics. KGraph uses approximate k-NN graphs, Small World uses navigable long-range links, and HNSW organizes links across multiple length-scale layers.
- Neighborhood-based methods build indexes from point neighborhoods or pivot relationships, then navigate proximity graphs with greedy query heuristics.
- KGraph: KGraph constructs an approximate directed k-NN graph by iteratively comparing points with neighbors’ neighbors, then applies four optimizations to reduce redundant computation.Its greedy search starts from randomly chosen data points and maintains the current best candidates.
- Small World: Small World builds an undirected graph incrementally, adding edges from each incoming point to its closest graph neighbors; former short-range links become long-range links.
- Small World: Small World search performs several greedy subsearches from random nodes, expanding through unvisited neighbors until no point improves the current M nearest results.
- HNSW: HNSW separates graph links by length scale into multiple layers, with all points at the ground layer and fewer points at higher layers.
- HNSW: HNSW incrementally inserts points by greedy traversal from upper layers, then connects each point to M neighbors down through the ground layer; ef controls search quality.Searching is roughly equivalent to insertion for an item with maximum level m = 0, returning ground-layer neighbors.
- Rank cover tree: Rank cover tree avoids numerical constraints such as triangle inequality and searches hierarchically by retaining nodes most similar to the query at each level.
7. DIVERSIFIED PROXIMITY GRAPH
Diversified Proximity Graph improves neighborhood-graph design by combining neighbor distance with directional diversity and adding reverse edges. Its construction uses a greedy diversification heuristic, with K = 2κ typically giving the best empirical performance.
- DPG diversifies an existing K-NN graph and then adds reverse edges to construct a different neighborhood graph.
- Motivation: Considering only neighbor distances can miss useful search directions when close neighbors are clustered; angular dissimilarity instead favors broader coverage.In the toy example, replacing edge (p, a4) with (p, b) gives p a route toward q’s nearest neighbor.
- Motivation: Hubness can leave points with few incoming edges, isolating them and disconnecting clusters in high-dimensional K-NN graphs.
- Construction: DPG selects κ points from each K-NN list to maximize average angular separation, using a greedy heuristic because the optimization problem is NP-hard.The selected points receive both outgoing and reverse edges.
- Construction: K = 2κ is used for DPG construction because the empirical study found this setting usually achieves the best trade-off between diversity and proximity.The angular-similarity diversification process has time complexity O(κ^2Kn).
- Search: DPG uses the same search process as KGraph after its diversified graph has been constructed.
8. EXPERIMENTS
Experiments compare ANNS methods across datasets, operating points, index costs, and scalability. DPG and HNSW generally provide the strongest search performance, while method choice depends on accuracy, construction, memory, and dataset conditions.
- Category Evaluations: SRS consistently outperforms QALSH in speedup-recall evaluation and has an index at least 5 times smaller than QALSH.Speedup for these external-memory methods is measured using dataset pages divided by pages accessed.
- Category Evaluations: OPQ beats other encoding-based methods by a big margin on most datasets, while NSH usually has the smallest index size.OPQ remains competitive in construction time despite construction costs related to sub-codeword length and data dimensionality.
- Category Evaluations: Annoy and FLANN outperform VP-tree in search performance, so VP-tree is excluded from the next evaluation round.VP-tree also has almost the largest index time because it spends substantial time automatically tuning parameters.
- Category Evaluations: KGraph and HNSW substantially outperform SW and RCT, leading the study to select KGraph and HNSW as neighborhood-based representatives.RCT has the smallest index size, whereas KGraph and HNSW require relatively large construction times.
- Overall Evaluation: DPG and HNSW have the best overall search performance, with DPG especially improving KGraph on hard datasets and at higher recall.At recall 0.8, DPG is ranked after KGraph on three datasets but eventually surpasses KGraph at higher recall; DPG and HNSW also perform best across K values from 1 to 100.
- Scalability and Costs: DPG, KGraph, HNSW, and Annoy have the best search scalability as the dataset size grows, while DPG is more robust to increasing dimensionality than KGraph.DPG does not require large extra construction time for graph diversification compared with KGraph, and DPG, KGraph, and HNSW can build indexes within one hour for the reported settings.
- Summary: DPG and HNSW are recommended when memory and offline construction resources are sufficient, while Annoy offers a strong search-performance and index-cost trade-off.The paper attributes Annoy’s trade-off to reducing the number of trees without substantially hurting search performance.
9. FURTHER ANALYSES
The further analyses compare leading methods within space-partitioning and neighborhood-based families, identifying design choices associated with performance differences. They also examine difficult clustered datasets, reproducibility discrepancies, and implementation effects.
- Space Partitioning-based Methods: Annoy, FLANN, and OPQ perform best among the evaluated space partitioning-based methods, all using k-means space partitioning.
- Space Partitioning-based Methods: k-means achieves the best performance among directly compared partitioning schemes, while hierarchical k-means partitioning is identified as the most promising direction.The compared alternatives use 18,611 effective partitions.
- Neighborhood-based Methods: KGraph performs poorly on Yout and Gauss because well-separated clusters produce many disconnected components in its index.
- Neighborhood-based Methods: Cross-cluster edges in DPG and HNSW improve recall relative to KGraph when search entrance points do not lie in the query’s cluster.The paper attributes DPG’s cross-cluster links mainly to diversification and reverse edges.
- Neighborhood-based Methods: 60.38% of KGraph data points cannot reach a query kNN point on Yout, compared with 1.28% for DPG.On Gist, the corresponding percentages are 0.04% for KGraph and 0.005% for DPG.
- Evaluation and Reproducibility: Disabling hardware-specific optimizations changes relative rankings across evaluations while preserving greater focus on the algorithms’ underlying computational behavior.The disabled optimizations included SIMD, multithreading, prefetching, and compiler optimization options for different methods.
10. CONCLUSION AND FUTURE WORK
The study frames ANNS as a practical alternative to exact search in high-dimensional data and evaluates algorithms across varied settings. It reports parameter-dependent trade-offs, identifies strong methods, and acknowledges limitations in scale, data type, tuning completeness, and distance metrics.
- Conclusion: ANNS targets robust retrieval of most kNN points with a linear-size index while accessing only a small fraction of the data.The paper gives αn, such as 1%, as an example access budget.
- Future work: The study is limited by its evaluated scope and plans larger datasets, sparse high-dimensional data, more complete tuning, and additional distance metrics.It also states that understanding of high-dimensional real data remains inadequate.
- Conclusion: The study evaluates algorithms under varied settings, including different datasets, query workloads, and performance measures.The passages emphasize that changing parameters such as projection dimension, hashcode length, or verified-point count changes the speedup–recall trade-off.
- Conclusion: SRS improves as projection dimension m increases, with in-memory values from 8 to 10 providing a good trade-off.Higher m improves high-recall speedup, while moderate recall can yield faster search.
- Conclusion: 2-AGH outperforms 1-AGH on most datasets, while longer hashcodes generally improve performance.The comparison focuses on b = 64 and b = 128 after observing weaker results with shorter codes.
- Conclusion: Randomized kd-tree search improves with more trees, but speedup shows little increase beyond t = 8.This setting concerns the number of randomized kd-trees.
A.13 Flann
The Flann evaluations examine how build-time and memory weighting, tree parameters, and graph-style construction choices affect speedup–recall trade-offs. The reported settings expose distinct performance boundaries for KD-tree, hierarchical k-means, and related variants.
- Flann: When memory use receives greater weight, search speedup becomes very low and approaches linear scan.For medium-sized datasets or systems with enough memory, wm = 0 provides good search performance.
- Flann: A build-time weight of wb = 0.01 is selected because larger wb values produce substantially worse search performance.The choice prioritizes search while avoiding excessive build time.
- Small World: Small World offers good search trade-offs for most datasets when its construction parameter NN is 10 or 20.Small NN performs well at low recall but declines at high recall; construction time is roughly linear in NN.
- Hierarchical Navigable Small World: HNSW similarly favors small M for low recall but loses performance at high recall, leading the study to set M = 10 by default.efConstruction is fixed at 200 while efSearch is varied to control search quality.
A.17 KGraph
KGraph exposes index and search parameters that determine its search-quality trade-off. The evaluation finds that sufficiently large neighborhood connectivity is needed for most datasets.
- KGraph: KGraph uses IK, sample rate ρ, termination threshold ζ, and initial entry count P to control graph construction and search.The termination threshold represents tolerable recall loss from early termination, and the study uses ζ = 0.002.
- KGraph: Recall grows slowly beyond ρ = 0.5, while most datasets require K > 40 for the reported search trade-off.The passage identifies these trends while describing the impact of IK and ρ on performance.
A.18 DPG
DPG is tuned similarly to KGraph while matching its worst-case index size, and the study compares counting-based with angular-based diversification. Counting-based DPG achieves similar search performance with lower diversification time, especially on large datasets.
- DPG: DPG uses KGraph-like parameter tuning with κ = K^2 = 20 so its worst-case index size matches KGraph.The experiments otherwise use the same setting as KGraph.
- DPG: Counting-based DPG achieves similar search performance to angular-similarity-based DPG.The comparison is reported in Figure 38.
- DPG: Counting-based DPG spends less diversification time than angular-based DPG, with especially significant improvements on datasets containing many data points.Figure 39 compares the diversification times of the two variants.
- Evaluation settings: The second-round evaluation uses representative algorithms including SRS, OPQ, FLANN, Annoy, HNSW, KGraph, and DPG.The listed defaults include m = 8 for SRS, 50 trees for Annoy, M = 10 for HNSW, and K = 40 for KGraph.
B. SUPPLEMENT FOR THE SECOND ROUND EVALUATION
The second-round supplement presents diversification time between DPG and examines trade-offs between recall, speedup, and the percentage of data points accessed across remaining datasets.
- Figures 40 and 41 examine the trade-off between search quality, measured by recall, and search efficiency across the remaining datasets.Figure 40 uses speedup, while Figure 41 uses the percentage of data points accessed.
- The reported efficiency dimensions are speedup and the percentage of data points accessed.
- Figure 39 reports diversification time between DPG.