Abstract
Unsupervised representation learning has recently received lots of interest due to its powerful generalizability through effectively leveraging large-scale unlabeled data. There are two prevalent approaches for this, contrastive learning and generative pre-training, where the former learns representations from instance-wise discrimination tasks and the latter learns them from estimating the likelihood. These seemingly orthogonal approaches have their own strengths and weaknesses. Contrastive learning tends to extract semantic information and discards details irrelevant for classifying objects, making the representations effective for discriminative tasks while degrading robustness to out-of-distribution data. On the other hand, the generative pre-training directly estimates the data distribution, so the representations tend to be robust but not optimal for discriminative tasks. In this paper, we show that we could achieve the best of both worlds by a hybrid training scheme. Specifically, we demonstrated that a transformer-based encoder-decoder architecture trained with both contrastive and generative losses can learn highly discriminative and robust representations without hurting the generative performance. We extensively validate our approach on various tasks.
Introduction
In the field of unsupervised representation learning, two paradigms have traditionally dominated: Contrastive Learning (e.g., SimCLR) and Generative Pre-training (e.g., iGPT). Contrastive learning excels at capturing high-level semantic features for downstream classification but often lacks robustness to distribution shifts. Conversely, generative models learn the underlying data distribution, providing robustness, but are typically less efficient at extracting discriminative features.
The Hybrid Generative-Contrastive Representation Learning (GCRL) framework, presented by researchers from Kakao Brain and KAIST, bridges this gap. By jointly optimizing for both objectives within a single transformer-based architecture, GCRL achieves highly discriminative representations that remain robust to out-of-distribution data.
Methodology
The core of GCRL is a transformer-based encoder-decoder architecture designed to handle dual objectives simultaneously.
Architecture and Hybrid Loss
The model reinterprets standard transformer blocks by splitting them: the first $N/2$ blocks serve as the encoder, while the remaining blocks act as the decoder. This separation allows the model to optimize two distinct losses:
- Contrastive Loss ($\mathcal{L}_c$): Applied to the pooled representations from the encoder. It uses the SimCLR framework to compare "positive" pairs (different views of the same image) against "negative" pairs.
- Generative Loss ($\mathcal{L}_g$): Applied to the output of the decoder. It utilizes an autoregressive approach, predicting the next pixel in a raster scan to estimate data likelihood.
Asymmetric Augmentation
A critical innovation in GCRL is the use of asymmetric augmentation. While contrastive learning thrives on strong augmentations (like color jittering and grayscale), these distortions can hinder generative modeling. In GCRL, the encoder processes both weakly and strongly augmented views, but the decoder only attempts to reconstruct the weakly augmented version. This ensures the generative task focuses on realistic data distributions while the contrastive task learns invariant semantic features.
Axial Attention
To manage the computational complexity of transformers on image data, GCRL employs Axial Attention. This technique decomposes global attention into sequential row-wise and column-wise operations, allowing the model to capture long-range spatial dependencies efficiently.
Experimental Results
The authors evaluated GCRL on benchmarks including CIFAR-10/100, ImageNet32, and SVHN, focusing on linear evaluation, robustness, and generative quality.
Performance and Robustness
GCRL demonstrates superior performance across the board. On ImageNet32 linear evaluation, GCRL achieved 43.6% accuracy, outperforming both pure iGPT (41.9%) and SimCLR (38.6%). Its robustness is particularly evident in Out-of-Distribution (OOD) detection; when trained on ImageNet32 and tested on SVHN, GCRL achieved an AUROC of 0.9982, significantly surpassing pure contrastive models.
Generative Quality
Despite the added complexity of the contrastive objective, GCRL maintains high generative performance. The model's ability to generate realistic images remains competitive with pure generative models, proving that discriminative learning does not have to come at the cost of modeling the data distribution.
Conclusion
GCRL successfully demonstrates that generative and contrastive learning are complementary. By employing an encoder-decoder split and asymmetric augmentation, the framework achieves a "best of both worlds" scenario: representations that are both highly discriminative for classification and robust for out-of-distribution tasks. Future research will look toward scaling these hybrid benefits to higher-resolution images and non-transformer architectures.
Summary updated