OOD-DiskANN: Efficient and Scalable Graph ANNS for Out-of-Distribution Queries

Shikhar Jaiswal, Ravishankar Krishnaswamy, Ankit Garg, Harsha Vardhan Simhadri, Sheshansh AgrawalarXiv 2022 · DOI

Abstract

Approximate Nearest Neighbor Search (ANNS) algorithms like DiskANN and HNSW are highly optimized for the distribution of the data they index. However, in cross-modal scenarios where queries are Out-of-Distribution (OOD)—such as using text to search for images—performance often collapses. We present OOD-DiskANN, a system that utilizes a small sample of expected queries to construct more robust graph indices. By introducing RobustVamana for graph construction, Accurate Product Quantization (APQ) for distance estimation, and ParallelGorder for disk I/O optimization, OOD-DiskANN achieves up to 40% better latency and 15% higher recall on billion-scale datasets.

Introduction: The OOD Performance Gap

Approximate Nearest Neighbor Search (ANNS) is a critical component of modern AI, powering large-scale image search and recommendation engines. While state-of-the-art graph-based indices are incredibly fast, they are often "overfit" to the distribution of the points they store. When queries originate from a different distribution (OOD), the search algorithm's efficiency plummets.

Latency vs. Recall for 10M scale datasets showing the performance gap between ID and OOD queries.

As shown in the figure above, across various popular algorithms like FAISS-IVF, HNSW, and Vamana (DiskANN), there is a significant gap in query efficiency between In-Distribution (ID) and OOD queries. For OOD queries, latency can be an order of magnitude worse than for ID queries, as the search algorithm frequently gets lost in the graph or suffers from inaccurate distance estimates.

Methodology

OOD-DiskANN introduces three key techniques to bridge this performance gap, leveraging a small sample (approximately 1% of the dataset size) of representative OOD queries during the indexing phase.

  1. RobustVamana: Standard graph indices are built by connecting base points to their neighbors. RobustVamana incorporates OOD query samples into the graph-building process to identify "cross-links" between base points that are frequently visited by OOD queries. These connections are stitched into the graph, improving navigability for future OOD queries even after the samples are removed.
  2. Accurate Product Quantization (APQ): Standard Product Quantization (PQ) minimizes reconstruction error, which the authors prove is the wrong metric for OOD queries. APQ instead optimizes a new loss function that minimizes distortion in relative distances between queries and base points, ensuring that the true nearest neighbors are correctly ranked even after compression.
  3. ParallelGorder: To address the bottleneck of SSD I/O requests, ParallelGorder reorders how nodes are stored on disk. It packs nodes likely to be accessed together into the same 4KB disk sector, reducing the total number of disk accesses required per query.

Key Insights: Why OOD Queries are Hard

The fundamental challenge with OOD queries is two-fold: connectivity and quantization misalignment. The authors discovered that the true nearest neighbors for OOD queries are often poorly connected in standard graphs, leading greedy search algorithms into local minima.

10-NN Cluster Radius for ID and OOD queries across three datasets.

Furthermore, because OOD queries are far from the primary data clusters, the mathematical errors in standard query-oblivious compression (like PQ or OPQ) are amplified. As illustrated in the cluster radius analysis, OOD queries typically have larger 10-NN radii, indicating they reside in sparser regions where distance estimation accuracy is even more critical.

Experimental Results

The authors evaluated OOD-DiskANN on massive datasets, including the 2.4 billion point Web Ads dataset and the 1 billion point Yandex Text-to-Image (T2I) dataset. Key findings include:

  • Efficiency: OOD-DiskANN provides up to a 40% improvement in mean query latency for the same recall target compared to standard DiskANN.
  • Recall: At equivalent latency levels, it improves recall by up to 15%.
  • I/O Optimization: ParallelGorder reduced SSD I/O requests by 15-40%, contributing to a 10-25% overall latency improvement.
  • Scalability: The system successfully managed indices with over 2 billion points, demonstrating its readiness for industrial-scale applications.

Limitations and Future Work

While highly effective, OOD-DiskANN introduces a small disk space overhead (roughly 400 bytes per base point for APQ metadata) and requires longer training times than standard k-means. Most importantly, it relies on having a sample of OOD queries beforehand. Future research may focus on online adaptations that can adjust to shifting query distributions in real-time without prior samples.

Summary updated

BibTeX
@misc{jaiswal2022ood,
  author = {Shikhar Jaiswal and Ravishankar Krishnaswamy and Ankit Garg and Harsha Vardhan Simhadri and Sheshansh Agrawal},
  title = {{OOD-DiskANN: Efficient and Scalable Graph ANNS for Out-of-Distribution Queries}},
  year = {2022},
  eprint = {2211.12850},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2211.12850},
}
Figure