Fast k-Nearest Neighbour Search via Dynamic Continuous Indexing

Ke Li, Jitendra Malik

Introduction

Finding the $k$-nearest neighbors ($k$-NN) of a query point is a foundational task in machine learning, but it notoriously suffers from the "curse of dimensionality." Most existing algorithms rely on space partitioning—dividing the vector space into discrete cells, such as with k-d trees or Locality-Sensitive Hashing (LSH).

As dimensionality increases, the volume of these cells grows exponentially, leading to two major failures:

  1. Efficiency: Algorithms require either an exponential number of cells or cells so large they contain too many points to search efficiently.
  2. Accuracy: If a query falls near a cell boundary, its true neighbors might reside in an adjacent cell and never be retrieved.

To overcome these limitations, the authors introduce Dynamic Continuous Indexing (DCI), a novel randomized algorithm that abandons discrete space-partitioning. By leveraging multiple 1D random projections and a clever statistical stopping condition, DCI achieves high-speed retrieval with significantly lower memory overhead than LSH, scaling linearly with ambient dimensionality.

How Dynamic Continuous Indexing Works

DCI replaces discrete cells with continuous indices. The core approach unfolds in several steps:

  1. Random Projections: The algorithm projects $d$-dimensional data points onto $m$ random unit vectors. Each projection creates a "simple index" where points are continuously sorted by their 1D position.
  2. Composite Indices: To reduce the chance of distant points appearing close by mere fluke, $m$ simple indices are grouped into a "composite index." A point only becomes a candidate for the final $k$-NN list if it appears close to the query across all $m$ simple indices within that group.
  3. Multiple Groups: The algorithm maintains $L$ such composite indices to ensure a high probability of success.
Geometric intuition of DCI projections

During a query, DCI iterates through the sorted 1D indices, moving outward from the query's projected position. The algorithm can run in a data-independent mode (stopping after a fixed number of iterations) or a data-dependent mode. The latter uses a statistical hypothesis test to decide when to stop, calculating the probability that a true neighbor hasn't been seen yet based on current candidate distances. It terminates when that probability falls below a threshold ($\epsilon$).

Key Insights

  • Order Preservation over Distance Preservation: Unlike the Johnson-Lindenstrauss transform, which aims to preserve all pairwise distances, DCI relies on the fact that 1D projections are surprisingly good at preserving the relative order of points. If point A is much closer to the query than point B, it is highly likely to remain closer in a random 1D projection.
  • Avoiding the "Boundary Problem": Because DCI doesn't use fixed bins or cells, it avoids the "near-miss" errors that occur when a neighbor is just across a partition line. It simply evaluates the next closest point in the continuous 1D sorted list.
  • Inferring the Unseen: The data-dependent stopping condition is a major breakthrough. By treating the random projections as independent trials, the authors use the distances of retrieved candidates to mathematically bound the probability that a closer, unretrieved point exists. This allows the algorithm to adapt to local data density on the fly.

Empirical Results

The authors evaluated DCI against Exact Euclidean LSH (E2LSH) using two high-dimensional image datasets: CIFAR-100 (3,072-dimensional vectors) and MNIST (784-dimensional vectors). These datasets contain varying levels of data density, with MNIST being particularly "clustered" and historically difficult for LSH.

Performance and Memory Comparison: DCI vs LSH
  • Speed (Candidate Reduction): DCI required 61.3% to 78.7% fewer candidate points than LSH to achieve the same level of approximation quality. Since distance calculations on candidates dominate query time, this represents a massive speedup.
  • Memory Efficiency: DCI is incredibly lean, using less than 1/20th of the memory required by LSH. LSH requires many large hash tables, whereas DCI only stores simple sorted lists and projection vectors.
  • Robustness to Density: On the MNIST dataset, where LSH performance typically degrades due to dense clusters, DCI maintained superior performance, demonstrating its ability to adapt to varying data distributions.

Limitations and Future Work

While DCI is more robust than LSH, it still requires parameter tuning for $m$ (number of simple indices per composite) and $L$ (number of composite indices). Although the authors found good values empirically, an automated way to set these based on a dataset's intrinsic dimensionality would be beneficial. Furthermore, while DCI scales linearly with ambient dimension, its performance still depends on the intrinsic dimensionality of the data; highly complex, "thick" manifolds will eventually challenge any $k$-NN algorithm. Finally, scaling to billions of points will require highly cache-optimized implementations of the underlying search trees or skip lists.

Summary updated

BibTeX
@inproceedings{li2016fast,
  author = {Ke Li and Jitendra Malik},
  title = {{Fast k-Nearest Neighbour Search via Dynamic Continuous Indexing}},
  booktitle = {International Conference on Machine Learning},
  year = {2016},
  url = {https://openreview.net/forum?id=BJEtqoZ_-r},
}
Figure