Identifiable Contrastive Learning with Automatic Feature Importance Discovery

Qi Zhang, Yifei Wang, Yisen Wang

Contrastive learning (CL) has become the gold standard for self-supervised representation learning. By teaching models to "pull" similar images together and "push" different ones apart, researchers have achieved state-of-the-art performance without relying on millions of manual labels. However, these learned features often operate as a "black box." They lack identifiability—meaning every time a model is trained, it yields a different set of features—and they lack interpretability, as the importance of individual dimensions remains obscured.

In their NeurIPS 2023 paper, researchers from Peking University introduce Tri-factor Contrastive Learning (triCL). This simple yet elegant modification forces models to discover and rank features by their semantic importance, solving key theoretical flaws in standard contrastive learning.

The Problem with Standard Contrastive Learning

Standard contrastive learning relies on a 2-factor similarity check: the dot product between two feature vectors ($z_x^\top z_{x'}$). While highly effective in practice, this approach suffers from two major theoretical shortcomings:

  1. Lack of Identifiability: The optimal solution is not unique. A model can apply any arbitrary linear transformation (like rotation or scaling) to the features and still achieve the exact same loss. Consequently, the features are "coupled" and change with every training run. This makes them unreliable for sensitive downstream tasks such as causal inference or fair classification.
  2. Feature Ambiguity: In a standard 512-dimensional embedding, it is impossible to know which dimension represents a core concept like "shape" and which represents background "noise." Standard CL treats all dimensions equally, preventing efficient feature selection without additional supervision.

The triCL Solution: A 3-Factor Approach

To address these issues, the authors propose a "3-factor" contrast. Instead of a simple dot product, they introduce a learnable diagonal matrix $S$:

$$\text{Similarity} = z_x^\top S z_{x'}$$

Here, $S = \text{diag}(s_1, \dots, s_k)$ contains learnable weights for each feature dimension. To make this mechanism work effectively, the method combines two key components:

  • The triCL Objective: A modified contrastive loss that uses the $S$ matrix to weight the importance of each dimension. This objective is highly versatile and compatible with existing frameworks like SimCLR, CLIP, or Spectral CL.
  • Decorrelation Penalty: A loss term ($L_{dec}$) is added to force different feature dimensions to be uncorrelated.

By forcing features to be decorrelated while simultaneously learning their weights in $S$, the model is incentivized to pack the most useful information into specific dimensions. The dimensions associated with larger values in $S$ naturally become the most semantically meaningful.

Key Insights: Breaking Symmetry and Automatic Ranking

The $S$ matrix acts as a crucial symmetry-breaker. In standard CL, the model does not care which dimension holds which information. In triCL, the model is driven to place the most important information in the dimensions with the highest $s_i$ values to minimize the loss most efficiently.

Normalized diagonal values of the importance matrix S, sorted by magnitude.

Because of this dynamic, you do not need to manually instruct the model on which features are important. After training, you can simply sort the dimensions by their values in $S$. The top dimensions capture high-level, distinct concepts (like specific animal classes or objects), while the bottom dimensions capture less relevant information or noise. Furthermore, the paper mathematically proves that triCL moves beyond mere "linear identifiability" to "exact identifiability" (up to a sign). This ensures that the features are truly reproducible across different initializations.

Experimental Results

The authors validated triCL across several standard computer vision benchmarks, including CIFAR-10, CIFAR-100, and ImageNet-100, yielding impressive results:

  • Reproducibility: In synthetic tests, 10 different runs of standard CL produced significantly different feature sets. In stark contrast, 10 runs of triCL produced identical solutions (a Euclidean distance of 0).
  • Efficiency in Retrieval: On ImageNet-100, using just the top 50 dimensions discovered by triCL achieved nearly the same image retrieval accuracy as using the full 512-dimensional vector. Standard methods showed a massive performance drop when dimensions were similarly truncated.
k-NN accuracy vs. the number of top dimensions used, showing that top-ranked features retain most of the performance.
  • Semantic Clarity: Visualizing the "most important" dimensions showed they consistently activated on specific object classes. Conversely, the "least important" dimensions appeared to capture random background noise or textures.
  • Benchmark Performance: triCL matched or slightly outperformed baselines like SimCLR and CLIP on standard linear probing and finetuning. This proves that adding interpretability and identifiability does not require sacrificing overall accuracy.

Limitations and Future Directions

While triCL is a powerful and lightweight extension, the authors note a few areas for further exploration. Currently, $S$ is restricted to a diagonal matrix. While this ensures simplicity and interpretability, exploring non-diagonal structures might capture more complex feature interactions. Additionally, the balance between the contrastive loss and the decorrelation penalty ($L_{dec}$) is crucial for stability, requiring careful hyperparameter tuning. Finally, while successfully tested on ImageNet-100, applying triCL to "foundation model" scales (e.g., full ImageNet-21k or LAION) will be an exciting next step to see if the feature discovery remains as clean at a massive scale.

Project Code: GitHub - PKU-ML/Tri-factor-Contrastive-Learning

Summary updated

BibTeX
@inproceedings{zhang2023identifiable,
  author = {Qi Zhang and Yifei Wang and Yisen Wang},
  title = {{Identifiable Contrastive Learning with Automatic Feature Importance Discovery}},
  booktitle = {Advances in Neural Information Processing Systems},
  year = {2023},
  url = {https://openreview.net/forum?id=BQA7wR2KBF},
}
Figure