Graph-based Nearest Neighbor Search: From Practice to Theory

Liudmila Prokhorenkova

Introduction

Graph-based Nearest Neighbor Search (NNS) algorithms, such as Hierarchical Navigable Small World (HNSW), have become the industry standard for high-performance vector search. Despite their empirical dominance, theoretical understanding has largely been confined to "sparse" high-dimensional regimes where the dimension $d$ is large relative to the number of points $n$. This paper, presented at ICML 2020, addresses this gap by analyzing the "dense" regime ($d \ll \log n$), providing a rigorous foundation for why heuristics like long-range "shortcut" edges and beam search are so effective.

The Challenge of the Dense Regime

In NNS, the goal is to find the point in a dataset $\mathcal{D}$ closest to a query $q$. Graph-based methods construct a network of data points and navigate it via greedy walks. However, in the dense regime—which characterizes many real-world datasets with low intrinsic dimensionality—greedy search can be slow, requiring $O(n^{1/d})$ steps, and is prone to getting trapped in local optima.

Graph search visualization: A greedy walk approaches query $q$, highlighting the risk of getting stuck in a local optimum ('lo') instead of reaching the true nearest neighbor ('nn').

The authors propose and analyze three key enhancements to the basic $k$-NN graph search:

  1. Rank-based Shortcuts: Inspired by Kleinberg’s small-world models, the authors introduce long-range edges. Crucially, they propose a dimension-free distribution based on neighbor rank rather than absolute distance. This allows the method to scale effectively even when the intrinsic dimension is unknown.
  2. Beam Search: Instead of a simple greedy walk, beam search maintains a set of $L$ candidates. The paper formally proves that this strategy helps bypass local optima and allows the graph to maintain a much lower degree (fewer edges per node) without sacrificing accuracy.
  3. Uniformization (DIM-RED): By applying dimensionality reduction and densification, real-world datasets can be made to behave more like the theoretical uniform models, improving the performance of simpler graph structures.

Key Results and Empirical Validation

The theoretical analysis demonstrates that adding just $\Theta(\log n)$ properly distributed long-range edges reduces the search complexity from polynomial to $O(\log^2 n)$.

Empirical tests on synthetic datasets (points on $d$-dimensional spheres) and real-world benchmarks (SIFT, GIST, GloVe) confirm these findings. As shown in the performance plots, the combination of Kleinberg-inspired (KI) shortcuts and beam search drastically reduces the number of distance calculations needed to achieve high recall, especially as the dimensionality increases.

Performance comparison for $d=4$ and $d=16$. The combination of beam search and shortcuts (purple diamonds) consistently outperforms basic kNN (blue circles) by reducing distance calculations for the same error rate.

For instance, in $d=16$ synthetic data, beam search allowed for a reduction in graph degree from 2000 to 20 while maintaining equivalent recall. This highlights beam search's role as a powerful "degree-reducer," enabling faster overall search times.

Conclusion

This work provides the first rigorous theoretical analysis of graph-based NNS in the dense regime. By proving the efficiency of rank-based shortcuts and the degree-reducing power of beam search, the authors bridge the gap between practice and theory. While the current model assumes uniform data distributions, it sets the stage for future work on non-uniform data and more complex graph diversification heuristics.

Summary updated

BibTeX
@inproceedings{prokhorenkova2020graph,
  author = {Liudmila Prokhorenkova},
  title = {{Graph-based Nearest Neighbor Search: From Practice to Theory}},
  booktitle = {International Conference on Machine Learning},
  year = {2020},
  url = {https://openreview.net/forum?id=XpmpLVyhkpO},
}
Figure