No Token Left Behind: Explainability-Aided Image Classification and Generation

Roni Paiss, Hila Chefer, Lior Wolf

Abstract

Contrastive Language-Image Pre-training (CLIP) models frequently exhibit "semantic neglect," where they prioritize specific keywords in a prompt while disregarding others. This behavior leads to instabilities in zero-shot tasks and optimization-based image editing. We present a novel approach that incorporates an explainability-based loss term to ensure the model attends to all relevant semantic tokens. Our method demonstrates significant improvements across one-shot classification, image editing, and spatially-conditioned image generation.

Introduction: The Challenge of Selective Similarity

CLIP has emerged as a foundational tool for bridging vision and language. However, its effectiveness is often hampered by "selective similarity." When evaluating the match between an image and a prompt like "a person with purple hair," CLIP may achieve a high similarity score by focusing exclusively on "hair" while ignoring the attribute "purple."

This "myopic" focus creates local minima during optimization. For example, in text-driven image editing, a model might change the color of a background element to purple rather than the subject's hair because it found a shortcut to increasing the similarity score. This paper addresses this instability by forcing the model to "pay attention" to every token in the prompt.

Methodology: Explainability as a Training Signal

The core innovation is the introduction of an explainability-aided loss function ($\mathcal{L}_{expl}$). Rather than treating explainability as a post-hoc diagnostic tool, the authors use it as an active feedback mechanism during optimization.

  1. Explainability Maps: Using Transformer-based explainability techniques, the system generates relevance scores for each text token and image patch. This identifies exactly which visual regions the model associates with specific words.
  2. The Explainability Loss:
  3. In classification, the loss ensures that similarity is driven by class-relevant tokens rather than prompt filler.
  4. In generation and editing, the loss encourages high relevance scores for all semantic words (e.g., both "purple" and "hair").
  5. Spatial Control: By constraining the explainability heatmap of a specific object (e.g., "a cat") to a user-defined bounding box, the method achieves zero-shot spatial conditioning without specialized architectures.
Figure 3: Comparison of image editing results and corresponding heatmaps for the prompt "a person with purple hair." Our method ensures the model attends to both the subject and the specific attribute, whereas baselines like StyleCLIP may neglect key tokens.

Key Results and Insights

The proposed method was evaluated against standard benchmarks, including ImageNet variants for classification and MSCOCO for spatial generation.

  • One-Shot Classification: The method consistently outperformed state-of-the-art prompt engineering (CoOp). On ImageNet with a ViT-B/16 backbone, it achieved 67.62% accuracy, surpassing CoOp's 66.93%.
  • Image Editing: Qualitative studies showed that the explainability loss successfully compels the model to perform difficult edits. For instance, when adding a beard to a female face, standard StyleCLIP often fails to localize the change correctly, while the proposed method succeeds by distributing attention across all relevant tokens.
  • Spatial Generation: The method provided superior layout control on MSCOCO-based tests, achieving a Precision of 71.7% and an Average Precision (AP) of 26.2, significantly higher than the 46.4% Precision and 8.0 AP of similarity-based baselines.

Conclusion

By treating explainability as a first-class citizen in the optimization process, this work effectively combats "shortcut learning" in CLIP-based models. Forcing the model to account for every token leads to more robust classification and more precise, controllable image generation. Future work may explore additional signals beyond explainability to further bridge the gap between zero-shot and fully supervised models.

Summary updated

BibTeX
@inproceedings{paiss2022no,
  author = {Roni Paiss and Hila Chefer and Lior Wolf},
  title = {{No Token Left Behind: Explainability-Aided Image Classification and Generation}},
  booktitle = {European Conference on Computer Vision},
  year = {2022},
  doi = {10.1007/978-3-031-19775-8\_20},
}
Figure