Sampling a Near Neighbor in High Dimensions - Who is the Fairest of Them All?

Martin Aumüller, Sariel Har-Peled, Sepideh Mahabadi, Rasmus Pagh, Francesco Silvestri

Abstract

Similarity search is a fundamental operation in large-scale data processing, yet standard algorithms like Locality Sensitive Hashing (LSH) exhibit a significant selection bias. While LSH is optimized to find the nearest neighbors, it disproportionately favors points closer to the query, failing to provide a representative sample of all points within a specified distance. This paper introduces the concept of "Fair Near Neighbor" (FNN) search, providing efficient algorithms that ensure every point within a given radius $r$ has an equal probability of being returned. We demonstrate that this "un-biasing" can be achieved with sub-linear query time, making it practical for applications in diversity-aware recommendation and unbiased statistical sampling.

Introduction

The classic $r$-near neighbor ($r$-NN) problem is a cornerstone of modern computer science, utilized in systems ranging from image retrieval to movie recommendation. The objective is simple: given a query point $q$, find any point $p$ within a distance $r$. However, the efficiency of modern high-dimensional search often comes at the cost of statistical fairness.

The most prevalent method for high-dimensional search, Locality Sensitive Hashing (LSH), operates by hashing points into buckets such that closer points are more likely to collide. While this property is ideal for finding the single nearest neighbor, it creates a systemic "selection bias" when multiple points satisfy the distance constraint. Points closer to the query appear in more hash buckets and are thus significantly more likely to be returned than points near the boundary of the radius $r$. This paper argues for individual fairness (or "equal opportunity"), where every point satisfying the distance constraint has an identical probability of selection.

Methodology

To achieve fair sampling, the authors propose treating the search problem as sampling from a union of sets (where each LSH bucket represents a set). They introduce several data structures to mitigate LSH bias:

1. Random Ranks

During preprocessing, every point in the dataset is assigned a random rank. At query time, the algorithm identifies all points within the relevant LSH buckets and returns the point with the minimum rank. While this ensures fairness for a single query, additional mechanisms are required to maintain independence across multiple queries.

2. Rejection Sampling and Degree Computation

To ensure independent and fair sampling, the authors utilize rejection sampling based on a point's "degree." The degree of a point $p$ is defined as the number of LSH buckets to which it belongs. Because LSH naturally favors points with higher degrees, the algorithm returns a discovered point $p$ with probability $1/\text{degree}(p)$. This mathematical inversion perfectly cancels out the inherent LSH bias.

3. Degree Approximation

Calculating the exact degree of a point can be computationally expensive. To maintain efficiency, the authors introduce approximation methods using "count-distinct" sketches or simulation processes that probe buckets until a non-empty one is found, ensuring the algorithm remains scalable.

4. Locality Sensitive Filters (LSF)

For inner-product similarity, the authors develop a nearly-linear space data structure using spherical filtering. This approach provides a more direct path to fairness in high-dimensional vector spaces compared to standard hashing techniques.

Experimental Evaluation

The proposed algorithms were evaluated against standard LSH across five diverse, real-world datasets:

  • MovieLens & Last.FM: User preferences using Jaccard similarity.
  • MNIST & SIFT: Handwritten digits and image descriptors using Euclidean distance.
  • GloVe: Word embeddings using Euclidean distance.

The primary metric for fairness was Total Variation Distance (TVD), which measures the gap between the algorithm's output distribution and a true uniform distribution.

Key Results

Quantifying the Bias

The experiments confirmed that standard LSH is heavily biased. In the Last.FM dataset, points with high similarity were up to 6 times more likely to be reported than points just above the distance threshold. Standard LSH typically exhibited a TVD of approximately 0.4, indicating a substantial departure from fairness.

Fairness and Performance

The proposed "Optimal" and "Degree Approximation" methods achieved near-zero TVD, making their empirical distributions nearly indistinguishable from a true uniform distribution. While these fair sampling methods are approximately 10x slower than "unfair" LSH, they still operate within the millisecond range (10ms to 100ms) for datasets containing up to 1 million points. This demonstrates that fairness does not require sacrificing sub-linear query performance.

Conclusion

Fair Near Neighbor search addresses a critical but often overlooked bias in high-dimensional similarity search. By normalizing the probability of retrieval based on a point's "degree" within the search structure, the authors provide a robust framework for unbiased sampling. This work is essential for applications where diversity and statistical parity are as important as raw retrieval speed, such as avoiding echo chambers in recommender systems or ensuring representative data sampling in machine learning pipelines.

Summary updated

BibTeX
@article{aumuller2022sampling,
  author = {Martin Aumüller and Sariel Har-Peled and Sepideh Mahabadi and Rasmus Pagh and Francesco Silvestri},
  title = {{Sampling a Near Neighbor in High Dimensions - Who is the Fairest of Them All?}},
  journal = {ACM Trans. Database Syst.},
  year = {2022},
  url = {https://openreview.net/forum?id=Ukgdt15-Z3B},
}
Figure