CLEAR: Contrastive & Anti-contrastive Regularization
- The paper introduces CLEAR, a framework that uses supervised contrastive learning on content latents and an anti-contrastive Pair-Switching penalty on style latents.
- CLEAR leverages a VAE with a split latent space, applying a soft nearest neighbor loss for content and a pair-switched loss for style to enhance semantic disentanglement.
- The method enables practical latent manipulation—such as content-style swapping and interpolation—to improve robustness against spurious style–content associations in out-of-distribution scenarios.
Searching arXiv for the CLEAR paper and closely related contrastive/anti-contrastive work to ground the article in current literature. arxiv_search(query="CLEAR anti-contrastive regularization style content associations", max_results=10) arxiv_search(query="Contrastive LEarning with Anti-contrastive Regularization (Sun et al., 24 Jul 2025)", max_results=10) arxiv_search(query="AdCo adversarial contrast (Hu et al., 2020)", max_results=5) Contrastive Learning with Anti-contrastive Regularization (CLEAR) is a weakly supervised representation-learning framework designed to separate task-relevant content from task-irrelevant style under distribution shifts in superficial attributes. In CLEAR, a supervised contrastive objective is applied to content latents so that they retain label information, while an anti-contrastive penalty called Pair-Switching (PS) is applied to style latents so that they become uninformative about labels. The framework is instantiated in a Variational Auto-Encoder (VAE), yielding CLEAR-VAE, which supports content–style swapping and interpolation and improves downstream prediction when test data contain previously unseen combinations of content and style (Sun et al., 24 Jul 2025).
1. Problem setting and semantic decomposition
CLEAR assumes that an input can be decomposed into content and style . Content denotes information directly related to the downstream outcome label , whereas style denotes task-irrelevant superficial attributes that may nevertheless correlate with content in the training distribution (Sun et al., 24 Jul 2025). The central failure mode is a spurious style–content association: models trained on observational data can use style as a shortcut for predicting , then fail when they encounter unseen style combinations at test time.
The framework explicitly targets distribution shifts in style for fixed content. Training data cover only a subset of content–style combinations, and the test set contains disjoint style subsets for each content class. Under this protocol, the desired representation should preserve label information in while forcing to be independent of (Sun et al., 24 Jul 2025).
The paper illustrates this decomposition on several datasets.
| Dataset | Content label | Style |
|---|---|---|
| Styled-MNIST | Digit identity | Corruption type |
| Colored-MNIST | Digit identity | Digit color |
| PACS | Object category | Domain |
| CelebA | Gender smiling | Hair color + other attributes |
| Camelyon17-WILDS | Gender 0 tumor/normal | Staining and hospital/site-specific characteristics |
This formulation is narrower than generic invariance learning. CLEAR does not merely seek robustness to nuisance variation; it specifies a semantic partition of the latent space and uses the supervised label to control which information is encouraged or suppressed. A common misconception is that anti-contrastive regularization eliminates contrastive learning. In CLEAR, the opposite is true: supervised contrastive learning is retained for content, and the anti-contrastive component acts only on style (Sun et al., 24 Jul 2025).
2. Objective: supervised contrastive content learning and Pair-Switching
CLEAR combines a contrastive objective on 1 with a pair-switched anti-contrastive objective on 2. For a batch of size 3, content latents 4, labels 5, cosine similarity 6, and temperature 7, the modified Soft Nearest Neighbor loss is
8
with
9
0
Minimizing 1 pulls together same-label content embeddings and pushes apart different-label content embeddings (Sun et al., 24 Jul 2025).
A naïve attempt to minimize label information in style would reverse this objective by maximizing a standard style contrastive loss or minimizing its negative. The paper identifies two problems with that route: 2 is unbounded below, making the total objective unstable, and minimizing a lower bound does not provide a clean guarantee on 3 (Sun et al., 24 Jul 2025).
CLEAR addresses this with Pair-Switching, which swaps the role of positive and negative pairs in a stable supervised contrastive form. The practical style loss is
4
where 5 and 6 are defined from 7 using the same label partitions as above. This pair-switched form rewards style embeddings that are similar across different labels and therefore unstructured with respect to 8 (Sun et al., 24 Jul 2025).
The full training loss is
9
where 0 is a 1-VAE objective and 2 weight the contrastive and anti-contrastive terms. In experiments, the paper typically sets 3 (Sun et al., 24 Jul 2025).
3. Mutual-information interpretation
The theoretical core of CLEAR is an information-theoretic asymmetry: maximize label information in content and minimize label information in style. Under the CLEAR generative model with independent priors for 4 and 5, the paper derives an ELBO whose final term behaves like a mutual-information term involving 6 and 7. Using an InfoNCE-style approximation, the paper states that minimizing a content InfoNCE objective corresponds to maximizing 8, and then derives the practical SNN objective from that construction (Sun et al., 24 Jul 2025).
For style, the key theoretical claim is stronger. The pair-switched InfoNCE objective is
9
and the paper shows that
0
It then states that the practical PS-SNN loss is a looser upper bound:
1
Accordingly, minimizing 2 directly reduces 3 up to the additive 4 constant (Sun et al., 24 Jul 2025).
This mutual-information view clarifies the meaning of “anti-contrastive” in CLEAR. The penalty is not an adversarial discriminator on style, nor a generic decorrelation penalty between latent groups. It is a label-conditioned regularizer that explicitly makes the style representation uninformative about 5. The paper contrasts this with alternatives such as TC, CLUB, and L1OutUB, which minimize 6 and only indirectly affect 7 through data processing inequality (Sun et al., 24 Jul 2025).
The paper also notes a theoretical caveat: the connection between SNN or multi-positive supervised-contrastive losses and mutual information is empirical rather than fully formalized, even though the InfoNCE bound itself is clear (Sun et al., 24 Jul 2025). That limitation matters because CLEAR’s asymmetry is strongest at the PS-InfoNCE level and somewhat looser at the practical PS-SNN level.
4. CLEAR-VAE architecture and training procedure
CLEAR is instantiated as CLEAR-VAE. The encoder 8 partitions the latent into
9
with independent Gaussian priors
0
and the decoder reconstructs 1 from both parts via 2 (Sun et al., 24 Jul 2025). The VAE component is
3
The reconstruction term ensures that 4 and 5 jointly retain the information needed to reconstruct the input, while the contrastive and anti-contrastive terms determine which semantics populate which subspace (Sun et al., 24 Jul 2025).
Pair construction is label-driven rather than augmentation-driven. For content SNN, positive pairs are all pairs with 6, and negatives are all pairs with 7. For style PS-SNN, the same partitions are used, but the numerator favors cross-label similarity. The paper reports that cosine similarity between normalized latent means works better than Mahalanobis or Jeffrey divergences in this setting (Sun et al., 24 Jul 2025).
Architecturally, the encoders are CNN stacks of Conv2D–BatchNorm–ReLU blocks, with depth depending on image size; decoders are symmetric ConvTranspose2D–BatchNorm–ReLU stacks. The latent dimension is dataset-dependent, typically between 16 and 64, with a split between content and style dimensions. The paper reports that 8 gives the best disentanglement behavior, because too large a 9 over-factorizes individual latent dimensions and harms semantic disentanglement. Values such as 0 worked well for SNN and PS-SNN, whereas large 1 such as 1 can cause loss of detail and numerical instability in adversarial variants (Sun et al., 24 Jul 2025).
Ablations on Styled-MNIST show a three-way distinction. A plain 2-VAE yields group Mutual Information Gap near zero; an SNN-only model clusters content by labels but leaves content information in style; and the full CLEAR-VAE with SNN plus PS-SNN gives the best separation in t-SNE, with clear label-based clustering in 3 and style clusters independent of label in 4 (Sun et al., 24 Jul 2025). The paper therefore treats both terms as necessary.
5. Representation control, evaluation protocol, and empirical behavior
Because CLEAR separates content and style latents, it enables direct latent manipulation. Given two samples 5 and 6, one may decode 7 to preserve the content of 8 while transferring the style of 9, or swap content by using 0 (Sun et al., 24 Jul 2025). The same factorization supports interpolation in either subspace: interpolate 1 while fixing 2, or interpolate 3 while fixing 4. The paper reports that content interpolation changes digit identity or face expression and gender while keeping background or facial style constant, whereas style interpolation changes corruption, color, background, hair, or domain while preserving content.
For quantitative evaluation, the paper pre-trains each VAE variant, freezes the encoder, trains a small MLP on 5, and evaluates under unseen content–style combinations. For Styled-MNIST, Colored-MNIST, PACS, and CelebA, each content class is assigned a disjoint set of styles at training and testing. For Camelyon17-WILDS, the standard train–test split is used, where test hospitals are out-of-distribution (Sun et al., 24 Jul 2025).
On Camelyon17-WILDS, CLEAR-PS outperforms the plain CNN baseline and the LAM domain-generalization baseline on all reported metrics.
| Model | Acc (mean±sd) | AUC | AP |
|---|---|---|---|
| Vanilla CNN | 0.638 ± 0.022 | 0.713 ± 0.030 | 0.667 ± 0.046 |
| LAM | 0.713 ± 0.012 | 0.804 ± 0.025 | 0.791 ± 0.012 |
| CLEAR-PS | 0.747 ± 0.019 | 0.832 ± 0.019 | 0.804 ± 0.027 |
The paper also reports that contrastive VAE encoders consistently outperform group-based VAEs such as MLVAE and GVAE in out-of-distribution settings, with larger gains when training sees fewer styles per content class or when style–content correlation is high (Sun et al., 24 Jul 2025).
To quantify semantic disentanglement, the paper introduces group Mutual Information Gap (gMIG),
6
High gMIG means the content group carries more label information than the style group. The paper reports that a plain 7-VAE tends to have gMIG near zero, while CLEAR variants have significantly higher gMIG, indicating successful semantic-level disentanglement (Sun et al., 24 Jul 2025).
These results support a specific interpretation of robustness. CLEAR is not merely learning invariant features in the usual contrastive sense; it is reallocating predictive and nuisance information across two latent groups. A plausible implication is that the method is especially appropriate when “style” corresponds to demographic, institutional, or domain variables that are spuriously correlated with the label in training data.
6. Relation to adjacent contrastive methods, disambiguation, and limitations
CLEAR belongs to a broader family of methods that modify contrastive geometry, but its mechanism is distinct. AdCo learns a global set of trainable negative adversaries in a min–max game, thereby changing the negative distribution itself; CLEAR instead keeps a supervised contrastive objective on content and applies an anti-contrastive regularizer to the style subspace, with the explicit goal of minimizing 8 (Hu et al., 2020). This difference is substantive: AdCo is feature-level adversarial negative learning, whereas CLEAR is semantic subspace allocation.
Other related methods illuminate adjacent design choices. “Contrastive Regularization for Semi-Supervised Learning” uses pseudo-label-aware attraction and repulsion to propagate label information through unlabeled clusters (Lee et al., 2022). “Context-Enriched Contrastive Loss” introduces a self-based regularizer that counters label-driven distortion by insisting that two views of the same instance remain the closest pair (Deng et al., 1 Dec 2025). “Your contrastive learning problem is secretly a distribution alignment problem” recasts CLEAR-like anti-contrastive regularization as modified target transport plans, modified costs, or unbalanced optimal transport that allow non-zero off-diagonal mass for selected pairs (Chen et al., 27 Feb 2025). “Contrasting the landscape of contrastive and non-contrastive learning” argues that repulsive structure is important because non-contrastive objectives admit abundant non-collapsed bad minima (Pokle et al., 2022). “Unleashing the Power of Contrastive Self-Supervised Visual Models via Contrast-Regularized Fine-Tuning” shows that contrastive regularization can also be useful at fine-tuning time, especially for reducing intra-class scattering inherited from instance-discriminative pretraining (Zhang et al., 2021).
The term CLEAR is itself overloaded. The 2020 paper “CLEAR: Contrastive Learning for Sentence Representation” studies sentence-level contrastive pre-training with textual augmentations and does not introduce anti-contrastive regularization (Wu et al., 2020). In current usage, “CLEAR” may therefore refer either to the sentence-representation method or to the 2025 style–content disentanglement framework; the latter is the subject here.
The 2025 CLEAR paper also states several limitations. The method is currently implemented only with VAEs on image data; its theoretical mutual-information account is strongest for InfoNCE and less formal for multi-positive SNN; and the framework assumes that content is well captured by the available supervised label and that style is ideally independent of that label in an unbiased population (Sun et al., 24 Jul 2025). These assumptions delimit the scope of the method. When the content–style split is ill-defined, or when the provided label is itself a biased proxy, the semantics of anti-contrastive regularization become less clear.
Within those limits, CLEAR provides a concrete instantiation of a broader idea in contemporary contrastive learning: representation quality can be improved not only by strengthening attraction and repulsion, but also by specifying where label information should reside and where it should not.