NeurIPS 2026

Rethinking Contrastive Loss in CLIP Post‑training

A Complementary Framework with Frozen Text Encoder — ComCLIP

Zidan Wang1 Yaqian Li2,* Xiaokai Zhang1 Kaiwen Long2 Kun He1 Hanpeng Liu1,2,*,†

1Huazhong University of Science and Technology 2Li Auto Inc.

* Corresponding authors  ·  † Work done during a research internship at Li Auto Inc.

ComCLIP framework: a frozen CLIP text encoder, a trainable CLIP image encoder anchored to a frozen copy, and a frozen DINOv2 encoder providing relational supervision.

Overview of ComCLIP. Three branches operate jointly: (i) the frozen CLIP text encoder for image-text alignment (\(\mathcal{L}_{\text{clip}}\)), (ii) the trainable CLIP image encoder anchored to its frozen pretrained counterpart (\(\mathcal{L}_{\text{mse}}\)), and (iii) a frozen DINOv2 encoder providing relational supervision via batch-wise similarity matrices (\(\mathcal{L}_{\text{rkd}}\)). All three losses operate on the post-projection embedding.

TL;DR Contrastive post-training of CLIP was thought to fail because small batches give too few negatives. We find the main cause is the temperature: at \(\tau = 0.01\) instead of the inherited \(\tau \approx 0.07\), the same InfoNCE objective improves CLIP. ComCLIP builds on this with a single-epoch, frozen-text-encoder recipe that produces a drop-in vision encoder.

Abstract

CLIP serves as a foundational vision-language model and the de facto vision encoder for downstream VLMs such as LLaVA. Post-training offers a lightweight route to refine CLIP, but recent work argues that the standard contrastive loss is unsuitable for post-training due to catastrophic forgetting under small batches, motivating designs that abandon the contrastive objective in favor of distillation. We revisit this premise and find that, for the InfoNCE objective, the reported forgetting is driven primarily not by insufficient negatives but by an inappropriate magnitude of the contrastive temperature \(\tau\): with \(\tau\) set sufficiently small, contrastive post-training improves rather than degrades the pretrained CLIP, which we explain through the temperature dependence of the InfoNCE gradient.

Building on this finding, we propose ComCLIP, a lightweight single-epoch post-training recipe that freezes CLIP's text encoder—so the refined vision encoder is a drop-in replacement with unchanged architecture and inference cost—and trains the vision encoder with a properly-tempered contrastive loss, an MSE anchoring loss against the original CLIP, and a relational distillation loss from DINOv2. Over multiple seeds, ComCLIP matches the self-distillation baseline CLIP-Refine on zero-shot classification while significantly improving the transferability of visual features, measured by linear probing (48.99 vs. 42.28 on ViT-B/16), and on ViT-L/14 it also improves MMVP over CLIP-Refine (24.20 vs. 19.01); CLIP-Refine remains stronger on image-text retrieval. Used as a drop-in vision encoder for LLaVA-1.5-7B without re-aligning the projector or LLM, ComCLIP yields no net change across 8 VLM benchmarks, i.e., the refinement does not break downstream compatibility.

Finding 1Temperature matters more than batch size

Inheriting CLIP's pretraining temperature \(\tau \approx 0.07\) reproduces the catastrophic forgetting reported in prior work. With a substantially smaller \(\tau = 0.01\), the same objective, data and compute improve the pretrained model. Both runs below train ViT-B/16 on CC3M for one epoch with \(\mathcal{L}_{\text{clip}}\) only.

61.82
OpenAI CLIP ViT-B/16, zero-shot accuracy averaged over 12 datasets
57.90 −3.92
Contrastive post-training at \(\tau = 0.07\) (pretraining init)
62.90 +1.08
Same objective at \(\tau = 0.01\)

Sweeping the temperature

Zero-shot accuracy (12-dataset avg) · batch size 1,024

Sweeping the batch size

Zero-shot accuracy (12-dataset avg) · \(\tau = 0.01\)

Both panels share one y-axis. Going from batch 128 to 2,048 gains +1.03, while the jump from \(\tau = 0.07\) to \(\tau = 0.01\) is worth +5.00. Every \(50 \le 1/\tau \le 200\) beats the base model, and \(\tau = 0.01\) does so at every batch size tested. Fixed and learnable \(\tau\) differ by at most 0.05. ViT-B/16, CC3M, one epoch, \(\mathcal{L}_{\text{clip}}\) only, single runs.

Why a small temperature helps

For the image-to-text term of sample \(i\), with similarities \(s_{ij} = \mathbf{u}_i^\top \mathbf{v}_j\) and softmax weights \(p_{ij}\), the gradient with respect to the logits is

