Contrastive Corpus Attribution for Explaining Representations

Chris Lin, Hugh Chen, Chanwoo Kim, Su-In Lee

Abstract

Despite the widespread use of unsupervised models, very few methods are designed to explain them. Most explanation methods explain a scalar model output. However, unsupervised models output representation vectors, the elements of which are not good candidates to explain because they lack semantic meaning. To bridge this gap, recent works defined a scalar explanation output: a dot product-based similarity in the representation space to the sample being explained (i.e., an explicand). Although this enabled explanations of unsupervised models, the interpretation of this approach can still be opaque because similarity to the explicand's representation may not be meaningful to humans. To address this, we propose contrastive corpus similarity, a novel and semantically meaningful scalar explanation output based on a reference corpus and a contrasting foil set of samples. We demonstrate that contrastive corpus similarity is compatible with many post-hoc feature attribution methods to generate COntrastive COrpus Attributions (COCOA) and quantitatively verify that features important to the corpus are identified. We showcase the utility of COCOA in two ways: (i) we draw insights by explaining augmentations of the same image in a contrastive learning setting (SimCLR); and (ii) we perform zero-shot object localization by explaining the similarity of image representations to jointly learned text representations (CLIP).

The Challenge of Explaining Unsupervised Models

Supervised models are relatively straightforward to explain because they output human-understandable scalars, such as the "probability of being a dog." Feature attribution methods like Saliency Maps or SHAP can then identify which input features drove that specific probability.

In contrast, unsupervised models—which are increasingly dominant in modern AI—output high-dimensional representation vectors. These vectors lack inherent semantic meaning; an individual element in a 512-dimensional vector does not correspond to a discrete human concept. Recent attempts to explain these models have focused on "explicand-centric" similarity—essentially asking, "What features make this image similar to its own original representation?"

Comparison of attribution frameworks: (a) Supervised, (b) Explicand-Centric Unsupervised, and (c) the proposed Contrastive Corpus (COCOA) approach.

We argue this is too narrow. Humans naturally explain things through contrast (e.g., "This is a zebra because it has stripes, unlike a horse"). Without a reference point (a corpus) and a contrast point (a foil), explanations remain opaque and lack human-aligned context.

Introducing COCOA

We introduce COCOA (COntrastive COrpus Attribution), a framework that defines a novel scalar explanation target called contrastive corpus similarity.

  1. The Target Function: Instead of explaining a raw vector, COCOA explains the difference between the average similarity of an input to a reference corpus ($C$) and its average similarity to a foil distribution ($D_{foil}$).
  2. The "Wrapper" Approach: Because this target is a differentiable scalar, COCOA acts as a wrapper. Researchers can plug in existing post-hoc attribution methods like Integrated Gradients, GradientSHAP, or RISE to calculate which input features most influence this contrastive similarity.
  3. Directional Interpretation: Mathematically, COCOA identifies features pointing the representation toward the "mean" of the corpus and away from the "mean" of the foil. This provides a clear geometric interpretation of attribution scores in latent space.

Key Insights and Applications

COCOA was evaluated across several architectures, including SimCLR, SimSiam, and CLIP. Several key insights emerged:

  • Explaining the Unseen: In supervised settings, traditional methods can only explain classes the model was trained on. COCOA can explain any class, provided a small corpus of examples (as few as 20 samples) is gathered after training.
  • Augmentation Invariance: By applying COCOA to SimCLR, we discovered that the model preserves labels by focusing on specific "class-preserving" regions (like a dog's face) across different augmentations (crops, flips, color jitters).
  • Cross-Modal Localization: COCOA can explain the similarity between an image and a text string. For example, asking "What in this image makes it look like 'a photo of a rocket'?" effectively turns a representation model into a zero-shot object localizer.

Quantitative and Qualitative Results

Using "Insertion" and "Deletion" metrics, COCOA consistently outperformed "label-free" and "corpus-only" baselines. It proved significantly better at identifying pixels that move a representation toward a specific class boundary. Qualitatively, in CLIP experiments, COCOA successfully localized fine-grained features. When shown an image containing both a car and a bicycle, COCOA could specifically highlight the bicycle when the corpus was "bicycle" and the car when the corpus was "car"—a task where "explicand-centric" methods typically struggle as they highlight all "important" regions simultaneously.

Limitations and Future Work

COCOA cannot explain a concept if the model hasn't learned anything about that corpus during training; it explains the model's representation, not necessarily the ground truth. Currently, users must manually choose the corpus and foil sets. Future work may involve automatic concept discovery to identify these sets algorithmically and extending COCOA into the realm of counterfactual explanations.

Summary updated

BibTeX
@inproceedings{lin2023contrastive,
  author = {Chris Lin and Hugh Chen and Chanwoo Kim and Su-In Lee},
  title = {{Contrastive Corpus Attribution for Explaining Representations}},
  booktitle = {International Conference on Learning Representations},
  year = {2023},
  url = {https://openreview.net/forum?id=eWKfMBL5to},
}
Figure