NEURIPS 2026

UniCon Unified Framework for Efficient Contrastive Alignment via Kernels

Hangke Sui1,3* Yuqing Wang2,3* Minh N. Do1,2,3,4

* Underlined names: equal contribution

1Electrical & Computer Engineering, UIUC  ·  2Siebel School of Computing and Data Science, UIUC
3Coordinated Science Laboratory, UIUC  ·  4VinUni-Illinois Smart Health Center
TL;DR  Training with a contrastive loss only tracks the top-r singular subspace of a weighted cross-covariance. UniCon builds that operator explicitly through a contrastive similarity weight matrix \(S(\gamma)\) and solves alignment in closed form — one SVD for linear encoders, a kernelized SVD for nonlinear ones — instead of thousands of SGD steps.
UniCon overview
UniCon builds \(S(\gamma)\) from the hyperspherical similarities of a batch and then performs either a closed-form SVD update (linear encoders, orange) or a kernelized update (nonlinear encoders, blue).

Overview

Highlights

One spectral characterization covers linear and kernel encoders, and every loss in the contrastive family.

0 SGD
Closed-form solution

The optimum is a best rank-r approximation. No backpropagation and no learning rate.

Unified
Linear and kernel

Linear encoders are the linear-kernel case of one RKHS spectral characterization.

Any loss
Contrastive family

CLIP / InfoNCE, triplet, sigmoid, and many-to-many alignment via \((\psi,\phi,\nu,\epsilon)\).

461×
Faster training

Seconds instead of hours on MSCOCO, with competitive or better retrieval.

Paper

Abstract

Contrastive objectives power state-of-the-art multimodal models, but their training remains slow, relying on long stochastic optimization. We propose a Unified Framework for Efficient Contrastive Alignment via Kernels (UniCon), which spans linear and nonlinear encoders as well as one-to-one and many-to-many alignments. At its core, UniCon introduces the contrastive similarity weight matrix \(S(\gamma)\), which enables closed-form global solutions that provably replace minibatch back-propagation with exact updates. Through the lens of reproducing kernel Hilbert spaces (RKHS), UniCon provides a kernelized perspective that unifies contrastive alignment and reveals its connection to spectral methods. To validate the theory, we conduct experiments on synthetic, unimodal, multimodal, and zero-shot tasks, demonstrating that UniCon achieves substantial efficiency gains while preserving generality and strong empirical performance.

Approach

Method

Similarity, then \(S(\gamma)\), then one spectral update. The fixed point settles in a couple of steps.

1
A unified contrastive loss

CLIP, InfoNCE, triplet, and SupCon-style losses are instances of one family, set by \(\psi,\phi\), the positive weight \(\nu\), and pair weights \(\epsilon_{ij}\).

2
Contrastive similarity weight \(S(\gamma)\)

Its gradient equals that of a trace objective weighted by \(S(\gamma)\): positive pairs are pulled, negatives are pushed.

3
Closed-form spectral update

The trace objective is maximized by a best rank-r approximation, in the ambient space or in an RKHS.

Generalized contrastive loss

For a batch with hyperspherical similarities \(s_{ij} = \langle f_{\theta_1}(x_i), f_{\theta_2}(y_j)\rangle\) and positive sets \(P_x(i)\), \(P_y(j)\):

$$\mathcal{L} = \frac{1}{2n}\sum_{i=1}^n \frac{1}{|P_x(i)|}\sum_{k\in P_x(i)} \phi\Big(\sum_{j\notin P_x(i)} \epsilon_{ij}\,\psi(s_{ij}-\nu s_{ik}) + \epsilon_{ik}\,\psi\big((1-\nu)s_{ik}\big)\Big) \;+\; (\text{same for } y) .$$

Lemma (gradient equivalence)

With the contrastive similarity weight matrix \(S(\gamma) = -\frac{1}{n}\sum_{i,j}\tfrac12\big(\tfrac{\gamma_{ij}}{|P_x(i)|}+\tfrac{\bar\gamma_{ji}}{|P_y(j)|}\big)e_ie_j^\top\),

$$\frac{\partial \mathcal{L}}{\partial \theta_k} = -\,\frac{\partial\, \mathrm{tr}\big(F_{\theta_1}(X)\, S(\gamma)\, F_{\theta_2}(Y)^\top\big)}{\partial \theta_k}\bigg|_{\gamma=\gamma(\theta_1,\theta_2)}, \qquad k\in\{1,2\}.$$

