Contrastive Learning Is Spectral Clustering On Similarity Graph
Zhiquan Tan, Yifan Zhang, Jingqin Yang, Yang Yuan
TL;DR
This work proves that InfoNCE-based contrastive learning (e.g., SimCLR) is equivalent to spectral clustering on the augmentation-derived similarity graph, and extends the theory to multi-modal CLIP, yielding a representation-theoretic view of embedding as spectral clustering on a pair graph. Building on a Markov random field framework and a maximum-entropy argument, the authors introduce Kernel-InfoNCE, using mixtures of exponential kernels to better capture local similarity, and derive practical kernel choices such as Simple Sum and Concatenation Sum. Empirically, Kernel-InfoNCE improves over Gaussian-kernel SimCLR on CIFAR-10/100 and TinyImageNet, and LaCLIP is discussed as a natural extension to enhance cross-modal clustering. The work provides reproducible code and a cohesive theoretical lens for understanding and improving contrastive learning across single- and multi-modal settings.
Abstract
Contrastive learning is a powerful self-supervised learning method, but we have a limited theoretical understanding of how it works and why it works. In this paper, we prove that contrastive learning with the standard InfoNCE loss is equivalent to spectral clustering on the similarity graph. Using this equivalence as the building block, we extend our analysis to the CLIP model and rigorously characterize how similar multi-modal objects are embedded together. Motivated by our theoretical insights, we introduce the Kernel-InfoNCE loss, incorporating mixtures of kernel functions that outperform the standard Gaussian kernel on several vision datasets. The code is available at https://github.com/yifanzhang-pro/Kernel-InfoNCE.
