Neighborhood Stability as a Measure of Nearest Neighbor Searchability

Thomas Vecchiato, Sebastian BruchSubmission to ICLR 2026 · Rejected

TL;DR

Clustering-based Approximate Nearest Neighbor Search (ANNS) is widely used to speed up vector retrieval, yet determining whether a dataset will search well under clustering usually requires running expensive empirical queries. This paper introduces Neighborhood Stability Measures (NSM): an internal clustering quality metric (clustering-NSM) that reliably predicts ANNS accuracy, and an intrinsic dataset clusterability metric (point-NSM) that predicts clustering quality directly from the raw data points—even for inner product similarity where traditional cluster metrics break down.

What Problem Does This Paper Address?

In large-scale vector search, Inverted File (IVF) indexing clusters vectors into hundreds or thousands of shards and only searches the few shards closest to a query. However, practitioners currently lack analytical tools to evaluate a dataset's "searchability"—the fundamental suitability of a dataset for clustering-based ANNS—without executing full-blown retrieval experiments with huge query workloads.

Existing internal clustering quality metrics (such as the Dunn index or Davies–Bouldin index) suffer from several flaws in this context:

  1. They measure Euclidean distance magnitudes, making them sensitive to outliers.
  2. They assume non-negative metric distances and cannot handle inner product / Maximum Inner Product Search (MIPS).
  3. They fail to correlate consistently with actual downstream ANNS recall.

Methods

The authors propose evaluating cluster quality and clusterability based on nearest neighbor consistency rather than distance values:

  • Set-NSM (Definition 1): For a set of points $S$, set-NSM is the fraction of points in $S$ whose 1-nearest neighbor (1-NN) also lies in $S$.
  • Clustering-NSM (Clustering Quality): The weighted average of set-NSM across all clusters in a flat partition (weighted by cluster size $|C_i|$). The authors formally prove that clustering-NSM satisfies the four axiomatic properties of clustering quality functions established by Ben-David & Ackerman (2008): consistency, richness, scale invariance, and isomorphism invariance.
  • Point-NSM (Clusterability): A query-free, clustering-free property of the dataset itself. For any point $u$, its point-NSM is the set-NSM of the neighborhood consisting of $u$ and its $(r - 1)$ nearest neighbors. The distribution of point-NSMs reflects the intrinsic clustering tendency of the dataset.

The authors theoretically demonstrate (Theorems 2 and 3) that under ball-covering models, the expected clustering-NSM is lower-bounded by or equal to the dataset's expected point-NSM, providing a direct mathematical link between raw data clusterability and realized cluster quality.

Datasets

The authors evaluated their methods across multiple tasks using standard public benchmarks (no new datasets were created):

  • ANNS Benchmarks:
  • Euclidean: MNIST and Fashion-MNIST ($60\text{k}$ vectors, $d=784$), GIST ($100\text{k}$, $d=960$), SIFT ($1\text{M}$, $d=128$).
  • Cosine Similarity: DeepImage ($10\text{M}$, $d=96$), GloVe ($1.2\text{M}$, $d=200$), LastFM ($300\text{k}$, $d=65$), MS MARCO ($8.8\text{M}$, $d=384$), Natural Questions / NQ ($2.7\text{M}$, $d=1{,}536$).
  • Maximum Inner Product Search (MIPS): Text2Image ($10\text{M}$, $d=200$), Music ($1\text{M}$, $d=100$).
  • Image Clustering Benchmarks: CIFAR-10, CIFAR-100, MNIST, Oxford Pets, and Caltech-101 (represented via embeddings from CLIP ViT-L/14, CLIP ResNet-50, and ReSSL).

Key Insights and Ideas

  • Topology over Metric Distances: Because NSM only checks whether a point's nearest neighbor belongs to the same set (a discrete rank-based property), it is scale-invariant and works identically well for cosine distance and signed inner products.
  • Predictive Pipeline: The metrics form a coherent chain: $$\text{High Point-NSM (Data)} \implies \text{High Clustering-NSM (Partition)} \implies \text{High ANNS Accuracy (Retrieval)}$$
  • High Efficiency via Sampling & Approximation:
  • Nearest neighbor checks only need to be computed once per point and can be reused to score any number of candidate clusterings.
  • Estimating the point-NSM distribution on just a $5\%$ random sample yields identical correlation coefficients to evaluating the entire dataset.
  • Replacing exact 1-NN lookups with fast approximate NN search during stability scoring incurs virtually zero degradation in predictive power.

Key Results

  • Predicting ANNS Accuracy: Clustering-NSM achieved high, statistically significant Spearman rank correlation with top-$k$ ANNS recall ($p < 0.001$). In contrast, the Dunn index exhibited erratic behavior across datasets, and Davies–Bouldin struggled on inner product datasets (even showing negative correlation on the Music dataset).
  • Predicting External Clustering Metrics: On image clustering tasks, clustering-NSM correlated strongly with external ground-truth metrics (Mutual Information and Homogeneity).
  • Point-NSM vs. Clustering-NSM: Across neighborhood radii $r \in \{1024, 2048, 4096, 8192\}$, point-NSM statistics (mean and $0.1$-quantile) correlated strongly with the resulting clustering-NSM of standard and spherical $k$-means (Spearman coefficients ranging between $0.74$ and $0.86$).

Limitations and Future Work

  • Flat Clustering Focus: Theoretical guarantees and empirical validations focus strictly on flat partitions (e.g., $k$-means / IVF); hierarchical clustering schemes were not analyzed.
  • Theoretical Assumptions: The proofs for Theorems 2 and 3 assume clusters can be decomposed into equal-sized metric balls, which is idealized compared to real-world clustering outputs.
  • Cluster Weights: The paper evaluates cluster weights proportional to cluster size ($\omega_i = |C_i|$); exploring alternative weighting schemes remains open.
  • Extension to Graph-based ANNS: The authors highlight extending point-NSM to explain the behavior and performance of proximity-graph ANNS algorithms (such as HNSW) as a promising avenue for future research.

Summary updated

Abstract

Clustering-based Approximate Nearest Neighbor Search (ANNS) organizes a set of points into partitions, and searches only a few of them to find the nearest neighbors of a query. Despite its popularity, there are virtually no analytical tools to determine the suitability of clustering-based ANNS for a given dataset—what we call “searchability.” To address that gap, we present two measures for flat clusterings of high-dimensional points in Euclidean space. First is Clustering-Neighborhood Stability Measure (clustering-NSM), an internal measure of clustering quality—a function of a clustering of a dataset—that we show to be predictive of ANNS accuracy. The second, Point-Neighborhood Stability Measure (point-NSM), is a measure of clusterability—a function of the dataset itself—that is predictive of clustering-NSM. The two together allow us to determine whether a dataset is searchable by clustering-based ANNS given only the data points. Importantly, both are functions of nearest neighbor relationships between points, not distances, making them applicable to various distance functions including inner product.
BibTeX
@misc{vecchiato2026neighborhood,
  author = {Thomas Vecchiato and Sebastian Bruch},
  title = {{Neighborhood Stability as a Measure of Nearest Neighbor Searchability}},
  year = {2026},
  eprint = {2602.16673},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2602.16673},
}
Figure