Minimizing the contrastive loss is therefore maximizing \(\mathrm{tr}(F_{\theta_1}(X) S(\gamma) F_{\theta_2}(Y)^\top) - \tfrac{\rho}{2}\|\cdot\|_F^2\), whose maximizers are known in closed form:

LINEAR ENCODERS $$\begin{aligned} C(\gamma) &= X S(\gamma) Y^\top = U\Sigma V^\top \\ F_1^\top F_2 &= \frac{1}{\rho}\sum_{i=1}^r \sigma_i u_i v_i^\top \end{aligned}$$
KERNEL ENCODERS (RKHS) $$\begin{aligned} M &= K_X^{1/2} S(\gamma) K_Y^{1/2} \\ AB^\top &= \frac{1}{\rho} K_X^{-1/2}\,[M]_r\,K_Y^{-1/2} \end{aligned}$$

Because \(S(\gamma)\) depends on the current encoders, UniCon alternates similarity → \(S(\gamma)\) → spectral update. Mini-batch solutions are fused with validation weights.

The core in code

The method rests on two functions in unicon/core/s_gamma.py: compute_S_gamma (one-to-one, Listing 1) and compute_S_gamma_generalized (many-to-many, Listing 2). The solvers only add the SVD.

from unicon import compute_S_gamma, clip_loss, LinearUniCon, KernelUniCon

S = compute_S_gamma(s, **clip_loss(tau=1.0).s_gamma_kwargs)  # (n, n) contrastive similarity weights
C = X.T @ S @ Y                                              # weighted contrastive cross-covariance

model = LinearUniCon(r=128).fit(X, Y, batch_size=4096, n_iters=2)  # Algorithm 1
model = KernelUniCon(r=10, kernel="angular").fit(X, Y, batch_size=30)  # Algorithm 2

Experiments

Results

Closed-form alignment matches or beats SGD-CLIP, in seconds rather than hours.

Seconds instead of hours

Training time of UniCon vs SGD-CLIP
Wall-clock training time reported in the paper (single NVIDIA L40S).

One spectral step reaches what SGD reaches after many epochs

Accuracy vs. training time
Test matching accuracy vs. wall-clock time on the synthetic latent-factor models. UniCon (★) is a single closed-form solve; SGD-CLIP is trained with AdamW.

Aligned representations

t-SNE of the shared space
Linear latent-factor model with three clusters. Two modalities in different spaces (left) are mapped into one shared space. SGD-CLIP and UniCon recover the same aligned, cluster-preserving structure. UniCon does it in a single spectral step.
Evolution of S(gamma)
Evolution of \(S(\gamma)\) for the nonlinear model, from a random initial similarity. The positive (diagonal) and negative weights settle within a couple of updates.

Image–text retrieval on Flickr30K

BackboneMethodTrain timeI→T R@1I→T R@10T→I R@1T→I R@10
RN-18 + SBERTSGD-CLIP45.6 s.043.221.041.217
UniCon1.7 s.020.145.087.361
RN-50 + SBERTSGD-CLIP45.0 s.043.221.041.217
UniCon0.81 s.134.464.188.567
CLIP ViT-B/32SGD-CLIP45.3 s.231.595.241.600
UniCon0.76 s.284.636.421.777

MSCOCO and zero-shot transfer to Flickr30K

BackboneMethodTrain timeI→T R@1I→T R@10T→I R@1T→I R@10Flickr30K R@5 (I→T / T→I)
RN-50 + SBERTSGD-CLIP5121.72 s.053.253.060.286—
UniCon11.11 s.105.388.129.439.171 / .249
CLIP ViT-B/32SGD-CLIP1066.60 s.128.415.123.427—
UniCon11.15 s.329.685.292.644.808 / .766

All models are trained on MSCOCO. Flickr30K is evaluated without any adaptation. Highlighted rows are UniCon.

Cite

BibTeX

@inproceedings{sui2026unicon,
  title     = {UniCon: Unified Framework for Efficient Contrastive Alignment via Kernels},
  author    = {Sui, Hangke and Wang, Yuqing and Do, Minh N.},
  booktitle = {Advances in Neural Information Processing Systems (NeurIPS)},
  year      = {2026}
}