Nearest Neighbor Normalization Improves Multimodal Retrieval

Neil Chowdhury, Franklin Wang, Sumedh Shenoy, Douwe Kiela, Sarah Schwettmann, Tristan Thrush

Introduction

Contrastive models like CLIP, BLIP, and SigLIP have transformed multimodal retrieval by linking text and images in a shared embedding space. However, these models frequently suffer from hubness, a phenomenon where specific "hub" items in high-dimensional space become the nearest neighbors for an excessive number of queries, leading to frequent false positives. Existing normalization techniques often require expensive fine-tuning or computationally heavy global database searches that scale poorly.

Nearest Neighbor Normalization (NNN) addresses this by providing a simple, training-free inference-time correction. By adjusting match scores based on local neighborhood statistics, NNN neutralizes hubs and improves retrieval accuracy across various architectures without the heavy overhead of previous methods.

Methodology: Local Bias Correction

NNN operates as an additive correction during the inference phase. Unlike global normalization methods that consider the entire dataset, NNN focuses on the "local" neighborhood of an embedding to capture fine-grained distinctions.

Overview of the NNN process: Bias scores are estimated from the k-nearest neighbors in a reference database and subtracted from original match scores to produce normalized results.

The process involves three main steps:

  1. Reference Database: A database of reference queries (e.g., training set captions) is established.
  2. Bias Estimation: For a retrieval candidate $r$, the system identifies its $k$-nearest neighbors in the reference database. The bias score $b(r)$ is calculated as the average similarity to these neighbors.
  3. Normalization: The final score is the original similarity minus the bias score.

By utilizing efficient vector search libraries like Faiss, NNN achieves sublinear runtime, making it significantly faster than exhaustive normalization methods while allowing bias scores to be precomputed and cached.

Mitigating Hubness and Bias

The primary strength of NNN lies in its ability to flatten the distribution of matches. In standard CLIP models, certain images act as "hubs," matching hundreds of unrelated captions incorrectly. NNN identifies these items as having high local bias and penalizes their scores accordingly, creating a fairer distribution.

Hubness reduction: The histogram shows how NNN (orange) significantly reduces the number of "hubs" compared to the original model (blue), leading to a flatter and more accurate distribution of matches.

Beyond accuracy, NNN offers a rare "win-win" for algorithmic fairness. It reduces gender bias by penalizing images that are hubs for specific gendered terms without sacrificing overall performance. On the VisoGender benchmark, NNN reduced average gender bias scores from 0.348 to 0.072 for $n=6$ retrievals.

Experimental Results

Evaluations across MS-COCO and Flickr30k benchmarks demonstrate substantial gains:

  • Accuracy Boost: CLIP’s Recall@1 on MS-COCO image retrieval improved from 30.43% to 37.53% (+7.1 points). Similar gains were observed across all tested models.
  • Efficiency: NNN achieved a >100x speedup over global normalization methods (like DBNorm) with negligible accuracy loss (less than 0.2%).
  • Robustness: The method is model-agnostic and remains effective even when the reference database differs from the test domain (e.g., using COCO queries for Flickr retrieval).

Conclusion

Nearest Neighbor Normalization is a powerful, lightweight tool for enhancing multimodal retrieval. While it is primarily effective for dual-encoder models and introduces a minor computational overhead, its ability to improve accuracy while simultaneously reducing bias and hubness makes it a highly practical solution for real-world deployment. Future research may focus on generating synthetic reference sets to expand NNN's utility in data-scarce domains.

Summary updated

BibTeX
@inproceedings{chowdhury2024nearest,
  author = {Neil Chowdhury and Franklin Wang and Sumedh Shenoy and Douwe Kiela and Sarah Schwettmann and Tristan Thrush},
  title = {{Nearest Neighbor Normalization Improves Multimodal Retrieval}},
  booktitle = {Conference on Empirical Methods in Natural Language Processing},
  year = {2024},
  doi = {10.18653/v1/2024.emnlp-main.1257},
}
Figure