$$\frac{\partial \mathcal{L}_i}{\partial s_{ij}} = \frac{1}{\tau}\bigl(p_{ij} - \mathbb{1}[j=i]\bigr), \qquad p_{ij} \le \exp\!\Bigl(-\frac{s_{ii}-s_{ij}}{\tau}\Bigr)\quad (j \neq i).$$

A pretrained CLIP already separates most matched pairs from mismatched ones, so the margin \(\Delta_{ij} = s_{ii} - s_{ij}\) is positive for most in-batch negatives. With a small \(\tau\), \(\Delta_{ij}/\tau\) is large for all but the hardest negatives. The gradient on easy pairs vanishes exponentially, which leaves the pretrained geometry intact, and the update concentrates on the few hard negatives, which refines it. At \(\tau \approx 0.07\), typical margins are of the same order as \(\tau\), so many already-correct pairs keep receiving gradient. The encoder then re-fits the small post-training corpus instead of correcting its remaining errors. This is the forgetting reported in prior work.

Practical guidance: set \(\tau\) well below the pretraining initialization so that \(\Delta_{ij}/\tau \gg 1\) for most negatives. We fix \(\tau = 0.01\) and transfer it unchanged to ViT-L/14, SigLIP, COCO Caption and CC12M. The analysis is specific to InfoNCE. It does not cover KL-based self-distillation or SigLIP's sigmoid loss.

MethodComCLIP: refine relative structure, anchor absolute geometry

ComCLIP freezes the CLIP text encoder and trains only the vision encoder for one epoch with three losses on the post-projection embedding \(\mathbf{u}\):

$$\mathcal{L}_{\text{ComCLIP}} = \lambda_{\text{clip}}\,\mathcal{L}_{\text{clip}} + \lambda_{\text{mse}}\,\mathcal{L}_{\text{mse}} + \lambda_{\text{rkd}}\,\mathcal{L}_{\text{rkd}}$$
Alignment

\(\mathcal{L}_{\text{clip}}\) · tempered InfoNCE

Symmetric InfoNCE against the frozen text encoder, with \(\tau\) fixed at 0.01. It drives zero-shot classification and retrieval.

Anchoring

\(\mathcal{L}_{\text{mse}}\) · feature anchor

MSE between \(\mathbf{u}(x)\) and the embedding \(\mathbf{u}^0(x)\) of a frozen copy of the original encoder. It stops the encoder from drifting and preserves transferable features.

Relational distillation

\(\mathcal{L}_{\text{rkd}}\) · DINOv2 relations

Row-wise KL between the batch similarity distributions of CLIP and DINOv2 (\(T = 0.1\)). It transfers DINOv2's view of which images are close to which, without forcing CLIP into DINOv2's coordinates.

The delivered model is a single CLIP vision encoder with the same architecture, parameter count and inference cost as the input model. It can replace CLIP directly, including inside LLaVA-1.5. Training: AdamW, lr \(10^{-6}\), weight decay 0.1, 410 warm-up steps, global batch 1,024, all \(\lambda = 1\).

Finding 2Each loss moves a different group of metrics

Training every subset of the three losses shows that they act on largely separable metrics. \(\mathcal{L}_{\text{clip}}\) alone raises zero-shot accuracy and retrieval but leaves linear probing flat. \(\mathcal{L}_{\text{mse}}\) alone is a no-op. \(\mathcal{L}_{\text{rkd}}\) alone pulls the embedding away from the text space. Combined, the anchor lets the contrastive signal improve alignment without eroding transferable features.

Configuration\(\mathcal{L}_{\text{clip}}\)\(\mathcal{L}_{\text{mse}}\)\(\mathcal{L}_{\text{rkd}}\)Zero-shotMS COCO R@1Flickr30K R@1Linear probe
12-avgI→TT→II→TT→I5-avg
OpenAI CLIP–––61.8248.1631.4774.7057.1044.70
Contrastive only✓––62.9051.9238.2876.8064.5644.04
Anchor only–✓–61.8248.1831.4574.7057.1244.79
Relational only––✓56.6443.3025.5769.3049.6644.42
Anchor + relational–✓✓61.3649.9831.5375.4058.0845.50
Contrastive + anchor✓✓–63.3551.6437.0377.0064.3448.60
Contrastive + relational✓–✓62.4951.5036.6777.3063.9647.15
ComCLIP (all three)✓✓✓63.1552.2036.1877.8063.2248.74

Loss decoupling on ViT-B/16, CC3M, one epoch, \(\tau = 0.01\), single runs. Best per column in bold. In a 3-seed control, adding \(\mathcal{L}_{\text{rkd}}\) to \(\mathcal{L}_{\text{clip}} + \mathcal{L}_{\text{mse}}\) significantly improves linear probing on ViT-L/14 (56.36 → 57.12, \(p \approx 0.013\)). On ViT-B/16 the gain has the same sign but is not significant.

ResultsBetter transferable features at zero-shot parity

