Papers › With a Little Help from My Friends: Nearest-Neighbor Contrastive Learning of Visual...

With a Little Help from My Friends: Nearest-Neighbor Contrastive Learning of Visual Representations

29 Apr 2021ICCV 2021 10arXiv:2104.14548archive 2025-07-28

Debidatta Dwibedi, Yusuf Aytar, Jonathan Tompson, Pierre Sermanet, Andrew Zisserman

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.

PaperPDFConference PDFCodeCode Syntology ran

In Syntology Open this paper in Syntology's Atlas, the map of the papers in Syntology's graph and their citations.

For agents, Syntology's MCP tool lists every function and class Syntology harvested from this paper and whether it ran (how to connect): get_harvested_code_for_paper(arxiv_id="2104.14548")

Code

Syntology Ran 4 of 5 code samples harvested from 2 repositories linked to this paper; 1 has no recorded run. Of those that ran: 4 ran with no contract checked.

By repository: community (archive-listed): 5 samples from 2 repositories, 4 ran. The run record, sample by sample. “Ran” means executed on a synthesized input, not that the code is correct or reproduces the paper.

lightly-ai/lightly mentioned on GitHubpytorch report
vturrisi/solo-learn mentioned on GitHubpytorch report

Repository list and official/mentioned flags are the archive's, frozen 2025-07-28. Reachability, where shown, is from one Syntology probe window (2026-09-16 to 2026-09-18); repositories not probed show nothing. GitHub stars are not tracked.

Code Syntology ran Syntology

5 samples harvested; 4 ran; 0 honoured the contract we drafted; 1 has no recorded run. Read from Syntology's graph 2026-09-24; that is when this build read the record, not when the samples ran.

4ran
1unverified

Licence: 0 of the 5 samples are pointer only, meaning Syntology does not serve that copy's text. This page shows no code text for any sample; each one links to its file in the repository.

Harvested from 2 repositories linked to this paper, official or community; each sample names its own and says which. “Ran” means the sample executed on a synthesized input. It does not mean the output is correct, and nothing here reproduces the paper's results. “Honoured” and “violated” refer to a contract Syntology drafted from the code itself; “our draft was wrong” and “fixture could not drive it” are failures of Syntology's instrument, not of the code.

Each sample ends with its code_sha256, Syntology's identity for that exact code. An agent fetches the stored sample with Syntology's MCP tool get_code(code_sha256="…") (how to connect); click an identity to copy that call.

Repository labels, per sample. official repository: The archive marks this repository official for the paper. named in the paper: The archive records that the paper mentions this repository; it is not marked official. community (archive-listed): In the archive's code links for this paper, not marked official and not recorded as mentioned in the paper. found in paper text by Syntology: Syntology found this repository in the paper's own text; whether it is the authors' implementation is not asserted. community: Not in the archive's code links for this paper; a community repository Syntology harvested. Samples from a repository marked official are listed first. Licence labels name the repository's licence as recorded at harvest. “Pointer only” means Syntology does not serve that copy's text, for one of four reasons: no licence file was found; the licence was not identified; the licence is recorded as permissive but that copy's record is not marked cleared; or the licence is outside the permissive list Syntology serves text under (MIT, Apache-2.0, BSD and similar). Some licences outside that list permit redistribution, such as WTFPL, and GPL-3.0 under its conditions; they are simply not on the list. Hover a licence label for the reason. File links open the file on GitHub at the default branch, which may have changed since the harvest.

ContrastiveModel beresandras/contrastive-classification-keras/algorithms.py community (archive-listed) ran MIT (permissive) · acc020a5fafd0a3c · report
NNCLR lightly-ai/lightly/lightly/models/nnclr.py community (archive-listed) ran fingerprinted MIT (permissive) · f4dca3b21591894a · report
NNCLRPredictionHead lightly-ai/lightly/lightly/models/nnclr.py community (archive-listed) ran MIT (permissive) · c86c2eda640e0f05 · report
NNCLRProjectionHead lightly-ai/lightly/lightly/models/nnclr.py community (archive-listed) ran MIT (permissive) · b23b111c2f4e00fd · report
NNCLR beresandras/contrastive-classification-keras/algorithms.py community (archive-listed) unverified MIT (permissive) · a8d39573526af033 · report

