Effective and General Distance Computation for Approximate Nearest Neighbor Search

Mingyu Yang, Wentao Li, Jiabao Jin, X. Zhong, Xiangyu Wang, Zhitao Shen, Wei Jia, Wei WangarXiv 2024

TL;DR

This paper introduces a novel approach to accelerate Approximate K Nearest Neighbor (AKNN) search by improving distance computation. They propose using Principal Component Analysis (PCA) for more effective distance estimation and a data-driven method for distance correction, making it more general and outperforming existing methods like ADSampling by up to 2.1x speedup with higher accuracy.

What Problem Does This Paper Address?

Finding the K nearest neighbors (KNN) to a query point in high-dimensional datasets is a fundamental task in many fields, from recommendation systems to image retrieval. However, the "curse of dimensionality" makes exact KNN search computationally prohibitive for large, high-dimensional datasets. Approximate KNN (AKNN) search offers a trade-off between accuracy and speed, but its performance is heavily bottlenecked by the time it takes to compute distances between points. Existing methods like ADSampling use approximate distances to speed things up but often sacrifice accuracy. ADSampling, in particular, relies on random projections for distance approximation and error bounding, which limits its effectiveness and generality. This paper aims to address these limitations by developing more accurate and versatile distance computation techniques for AKNN search.

Methods

The authors propose two main improvements over existing methods, particularly ADSampling:

  • More Effective Distance Estimation (DDCres): Instead of random projections, they leverage Principal Component Analysis (PCA) for dimensionality reduction. PCA is shown to maximize projection variance and minimize residual variance, leading to more accurate approximate distances compared to random projections. They also derive new error bounds based on the Gaussian distribution of estimation errors.
  • More General Distance Correction (DDCpca, DDCopq, DDCres): They introduce a data-driven distance correction scheme that is agnostic to the specific method used for approximate distance estimation. This means it can work with various techniques, including projection-based methods (like PCA) and quantization-based methods (like Optimized Product Quantization - OPQ). This scheme learns a correction parameter from the data, effectively creating a "learned decision boundary" to decide whether a candidate point can be pruned early.

They also propose an incremental version of their method (Incremental-DDCres) that progressively increases the projected dimensions, allowing for early termination and further efficiency gains.

Datasets

The authors evaluated their methods on eight publicly available datasets:

  • MSONG (Audio)
  • GIST (Image)
  • DEEP (Image)
  • WORD2VEC (Text)
  • GLOVE (Text)
  • TINY5M (Image)
  • TINY80M (Image)
  • SIFT100M (Image)

These datasets vary in scale and dimensionality, ranging from 96 to 960 dimensions and from 100,000 to over 79 million data points. They also mention conducting experiments on a private dataset from Ant Group for facial image search.

Key Insights and Ideas

  • PCA is superior to random projection for distance estimation: By analyzing the variance of estimation errors, the authors demonstrate that PCA-based projections capture more information and lead to significantly smaller errors than random projections, improving the effectiveness of AKNN.
  • Data-driven correction offers generality: The core idea of treating the error bound as a learnable parameter, rather than being fixed by the projection method, is a significant step towards a universal distance correction mechanism. This allows the method to adapt to various approximate distance computations.
  • Balancing accuracy and efficiency through learned boundaries: The data-driven approach allows for tuning a "recall target," enabling a trade-off between pruning more aggressively (higher efficiency) and retaining more candidates (higher accuracy), which can be crucial in real-world applications.
  • Orthogonal projection enables incremental refinement: The property of orthogonal projections allows for a step-by-step increase in dimensions, providing opportunities for early stopping and further optimization.

Key Results

  • Speedup: The proposed methods achieve a speedup of 1.6 to 2.1 times compared to ADSampling on real-world datasets.
  • Accuracy: The methods provide higher accuracy than ADSampling.
  • Efficiency: DDCres achieves a 2x speedup over HNSW and a 1.45x speedup over ADSampling on the TINY80M dataset.
  • Pruning Rate: The proposed methods achieve a higher pruned rate, indicating better efficiency in eliminating irrelevant candidates.
  • Ant Group Application: The DDCopq method was integrated into Ant Group's search engine, reducing retrieval time by 35% and increasing throughput by 55.25% for facial image search without sacrificing accuracy.

Limitations and Future Work

  • Out-of-Distribution (OOD) Queries: The paper acknowledges that OOD queries can pose a challenge, particularly for the data-driven methods (DDCopq and DDCpca) that rely on training data. While they suggest retraining the model with OOD queries can mitigate this, it's an area for further improvement.
  • Pre-processing Time: While the proposed methods have lower pre-processing costs than indexing in HNSW/IVF, the training of linear models for DDCpca and DDCopq does add to this cost, especially for very large datasets.
  • Future Work: The authors suggest exploring advanced methods for distance computation to further refine efficiency. They also mention that the choice between PCA-based and quantization-based methods can be guided by the variance skewness of the dataset, implying potential for adaptive method selection.

Summary updated

BibTeX
@misc{yang2024effective,
  author = {Mingyu Yang and Wentao Li and Jiabao Jin and X. Zhong and Xiangyu Wang and Zhitao Shen and Wei Jia and Wei Wang},
  title = {{Effective and General Distance Computation for Approximate Nearest Neighbor Search}},
  year = {2024},
  eprint = {2404.16322},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2404.16322},
}
Figure