ComCLIP and the self-distillation baseline CLIP-Refine sit at different points of a trade-off. On ViT-B/16 over three seeds, the two are at parity on zero-shot classification (63.00 vs. 62.87, \(p = 0.26\)). CLIP-Refine is ahead on retrieval, and ComCLIP is far ahead on linear probing (48.99 vs. 42.28, \(p < 0.001\)). CLIP-Refine pushes linear probing below the original CLIP, while ComCLIP raises it.

Training data in parentheses · \(\pm\) = std over 3 seeds
MethodZero-shotMS COCO R@1Flickr30K R@1Lin. probeMMVP
12-avgI→TT→II→TT→I5-avgavg
OpenAI CLIP61.8248.1631.4774.7057.1044.7012.59
+ KUEA (IN-1K)62.0748.4831.9975.0057.6244.6511.85
+ KUEA (CC3M)61.9948.0031.4775.0057.0044.7214.07
+ CLIP-Refine (COCO)62.87±0.1154.17±0.2837.72±0.0781.30±0.4064.45±0.2142.28±0.6216.05±1.14
+ CLIP-Refine (CC3M)61.5941.1233.2966.2060.1844.8919.26
+ ComCLIP (COCO)62.9752.2435.3679.5061.3647.2315.56
+ ComCLIP (CC3M)63.00±0.1352.49±0.2836.17±0.0277.80±0.0063.11±0.0948.99±0.3514.81±2.97
+ ComCLIP (CC12M)63.0451.5835.5677.1062.4246.5615.56

Best and second-best per backbone in bold and underline; highlighting does not imply statistical significance. ComCLIP and CLIP-Refine train for 1 epoch, KUEA for 2 (its default). MMVP has only 135 image pairs (one pair = 0.74 points), so we draw MMVP conclusions only from multi-seed comparisons.

Radar chart comparing OpenAI CLIP, KUEA, CLIP-Refine and ComCLIP on ViT-L/14 across zero-shot classification, retrieval, linear probing and MMVP.
The linear-probe gain is not a data artifactWith matched training data, ComCLIP still leads CLIP-Refine on linear probing: +4.10 on ViT-B/16 (both on CC3M) and +7.45 on ViT-L/14 (both on COCO Caption).
MMVP improves on ViT-L/14Over 3 seeds with both methods trained on CC3M, ComCLIP reaches 24.20±0.86 against CLIP-Refine's 19.01±1.86 (Welch \(p = 0.025\)).

DownstreamA drop-in vision encoder for LLaVA-1.5

We swap LLaVA-1.5-7B's vision encoder for each post-trained ViT-L/14 and keep the projector and LLM frozen. ComCLIP produces no net change against the original CLIP (mean relative change +0.02%), while KUEA and CLIP-Refine each degrade 6 of the 9 scores. The refinement keeps downstream compatibility intact. It does not by itself improve VLM accuracy without re-alignment.

Vision encoderRel. ΔW/T/LAI2DPOPERefCOCOgV*MME-cMME-pSQA-ImgOCRBenchTextVQA
OpenAI CLIP––52.7585.2020.6741.36320.001350.7967.6327.8034.57
KUEA−1.23%3/0/652.3085.4620.5038.74317.141350.8266.6827.4034.69
CLIP-Refine−0.95%3/0/652.2085.5720.6139.79308.211345.9767.7227.6034.84
ComCLIP+0.02%4/2/352.7585.1420.6341.36307.501373.4767.8228.2034.89

LLaVA-1.5-7B with a swapped ViT-L/14 encoder; LLM and projector frozen. Rel. Δ is the mean per-benchmark relative change against OpenAI CLIP; W/T/L counts improved/tied/degraded scores. Best per column in bold.

ScopeLimitations

  • ComCLIP targets CLIP-like models with a shared image-text contrastive space. The temperature analysis covers InfoNCE only, not CLIP-Refine's KL-based self-distillation or SigLIP's sigmoid loss.
  • MMVP has only 135 pairs and large seed variance. The MMVP gain over CLIP-Refine is significant only on ViT-L/14, and generative enhancement methods report higher MMVP.
  • Downstream evaluation uses one VLM configuration (LLaVA-1.5-7B with a frozen projector and LLM). Whether re-alignment turns the linear-probe gains into VLM gains is untested.
  • Gains are not monotone in corpus size (CC12M is not better than CC3M on linear probing), and training runs a frozen CLIP copy and a DINOv2 teacher forward at every step.

BibTeX

@inproceedings{wang2026rethinking,
  title     = {Rethinking Contrastive Loss in CLIP Post-training: A Complementary Framework with Frozen Text Encoder},
  author    = {Wang, Zidan and Li, Yaqian and Zhang, Xiaokai and Long, Kaiwen and He, Kun and Liu, Hanpeng},
  booktitle = {Advances in Neural Information Processing Systems (NeurIPS)},
  year      = {2026}
}