Manuscript Offprint

arXiv:2611.26609

Variants of Beam Search for DiskANN

Viraj Agrawal, Kirankumar Shiragur

Open access. PaperVantage converted this article to text, so layout and figures may differ from the original. This text is shared under the same licence.

Abstract

Graph-based data structures such as DiskANN, HNSW, and NSG constitute the state of the art for large-scale approximate nearest-neighbor (ANN) search. Indyk and Xu [13] introduced the notion of α\alpha-reachable graphs, which include graphs built by DiskANN’s slow-preprocessing construction, and proved that greedy search achieves an approximation factor of α+1α−1\tfrac{\alpha+1}{\alpha-1}. Independently, Al-Jazzazi et al. [1] proposed adaptive beam search (ABS) with a relaxation parameter γ>0\gamma>0, showing a 2γ\tfrac{2}{\gamma} approximation on navigable graphs (α≈1\alpha\approx 1), where greedy search admits no guarantees. In this work, we unify and generalize these results by proving that ABS with parameter γ\gamma on α\alpha-reachable graphs achieves an approximation of α+1α(γ+1)−1\tfrac{\alpha+1}{\alpha(\gamma+1)-1} for any metric. Moreover, on sorted α\alpha-reachable graphs (introduced by Gollapudi et al. [10]) under the ℓ2\ell_{2} metric, we obtain the tighter bound max⁡(αα(γ+1)−1,α2+1α2(γ+1)−1)\max\bigl(\tfrac{\alpha}{\alpha(\gamma+1)-1},\tfrac{\alpha^{2}+1}{\alpha^{2}(\gamma+1)-1}\bigr). Beyond these theoretical results, we design a beam predictor using features inspired by fine-grained analysis of ABS, trained via a constrained objective that minimizes mean distance computations subject to a target recall. On three 100-million-point benchmarks, using graphs built by DiskANN’s practical construction, beam predictor lowers mean query latency on SSD-resident indices at matched recall by up to 29.6%29.6\% relative to classical beam search (CBS). Relative to ABS, it is faster in 1111 of 1515 settings, by up to 6.5%6.5\%, and at most 1.4%1.4\% slower in the other 44; at 95%95\% recall, its advantage over ABS grows from 0.80.8–4.2%4.2\% for 100100 neighbors to 4.64.6–5.6%5.6\% for 500500 neighbors. In memory, it needs 1.31.3–23.7%23.7\% fewer distance computations than CBS and 0.00.0–3.9%3.9\% fewer than ABS.

1 Introduction

Nearest neighbor search is a fundamental problem in data structures, with applications in search, recommendation systems and, more recently, retrieval-augmented generation (RAG). Given a dataset of nn vectors and a query vector qq, the goal is to retrieve the kk data vectors nearest to qq. Since exact search typically takes linear time in nn in high dimensions, much research has focused on approximate nearest neighbor (ANN) search: data structures and algorithms that efficiently return high-quality approximate answers. Early work on ANN search targeted modest datasets—millions of points in tens of dimensions—and produced a rich line of space-partitioning techniques, including locality-sensitive hashing [12, 2], KD-trees [3] and cover trees [5]. These methods scale poorly with the dimension: tree-based partitions must examine a number of cells that grows exponentially with it, and hashing needs many hash tables to reach high recall. To avoid this curse of dimensionality, more recent work has turned to graph-based indices such as DiskANN [16], HNSW [20], NSG [9] and NGT [15, 27, 14], which have become the dominant approach in practice due to their strong empirical performance.

Despite this empirical success, the theoretical understanding of graph-based methods remained limited until the recent work of Indyk and Xu [13], who introduced a family of graphs called α\alpha-reachable graphs (α>1\alpha>1). This family includes the graphs built by DiskANN’s slow preprocessing, and the authors showed that a simple greedy search on such graphs converges to a local optimum whose distance to the query qq is at most α+1α−1\tfrac{\alpha+1}{\alpha-1} times the true nearest-neighbor distance. Subsequently, Gollapudi et al. [10] extended this analysis to the widely used classical beam search (CBS), showing the same α+1α−1\tfrac{\alpha+1}{\alpha-1} approximation guarantee for all elements maintained in the beam. In addition, they showed that DiskANN’s RobustPrune procedure produces a special class of sorted α\alpha-reachable graphs, and proved that under the ℓ2\ell_{2} metric these graphs admit the sharper approximation bound of αα−1\tfrac{\alpha}{\alpha-1}. Complementing these works, Al-Jazzazi et al. [1] proposed a modified search procedure called adaptive beam search (ABS), parameterized by γ>0\gamma>0, which delays termination to enable additional exploration. They proved a 2γ\tfrac{2}{\gamma}-approximation guarantee on navigable graphs—corresponding in our terminology to the regime α≈1\alpha\approx 1—where classical beam search does not admit any provable guarantees.

Given these two extremes—classical beam search on α\alpha-reachable graphs (α>1,γ=0)(\alpha>1,\gamma=0) and adaptive beam search on navigable graphs (α≈1,γ>0)(\alpha\approx 1,\gamma>0)—it is natural to ask the following questions.

Q1. What approximation guarantee can adaptive beam search, parameterized by γ≥0\gamma\geq 0, achieve on α\alpha-reachable graphs with α>1\alpha>1?

Q2. Can the improved ℓ2\ell_{2}-metric guarantee of Gollapudi et al. [10] be combined with adaptive beam search?

References (32)