Tasks

Contrastive LearningFine-Grained Image ClassificationImage ClassificationSelf-Supervised Image ClassificationSelf-Supervised LearningSemi-Supervised Image ClassificationTransfer Learning

Results from the paper archive 2025-07-28

TaskDatasetModelMetricValueRank at snapshotLeaderboardReport
Fine-Grained Image Classification Birdsnap NNCLR Accuracy 61.4% #5 of 5 Archive leaderboard report
Fine-Grained Image Classification Caltech-101 NNCLR Top-1 Error Rate 8.7% #9 of 18 Archive leaderboard report
Fine-Grained Image Classification FGVC Aircraft NNCLR Accuracy 64.1 #53 of 57 Archive leaderboard report
Fine-Grained Image Classification SUN397 NNCLR Accuracy 62.5 #5 of 5 Archive leaderboard report
Image Classification CIFAR-10 NNCLR Percentage correct 93.7 #172 of 265 Archive leaderboard report
Image Classification CIFAR-100 NNCLR Percentage correct 79 #135 of 211 Archive leaderboard report
Image Classification DTD NNCLR Accuracy 75.5 #10 of 11 Archive leaderboard report
Image Classification Flowers-102 NNCLR Accuracy 95.1 #43 of 52 Archive leaderboard report
Image Classification Food-101 NNCLR Accuracy (%) 76.7 #10 of 11 Archive leaderboard report
Image Classification Oxford-IIIT Pet Dataset NNCLR Accuracy 91.8 #3 of 5 Archive leaderboard report
Image Classification PASCAL VOC 2007 NNCLR Accuracy 83 #1 of 1 Archive leaderboard report
Image Classification Stanford Cars NNCLR Accuracy 67.1 #24 of 24 Archive leaderboard report
Self-Supervised Image Classification ImageNet NNCLR (ResNet-50, multi-crop) Number of Params 25M #71 of 144 Archive leaderboard report
Self-Supervised Image Classification ImageNet NNCLR (ResNet-50, multi-crop) Top 1 Accuracy 75.6% #71 of 144 Archive leaderboard report
Self-Supervised Image Classification ImageNet NNCLR (ResNet-50, multi-crop) Top 5 Accuracy 92.4 #71 of 144 Archive leaderboard report
Semi-Supervised Image Classification ImageNet - 1% labeled data NNCLR (ResNet-50) Top 1 Accuracy 56.4% #44 of 65 Archive leaderboard report
Semi-Supervised Image Classification ImageNet - 1% labeled data NNCLR (ResNet-50) Top 5 Accuracy 80.7 #44 of 65 Archive leaderboard report
Semi-Supervised Image Classification ImageNet - 10% labeled data NNCLR (ResNet-50) Top 1 Accuracy 69.8% #40 of 75 Archive leaderboard report
Semi-Supervised Image Classification ImageNet - 10% labeled data NNCLR (ResNet-50) Top 5 Accuracy 89.3 #40 of 75 Archive leaderboard report

Ranks are positions in the archive's leaderboards as they stood at the 2025-07-28 snapshot. Results published since then are not among these rows, so a rank here is not a current standing.

Methods

Introduced by this paper: NNCLR

1x1 ConvolutionAverage PoolingBatch NormalizationBottleneck Residual BlockColorJitterContrastive LearningConvolutionDense ConnectionsGlobal Average PoolingKaiming InitializationMax PoolingNNCLRRandom Resized CropReLUResidual BlockResidual ConnectionSupervised Contrastive Loss

Report a problem or propose a change · a person checks every report against the paper or source before anything changes; decisions are listed on /corrections