NeurIPS 2026Coming to NeurIPS?Explore papers, orals & directions

Interpreting and Analysing CLIP's Zero-Shot Image Classification via Mutual Knowledge

Fawaz Sammani, Nikos Deligiannis

TL;DR

This paper introduces a novel, training-free approach to interpret CLIP's zero-shot decisions by analyzing the "mutual knowledge" between its vision and language encoders. By mapping both modalities into a shared, discrete space of fine-grained textual concepts, the authors use Mutual Information (MI) dynamics to discover exactly what features drive CLIP's predictions.

What Problem Does This Paper Address?

Contrastive Language-Image Pretraining (CLIP) has revolutionized zero-shot image classification by embedding images and text into a shared continuous space. However, understanding why CLIP makes a specific classification decision remains a challenge.

Existing explainability techniques (like Grad-CAM) typically provide coarse, high-level heatmaps that highlight an entire object but fail to explain fine-grained decisions (e.g., distinguishing between similar dog breeds based on snout shape vs. ear type). Furthermore, because the vision encoder outputs visual regions and the text encoder outputs text, they speak different "languages." To find out what both encoders have learned in common, we need a shared medium.

Computing Mutual Information (MI) directly in continuous high-dimensional spaces is notoriously difficult and requires complex approximations. This paper addresses these challenges by establishing a discrete, shared communication channel made of fine-grained textual concepts.

Methods

The authors propose a pipeline to extract and align concepts from both encoders without training any new models:

  1. Visual Concept Extraction: The method extracts visual features from the image and uses spectral graph clustering (eigendecomposition of a feature affinity matrix) combined with Conditional Random Fields (CRF) to isolate prominent image regions. These regions are then clustered using PCA or K-means into distinct "visual concepts" (object parts).
  2. Textual Mapping via Optimal Transport: To translate these visual patches into text, the authors use an LLM (like GPT-3.5) to generate a large bank of class-agnostic descriptors. They apply visual prompt engineering (drawing a red circle around the patch or blurring the background) to feed individual visual concepts into CLIP's vision encoder. The patches are matched to the text descriptors and filtered using an Optimal Transport formulation (Sinkhorn-Knopp) to ensure diverse, unique concept assignments.
  3. Language Concept Extraction: Textual concepts surrounding the zero-shot predicted class are extracted based on their similarity in the language embedding space.
  4. Mutual Information Dynamics: With both modalities mapped to a shared dictionary of discrete concepts, MI can be computed efficiently. The authors introduce "MI Dynamics": they sequentially remove the most important visual concepts and plot the decay of MI. The Area Under the Curve (AUC) of this plot quantifies the strength of the shared knowledge.
Figure 1: CLIP maps visual and textual inputs into a joint embedding space, with an information channel expressed in terms of the Mutual Information (MI) between them (a). We interpret the visual features from the vision encoder with multimodal concepts (b) which represent object parts and their corresponding textual description. From the language encoder, we identify points (shown in grey) around the zero-shot prediction (shown in green) as textual descriptions of the predicted class (c). By considering the textual descriptors corresponding to the visual concepts, and the textual descriptors of the language encoder for the predicted class, the two encoders establish a common space of textual concepts allowing us to identify mutual concepts and analyze their shared knowledge (d).

Datasets

The approach was evaluated using 13 different CLIP models across three major image classification datasets:

  • ImageNet (Full validation split)
  • Places365 (Scene recognition)
  • Food101 (Food classification)

The text descriptor banks were generated using various LLMs, including GPT-3.5, GPT-4o, GPT-4o-mini, and Llama3.1-8B-Instruct.

Key Insights and Ideas

  • ViTs vs. CNNs: Vision Transformer (ViT) based CLIP models exhibit significantly stronger shared knowledge (higher AUC) than CNN-based counterparts (ResNets and ConvNeXts). This supports the idea that architectures lacking inductive biases leverage massive pretraining datasets more effectively to build a robust vision-language channel.
  • The AUC-Accuracy Correlation: Within a specific architectural family, the strength of shared encoding (AUC) scales linearly with zero-shot accuracy. This makes MI dynamics a potentially valuable tool for model selection when accuracy metrics alone aren't enough to differentiate models.
  • Scale and Data Quality Matter: Larger models with more patches (smaller patch sizes or larger input images) and models trained on cleaner, curated datasets (like DataComp or DFN) yield higher AUC scores, indicating a more reliable information channel.
  • Internet Pretraining Biases: Interestingly, general concepts like "patterns and styles" often retain higher mutual information than highly specific, discriminative features (like the body shape of a rare animal). Because CLIP is trained on internet scrapings, it excels at encoding universally prevalent features over niche, fine-grained ones.

Key Results

  • Explainability Performance: The training-free multimodal explanations outperformed established baselines (such as Multimodal Concept Bottleneck Models) across standard XAI metrics, including Deletion, Accuracy Drop, and Accuracy Increase.
  • Boosting Zero-Shot Accuracy: To prove the relevance of the discovered concepts, the authors fed the extracted textual descriptions back into CLIP as additional prompts. This application yielded significant improvements in zero-shot classification, boosting accuracy by up to 3.75% on ImageNet (e.g., raising a ResNet-50x16 baseline from 68.47% to 72.22%).

Limitations and Future Work

The authors note two primary limitations:

  1. Noisy Visual Clusters: In some instances, the visual concepts identified by PCA/K-means can be scattered or noisy, which can cause the subsequent textual mapping to diverge from the true image content.
  2. Task Scope: The current framework is strictly evaluated on zero-shot image classification.

Future work could extend this mutual knowledge lens to other contrastive downstream tasks, such as image-text retrieval, semantic segmentation, object localization, or even to non-contrastive models.

Summary updated

BibTeX
@inproceedings{sammani2024interpreting,
  author = {Fawaz Sammani and Nikos Deligiannis},
  title = {{Interpreting and Analysing CLIP's Zero-Shot Image Classification via Mutual Knowledge}},
  booktitle = {Advances in Neural Information Processing Systems},
  year = {2024},
  url = {https://openreview.net/forum?id=n01yLUy7Mj},
}
Figure