Contrastive self-supervised learning trains an encoder by pulling two augmented views of the same image together and pushing every other image in the batch away. When two batch images actually show the same kind of object, such as two golden retrievers, that push works against the learning signal. These pairs are called false negatives. Existing fixes detect suspected false negatives and then either drop them from the push term ("elimination") or pull them together like true positives ("attraction"). The literature disagrees on which is right. One study finds attraction destructive when the detector is noisy (Incremental False Negative Detection for Contrastive Learning). Another finds attraction beats elimination on ImageNet (Boosting Contrastive Self-Supervised Learning with False Negative Cancellation). Every detector also needs a hand-tuned warm-up period, because early embeddings are meaningless.
We propose to treat each suspect pair as a small model-comparison problem: do these two embeddings come from the same latent class or from different ones? The tool is marginal likelihood sandwiching, which computes both a guaranteed lower bound and a guaranteed upper bound on a model's evidence (the probability it assigns to the data after integrating out unknowns). Bounding the evidence of both hypotheses yields an interval on the pair's log odds of being a false negative. The decision follows from where that interval sits. Attract the pair only when the whole interval says "same class." Keep it as a negative when the whole interval says "different." Eliminate it when the interval straddles the boundary. Early in training the intervals are wide, so the warm-up schedule falls out of the bounds instead of being hand-set.
Core Claim
We argue that the elimination-versus-attraction contradiction comes from confidence, not from choosing the wrong strategy. Attraction helps when the same-class evidence is decisive and hurts when it is not. A sandwiched Bayes factor (the ratio of the evidence for "same class" to the evidence for "different class," bracketed above and below) is the right object for telling these cases apart. This is exactly the setting sandwiching was designed for. A one-sided lower bound can rank two hypotheses wrongly when one bound is looser than the other. A sandwich certifies the sign of the comparison whenever the two intervals do not overlap.
How the Bracket Is Built
Contrastive encoders have no generative decoder, so bounds like the importance-sampling gap bound of Bounding Evidence and Estimating Log-Likelihood in VAE do not apply to the encoder directly. We therefore place an explicit latent-variable model on top of it. A Bayesian mixture of von Mises–Fisher distributions (Gaussian-like clusters on the unit sphere) is fitted to a memory bank $D$ of recent normalized embeddings, with $K$ components and uncertain component means, concentrations and weights, collected in $\theta$. The class assignments are discrete and can be summed exactly. The parameters $\theta$ cannot be integrated in closed form, and that integral carries the epistemic uncertainty that is large early in training.
For anchor $i$ and candidate negative $j$, write $S$ for "same component" and $\bar S$ for "different component." Let $L_H$ and $U_H$ be lower and upper bounds on $\log p(D, z_i, z_j, H)$ for $H \in \{S, \bar S\}$, where $z$ is an embedding. Because the prior probability of a same-class pair is folded into each evidence term, the log posterior odds satisfy
$$ O_{ij} = \log \frac{p(S \mid D, z_i, z_j)}{p(\bar S \mid D, z_i, z_j)} \in \left[\, L_S - U_{\bar S},\; U_S - L_{\bar S} \,\right] = [O^-_{ij}, O^+_{ij}]. $$
The lower bounds are importance-weighted bounds using $k$ samples from a variational proposal $q(\theta)$. The upper bounds are the importance-sampling variational gap bound of Struski et al., which tightens monotonically as $k$ grows. We also run the χ upper bound of Variational Inference via \chi Upper Bound Minimization as an alternative upper bound. The proposal $q$ is trained with a mass-covering objective from that same work, so that it does not collapse onto one mode and leave the upper bound loose. Both bounds hold for any proposal, so the bracket stays valid even when $q$ is poor. A poor $q$ only widens it.
The decision rule has no tuned threshold. Pair $(i,j)$ is attracted as a positive if $O^-_{ij} > 0$, kept as an ordinary negative if $O^+_{ij} < 0$, and removed from the denominator otherwise. A cost-asymmetric variant replaces 0 with $\log c$ on the attraction side; it is reported as a sensitivity check. The warm-up behaviour falls out of the prior. With uninformative embeddings the two likelihoods roughly agree, so $O_{ij}$ sits near the prior log odds of about $-\log K$. Nearly every pair is then certified "different" and training reduces to plain contrastive learning. Pairs move into elimination, and later into attraction, only as the mixture sharpens.
Cost is controlled by computing the shared memory-bank term once per batch with the same $\theta$ samples. Each pair then adds only $O(k K)$ work. The memory bank is subsampled to a few thousand entries, and $q$ is refreshed every few hundred steps. We expect importance weights to degenerate as $|D|$ grows. That is the same outlier sensitivity Struski et al. had to patch by discarding the top 1% of latents. Here the failure is conservative: wider brackets, more elimination, less attraction.
Relation to Prior Work
Three detector families motivate this work and are what we replace. Debiased contrastive learning subtracts the expected positive contribution from the negative sum using a fixed class prior. When the corrected sum goes negative it clamps it, and it never decides about individual pairs. ProGCL (ProGCL: Rethinking Hard Negative Mining in Graph Contrastive Learning) fits a Beta mixture to similarity scores and reweights negatives, but needs a hand-set start epoch. IFND clusters with $k$-means and ramps acceptance linearly. In all three, a point estimate stands in for evidence, and the warm-up and attraction choices are made outside the model. Difficult Examples Hurt Unsupervised Contrastive Learning: A Theoretical Perspective constrains the design. Its theory says ambiguous pairs actively harm learning, which is why our ambiguous branch removes pairs rather than keeping them.
BayesNCL is the closest variational approach. It masks conflicting feature dimensions with Bernoulli gates trained by a one-sided evidence lower bound. It acts on dimensions rather than pairs and has no upper bound, so it cannot tell how loose its approximation is. Two works supply the idea of two-sided bounds in learning loops without addressing false negatives. Exploring Bidirectional Bounds for Minimax-Training of Energy-Based Models traps a generative likelihood between bounds. CLUB builds a contrastive upper bound on mutual information, but samples its negatives naively. Bidirectional Monte Carlo (Measuring the reliability of MCMC inference with bidirectional Monte Carlo) would give tighter brackets, but it needs exact joint samples. Our model provides these only for synthetic checks, so we use it there as a reference rather than in the training loop.
Research Program
The work has three stages. The first validates the bracket offline. Frozen encoder checkpoints from several epochs of a SimCLR run on ImageNet-100 are used with ground-truth labels. We measure how often certified-same pairs truly share a label (precision of attraction), how often certified-different pairs truly differ, and how the fraction of ambiguous pairs falls with training. On a synthetic von Mises–Fisher mixture with known parameters, we verify that the exact log odds lie inside the bracket. Bidirectional Monte Carlo serves as an independent reference.
The second stage trains with the three-way rule on CIFAR-10, CIFAR-100, STL-10 and ImageNet-100. The third stage reproduces the contradiction in a controlled way. We inject label-free noise into the detector by perturbing embeddings fed to the mixture, at several noise levels and start epochs. The test is whether attraction gated by $O^-_{ij} > 0$ tracks the better of always-attract and always-eliminate across the whole sweep. A limited ImageNet-1k run and a graph check on ogbn-arXiv (encoder swapped for ProGCL's graph network) come last, conditional on stage two succeeding.
Baselines
The naive reference point is plain SimCLR with the same encoder, augmentations, batch size and epochs. On ImageNet-100, BayesNCL reports a SimCLR baseline of 68.31% top-1 linear-probe accuracy and 69.63% for its NCL baseline.
The strongest competitor on ImageNet-100 is BayesNCL at 70.44% top-1 linear-probe accuracy, reported in BayesNCL. It is the only method in the file that already brings variational inference to contrastive conflicts, so it is the natural head-to-head. We will rerun it from its published settings with the same backbone and epochs and give it the same tuning budget as ours: a grid over its sparsity prior and KL weight matched in size to our grid over $K$ and $k$. Beating it means a mean linear-probe gain over three seeds that exceeds the seed spread. Beating its reported 70.44% alone does not count, since setups differ.
On ImageNet-1k the reference is false negative cancellation (support-set detection with attraction), which reports 74.4% top-1 linear evaluation and 63.7% top-1 with 1% labels. IFND reports 69.7% top-1. We will rerun both in a shortened, compute-matched schedule rather than compare to those headline numbers. Debiased contrastive learning is rerun everywhere with its class prior set from true class counts, which favours it; its file-reported number is a +4.26% top-1 gain on STL-10, and no reported result was found on Lacuna for it on ImageNet-100. ProGCL's 72.56% on ogbn-arXiv is the graph reference.
Four ablations isolate the key ingredient by holding the detector model fixed while varying the decision rule. In the first, the closed-form same-class posterior under a point-estimated mixture is fed through the same three-way rule, with tuned hysteresis thresholds. In the second, the bracket is replaced by the spread of a bootstrap ensemble of point-estimated mixtures. The third uses the lower bounds alone, with no upper bound. The fourth forces always-eliminate and always-attract using the same detector. If the first two match the full method, the sandwich is not earning its place.
Why not just…?
Why not just use the closed-form same-class posterior from a fitted mixture, with a confidence threshold and a warm-up? This is the most serious threat. With fixed mixture parameters, the probability that two embeddings share a component is cheap and exact. A well-tuned threshold plus warm-up might match everything here. What it lacks is any account of uncertainty in the mixture itself. Early in training it can be confidently wrong, which is the confirmation-bias trap that forced IFND's linear ramp and ProGCL's start epoch. The first ablation tests this directly, with its warm-up and thresholds tuned on the same budget. If it ties our method across the noise sweep in stage three, we will report that the sandwich adds rigour but not accuracy.
Why not just use debiased contrastive learning with a good class prior? It corrects the expected size of the negative sum, so it cannot attract anything. It also needs the clamp whenever a mini-batch estimate goes negative. FNC's finding that attraction adds roughly 1.75% versus 1.02% for elimination on ImageNet suggests that discarding attraction leaves accuracy on the table. We run it with the true prior to give it its best case. Our mixture weights estimate that prior from data instead.
Why not just bootstrap the clustering, or run IFND-style $k$-means with a schedule, to get uncertainty? Bootstrap spread is a reasonable uncertainty proxy, and the second ablation tests it. It gives no guarantee that the true odds lie inside the spread, and its width depends on resampling choices rather than shrinking predictably with more samples. The importance-sampling bounds do shrink predictably: Struski et al. report a gap of 0.04 on MNIST, against more than 6.0 for the χ and related upper bounds. $k$-means with a schedule also needs multi-granularity cluster counts and an offline pass over the dataset, which IFND reports costs hours on ImageNet. Our refresh runs on a subsampled memory bank.
Decisive Checks
The idea stands or falls on four checks. First, on ImageNet-100 with held-out labels, attraction gated by certified intervals must have clearly higher same-label precision than the point-estimate posterior at equal attraction rate, and the synthetic exact log odds must fall inside the bracket. Second, in the noise and start-epoch sweep, the three-way rule must track the better of always-attract and always-eliminate. That would reconcile the IFND and FNC findings rather than siding with one. Third, the ambiguous fraction must fall over training without any schedule. The method must match or beat IFND-style ramps and ProGCL-style start epochs when those are tuned. Fourth, the full method must beat the point-estimate and bootstrap ablations and the rerun BayesNCL on linear-probe accuracy beyond seed variance. If the brackets stay too wide to ever certify attraction, for example from importance-weight collapse on large memory banks, the method degrades to cautious elimination. We will report that outcome as a negative result about sandwiching at this scale.
References
- Incremental False Negative Detection for Contrastive Learning
- Boosting Contrastive Self-Supervised Learning with False Negative Cancellation
- Bounding Evidence and Estimating Log-Likelihood in VAE
- Variational Inference via \chi Upper Bound Minimization
- Debiased contrastive learning
- ProGCL: Rethinking Hard Negative Mining in Graph Contrastive Learning
- Difficult Examples Hurt Unsupervised Contrastive Learning: A Theoretical Perspective
- Bayesian Gated Non-Negative Contrastive Learning
- Exploring Bidirectional Bounds for Minimax-Training of Energy-Based Models
- CLUB: A Contrastive Log-ratio Upper Bound of Mutual Information
- Measuring the reliability of MCMC inference with bidirectional Monte Carlo