NeurIPS 2026Coming to NeurIPS?Explore papers, orals & directions

Fair Near Neighbor Search: Independent Range Sampling in High Dimensions

Martin Aumüller, Rasmus Pagh, Francesco Silvestri · DOI

TL;DR

Standard similarity search algorithms like Locality Sensitive Hashing (LSH) are inherently biased, heavily favoring data points that are closer to the query or located in dense clusters. This paper introduces the first efficient, high-dimensional data structures that guarantee "equal opportunity" fairness, ensuring every valid neighbor within a given distance threshold has an identical probability of being returned.

What Problem Does This Paper Address?

In similarity search, the $r$-near neighbor ($r$-NN) problem asks a system to return any data point within a radius $r$ of a query point. This is a foundational primitive for recommendation systems, data mining, and machine learning.

However, standard high-dimensional techniques like LSH introduce a hidden algorithmic bias: they are fundamentally designed to maximize collision probabilities for closer points. If a streaming service uses $r$-NN to recommend movies within a certain genre similarity threshold, LSH will consistently surface the absolute closest or most densely clustered movies, completely starving other perfectly valid choices of exposure.

The authors tackle this by formalizing the $r$-near neighbor independent sampling ($r$-NNIS) problem. The goal is to achieve "equal opportunity" fairness: every point within the radius $r$ must have an exactly equal ($1/|B_S(q,r)|$) and independent chance of being selected, removing the structural bias inherent to spatial indexing.

Methods

The paper proposes three distinct algorithmic solutions depending on the setting:

  1. Rank-Based LSH ($r$-NNS): The authors first introduce a global random permutation to assign a "rank" to every data point. Data points within LSH buckets are sorted by this rank. When a query occurs, the algorithm scans the buckets and returns the valid neighbor with the lowest rank. This guarantees uniform sampling for a single query.
  2. Count-Sketch Segmented Sampling ($r$-NNIS): To ensure independence across multiple or repeated queries, the authors extend the rank-based approach. They use a count-sketch structure to estimate the total number of colliding points. They then divide the global permutation into dynamically sized segments and sample these segments to ensure that subsequent query results aren't influenced by prior outputs.
  3. Nearly-Linear Space Filtering for Inner Product: For applications using inner product similarity, the authors design a simpler, space-efficient alternative. Instead of using LSH as a black box, it utilizes random Gaussian projections (tensoring) and a bucket-enumeration strategy that stores each data point exactly once, drastically reducing memory overhead.

Datasets

The authors evaluated their approach using:

  • Last.FM: 1,892 users and 18,739 unique artists, converted into a set representation.
  • MovieLens: 2,112 users and 65,536 unique movies, also converted into a set representation.
  • Synthetic Clustered Dataset: A specifically engineered dataset designed to demonstrate how alternative "approximate" fairness definitions fail in the presence of dense data clusters.

Key Insights and Ideas

  • The Flaw of "Approximate" Fairness: A competing, concurrent approach attempted to solve this problem by relaxing the requirement to an "approximate neighborhood" (sampling uniformly from a slightly larger radius $cr$). The authors reveal a major vulnerability here: in clustered data, an item can become 50x less likely to be picked than a less similar item simply because it resides in a crowded neighborhood. This can be weaponized by adversaries to obfuscate data points.
  • Fairness is Computationally Affordable: Achieving perfect uniformity doesn't require a massive sacrifice in speed. The proposed algorithms achieve strict fairness guarantees while matching the query time of standard, unfair LSH up to minor polylogarithmic factors.
  • Permutations Neutralize Spatial Bias: By decoupling the selection mechanism (the random rank permutation) from the retrieval mechanism (LSH collision), the algorithm successfully neutralizes LSH's geometric bias toward closer points.

Key Results

  • Eliminating the Gradient: In empirical tests on MovieLens and Last.FM, standard LSH showed a steep gradient, heavily over-representing highly similar points. The authors' Fair LSH completely flattened this gradient, delivering a perfectly uniform distribution across all valid neighbors.
  • Low Real-World Overhead: The running time of these fair algorithms depends partly on the ratio of points in the approximate neighborhood versus the true neighborhood ($b_S(q,cr)/b_S(q,r)$). Testing on real-world datasets proved that this ratio remains small and practical, meaning the worst-case theoretical slowdowns rarely manifest in practice.

Limitations and Future Work

  • Manual Parameterization: The current data structures require the user to manually set and balance the distance thresholds ($r$ and $cr$). The authors note that a "parameterless" version that automatically optimizes these trade-offs would be a significant improvement.
  • Strict Uniformity vs. Smooth Weighting: This paper treats fairness as a binary threshold—either a point is within radius $r$ (equal chance) or it isn't. In many real-world scenarios, a smooth, controlled weighting system (where closer points are preferred, but without LSH's erratic structural biases) would be highly desirable. The authors leave this weighted fairness variant as an open direction for future research.

Summary updated

BibTeX
@misc{aumuller2019fair,
  author = {Martin Aumüller and Rasmus Pagh and Francesco Silvestri},
  title = {{Fair Near Neighbor Search: Independent Range Sampling in High Dimensions}},
  year = {2019},
  eprint = {1906.01859},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/1906.01859},
}
Figure