TL;DR
While CLIP’s ability to generalize to out-of-distribution data is legendary, this paper reveals that its "magic" depends heavily on the diversity of visual domains in its training set. Surprisingly, partially seeing a domain can actually make a model worse at recognizing new classes within that same domain—a failure of compositional generalization traced back to a lack of shared internal "circuits" within the model.
Introduction
Contrastive Vision-Language Models (VLMs) like CLIP have revolutionized zero-shot classification, showing unprecedented robustness to Out-of-Distribution (OOD) data. Most researchers attribute this to the massive diversity of CLIP's training data, but the exact mechanisms remain fuzzy.
The authors tackle two specific types of generalization:
- Domain Generalization (DG): Can CLIP recognize an object (e.g., a dog) in an entirely unseen style (e.g., a sketch) if it has seen other styles (paintings, clipart)?
- Compositional Generalization (CG): If CLIP has seen sketches of cats and natural images of dogs, can it recognize a sketch of a dog?
The challenge is that simply adding "more data" isn't always the answer. The paper investigates whether CLIP learns generalizable features that work across domains or if it relies on "shortcuts" that fail when faced with new combinations of concepts and styles.
Methods and Experimental Setup
Moving away from solely analyzing pre-trained models, the researchers retrained CLIP from scratch on systematically controlled data mixtures. They varied domain diversity (how many styles are seen) and class exposure (which objects are seen in which styles).
As illustrated above, they compared several training setups:
- Natural-only: A baseline trained only on natural images.
- Leave-out-domain: Tests Domain Generalization by holding out the test domain entirely.
- CG low-diversity / high-diversity: Tests Compositional Generalization by including the test domain during training, but only for a subset of classes.
To understand the internal mechanisms driving these results, they employed three sophisticated analysis techniques:
- Sparse Autoencoders (SAEs): Used to extract interpretable features from the model's visual embeddings.
- Representational Similarity Analysis (CKA): To measure how similar the internal representations of the same class are across different domains.
- Mechanistic Similarity: A novel approach identifying "circuits"—specific paths of neurons and their interactions—responsible for a prediction, measuring how much these circuits are shared between different domains.
Key Insights and Results
The "Seen Class Bias" and DG vs. CG
One of the most counter-intuitive findings is that seeing a subset of classes in a test domain (e.g., sketches of cats) can actually result in lower accuracy on unseen classes (sketches of dogs) compared to a model that never saw sketches at all. The model learns a "shortcut" (e.g., "this specific sketch-texture means cat") rather than a general understanding of the "sketch" domain.
Consequently, in many cases, Domain Generalization (extrapolating to a completely new domain) was actually stronger than Compositional Generalization (interpolating within a partially seen domain). As seen in the performance charts, the "Leave-out-domain" setup often outperformed the "CG low-diversity" setup.
Domain Diversity is Non-Negotiable
High domain diversity is essential for both DG and CG. However, not all domains are equal. Adding "Sketch" images helps the model generalize to "Clipart," but once "Sketch" is included, adding "Quickdraw" provides diminishing returns because they share too many visual features. By ensuring the classes seen in a specific domain during training do not overlap with the classes queried at test time, the authors were able to significantly improve performance (e.g., Sketch accuracy jumped from 19.5% to 36.9%).
Generalization = Circuit Sharing
The authors show that when CLIP generalizes well, it uses the same internal "circuits" across different domains. If a model develops a "private" circuit for a specific domain, it fails to generalize to new classes in that domain because it hasn't learned to align that domain's features with its broader knowledge base.
A prime example is the "Quickdraw" domain (very simple line drawings). It consistently showed the lowest "mechanistic similarity" to other domains (0.218 vs 0.28 for others). Because CLIP struggled to share circuits with this highly abstract domain, it failed to generalize to Quickdraw even with high-diversity training.
Limitations and Future Work
The primary limitation of this study is scale. While the authors validated their findings up to 10M samples, the original CLIP was trained on 400M+ images. It’s possible that at extreme scales, some of these "shortcut" behaviors are smoothed out.
Additionally, the "Quickdraw" domain remains an outlier; the model's inability to share features with such a sparse domain suggests limits to the types of visual abstractions CLIP can bridge. Future work could apply the "mechanistic similarity" framework to Large Language Models (LLMs) to see if they share similar "circuits" when processing different languages or reasoning tasks.
Summary updated