ComFe: An Interpretable Head for Vision Transformers

Evelyn J. Mannix, Liam Hodgkinson, Howard Bondell

This paper introduces Component Features (ComFe), a novel, interpretable-by-design classification head for Vision Transformers (ViTs). By decomposing images into semantically meaningful "component features" and comparing them to learned class prototypes, ComFe provides transparent reasoning for its predictions without sacrificing the performance or scalability of modern foundation models.

TL;DR

ComFe is the first interpretable classification head for Vision Transformers that scales to large datasets like ImageNet-1K while maintaining competitive accuracy. It works by clustering image patches into "component features" and matching them against a library of class prototypes, allowing researchers to see exactly which parts of an image (e.g., a bird's wing or a car's roof) drove a specific prediction.

What Problem Does This Paper Address?

Standard deep learning models are "black boxes," making it difficult to trust their decisions in high-stakes fields like medicine or autonomous driving. While post-hoc techniques like Class Activation Maps (CAMs) exist, they can be misleading and don't explain why a model chose a specific class based on training data.

Previous "interpretable-by-design" models (like ProtoPNet) use prototypes—visual representations of concepts from the training data—to explain classifications. However, these methods face three major hurdles:

  1. Scalability: They struggle with large-scale datasets like ImageNet-1K due to computational intensity.
  2. Hyperparameter Sensitivity: They often require extensive tuning for every new dataset.
  3. Background Noise: They frequently learn to associate background features (like grass or sky) with specific classes, leading to "spurious correlations."

Methods

ComFe addresses these issues by acting as a modular head for pretrained, frozen ViT backbones (specifically the DINOv2 family). The framework operates in a few key stages:

  1. Feature Extraction: A frozen ViT processes an image into patch embeddings.
  2. Component Clustering: A transformer decoder (the "Clustering Head") groups these patch embeddings into a small set of Image Prototypes ($P$). These represent physical components of the object (e.g., the head, body, or wings of a bird).
  3. Prototype Comparison: These image prototypes are compared against a library of Class Prototypes ($C$) learned during training. These class prototypes represent the "ideal" version of a component for a specific category.
  4. Probabilistic Reasoning: The model uses a hierarchical mixture modeling approach based on the von-Mises Fisher distribution. This is particularly suited for ViT latent spaces, where cosine similarity is the primary measure of semantic relatedness.
Figure 2: The ComFe framework. A pretrained ViT network is applied to an input image X, to produce patch embeddings Z and a class token. The ComFe clustering head gθ is trained to cluster patch embeddings and produce image prototypes P, which are compared to a set of learnt class prototypes C which represent the training data to identify the informative image regions and make a prediction. In constrast, a standard non-interpretable approach will train a linear head to make a prediction using the class token, and does not provide insight into the informative image regions or which training images led to a particular prediction.

Datasets

The authors evaluated ComFe across a diverse range of benchmarks:

  • Fine-grained Classification: CUB200 (birds), Oxford Pets, Stanford Cars, and FGVC Aircraft.
  • General Benchmarks: ImageNet-1K, CIFAR-10/100, Food-101, and Flowers-102.
  • Robustness & Generalization: ImageNet-V2, ImageNet-Sketch, ImageNet-R (Renditions), and ImageNet-A (Adversarial).
  • Interpretability: The FunnyBirds framework, which uses synthetic data to quantify how "correct" and "complete" a model's explanations are.

Key Insights and Ideas

  • Leveraging Foundation Models: Instead of training from scratch, ComFe uses the rich, semantically consistent latent space of DINOv2. This allows the model to identify components (like "eyes" or "wheels") across different images without needing explicit part annotations.
  • Efficiency through Bottlenecks: By clustering hundreds of patches into just a few image prototypes ($N_P \approx 5$), ComFe significantly reduces the complexity of the interpretability problem, making it scalable to ImageNet.
  • Explicit Background Modeling: By adding a dedicated "background" class, the model learns to ignore non-informative regions, leading to cleaner explanations and better robustness.
  • Interpretability-Robustness Link: The results suggest that forcing a model to reason via specific components makes it more robust to out-of-distribution data (like sketches or artistic renditions) compared to standard linear heads.

Key Results

  • Competitive Accuracy: On CUB200, ComFe achieved 87.6% accuracy, outperforming several previous interpretable methods that required finetuning the entire network.
  • First at Scale: ComFe is the first interpretable method to report results on ImageNet-1K, achieving 83.0% (ViT-S/14), which is competitive with non-interpretable linear heads.
  • Superior Robustness: ComFe consistently outperformed standard linear heads on robustness benchmarks. For example, on ImageNet-A, ComFe (ViT-L) reached 55.0% accuracy compared to 52.0% for the linear baseline.
  • Training Speed: The model is highly efficient; it can be trained on the CUB200 dataset in just 30 minutes on a single NVIDIA A100 GPU.
Figure 1: Illustration of ComFe. The image is first clustered into component features, which are then compared to class prototypes. This comparison between component features and class prototypes is used to identify the salient parts of the image for predicting the class Osteospermum, as shown by the class confidence heatmap in the final image.

Limitations and Future Work

  • Backbone Dependency: The quality of the explanations is heavily tied to the quality of the pretrained ViT. If the backbone has "context leakage" (e.g., embedding background info into object patches), the explanations may suffer.
  • Initialization Sensitivity: Like many clustering algorithms, ComFe can be sensitive to random seeds, sometimes finding different "informative" features across runs. The authors suggest ensembling multiple heads to mitigate this.
  • Incomplete Maps: Because ComFe only looks for discriminative features, it might not highlight every part of an object—only the parts necessary to distinguish it from other classes.
  • Future Directions: The authors suggest extending ComFe to semantic segmentation tasks, where pixel-level supervision could lead to even more precise and complete confidence maps.

Summary updated

BibTeX
@article{mannix2025comfe,
  author = {Evelyn J. Mannix and Liam Hodgkinson and Howard Bondell},
  title = {{ComFe: An Interpretable Head for Vision Transformers}},
  journal = {Accepted by TMLR},
  year = {2025},
  url = {https://openreview.net/forum?id=cI4wrDYFqE},
}
Figure