[Paper Review] With a Little Help from My Friends: Nearest-Neighbor Contrastive Learning of Visual Representations
This paper proposes NNCLR, a self-supervised contrastive learning method that uses nearest neighbors from a learned embedding space as positive pairs instead of data-augmented views. By leveraging semantically similar examples from the dataset, NNCLR improves representation learning, achieving 75.6% top-1 accuracy on ImageNet linear evaluation—outperforming prior state-of-the-art methods and reducing reliance on complex data augmentations.
Self-supervised learning algorithms based on instance discrimination train encoders to be invariant to pre-defined transformations of the same instance. While most methods treat different views of the same image as positives for a contrastive loss, we are interested in using positives from other instances in the dataset. Our method, Nearest-Neighbor Contrastive Learning of visual Representations (NNCLR), samples the nearest neighbors from the dataset in the latent space, and treats them as positives. This provides more semantic variations than pre-defined transformations. We find that using the nearest-neighbor as positive in contrastive losses improves performance significantly on ImageNet classification, from 71.7% to 75.6%, outperforming previous state-of-the-art methods. On semi-supervised learning benchmarks we improve performance significantly when only 1% ImageNet labels are available, from 53.8% to 56.5%. On transfer learning benchmarks our method outperforms state-of-the-art methods (including supervised learning with ImageNet) on 8 out of 12 downstream datasets. Furthermore, we demonstrate empirically that our method is less reliant on complex data augmentations. We see a relative reduction of only 2.1% ImageNet Top-1 accuracy when we train using only random crops.
Motivation & Objective
- To improve self-supervised visual representation learning by moving beyond instance discrimination with single-view positives.
- To reduce dependency on complex data augmentation strategies in contrastive learning by using semantically meaningful, cross-sample positives.
- To explore whether nearest neighbors in the embedding space can serve as effective, diverse positives that capture intra-class variations.
- To demonstrate that such a method can outperform both self-supervised and even supervised pre-training on downstream transfer tasks.
Proposed method
- The method uses a support set of frozen embeddings from a subset of the training data, updated during training to maintain a dynamic memory of features.
- For each input image, the model retrieves its nearest neighbors in the latent space using cosine similarity, treating them as positive pairs.
- Contrastive loss is applied between augmented views of the same image and their nearest neighbors from the support set, encouraging feature similarity.
- The support set is distinct from memory banks and queues, as it is used for positive neighbor retrieval rather than negative feature storage.
- The model is trained using a momentum-updated encoder and a predictor head, similar to SimCLR, but with a key difference in positive pair sourcing.
- The approach is evaluated under various settings: linear evaluation on ImageNet, semi-supervised learning with 1% labels, and transfer learning on 12 downstream datasets.
Experimental results
Research questions
- RQ1Can using nearest neighbors from the dataset as positive pairs in contrastive learning improve representation quality compared to standard data-augmented views?
- RQ2Does NNCLR reduce the performance gap between self-supervised and supervised pre-training on downstream tasks?
- RQ3To what extent does NNCLR reduce reliance on complex data augmentation strategies?
- RQ4How does the diversity of nearest neighbors (e.g., from same class, similar texture, or context) affect learning and final performance?
- RQ5Can a purely unsupervised nearest-neighbor selection strategy achieve performance close to a supervised oracle that always picks same-class neighbors?
Key findings
- NNCLR achieves 75.6% top-1 accuracy on ImageNet linear evaluation, a 3.9% improvement over the prior state of the art and a 3.8% gain over SimCLR.
- On semi-supervised learning with only 1% ImageNet labels, NNCLR improves accuracy from 53.8% to 56.5%, demonstrating strong generalization under label scarcity.
- NNCLR outperforms state-of-the-art self-supervised and even supervised ImageNet pre-trained features on 8 out of 12 downstream transfer learning benchmarks.
- With only random crop augmentation (no color jitter, cutout, etc.), NNCLR achieves 73.3% top-1 accuracy, a 2.1% relative drop, showing reduced dependence on data augmentation.
- The nearest neighbor accuracy (same ImageNet class) reaches 57% at the end of training, indicating that the model learns to retrieve semantically relevant examples.
- When forced to use only same-class nearest neighbors (oracle setting), NNCLR reaches 75.8% top-1 accuracy, suggesting further performance gains are possible with better neighbor selection strategies.
Read this paper
Open the full text in the Nubint reader and ask about any passage as you read.
Read this paper on NubintThis review was generated by AI from the original paper. Please check the paper before citing it.