TU Berlin's Beyond Attention Heatmaps Exposes How Cancer AI Misleads Doctors
A TU Berlin-led team introduces xMIL, a label-free evaluation framework and large-scale benchmark revealing which explanation methods actually reflect how MIL models make decisions in digital pathology.
ProTakeaways
- Researchers from TU Berlin and BIFOLD introduce a label-free framework for evaluating MIL heatmap quality in histopathology using a patch-flipping faithfulness test.
- A large-scale benchmark across 60 experimental settings (10 datasets, 3 architectures, 2 backbones, 3 task types) compares six explanation methods head-to-head.
- LRP, Integrated Gradients, and Single (perturbation) consistently outperform attention heatmaps, which frequently score near random in faithfulness tests.
- The best method depends on architecture: LRP for Transformer-based MIL, Single for Attention- and Mamba-based MIL.
- Proof-of-concept shows LRP/Single heatmaps correlate with spatial transcriptomics ground truth (Pearson r 0.54–0.78), enabling a new approach to biological model validation.
- Code is publicly available at github.com/bifold-pathomics/xMIL.
In computational pathology, multiple instance learning (MIL) has become the dominant approach for analyzing gigapixel whole slide images. The idea is straightforward: a slide is split into thousands of small patches, each patch gets an embedding from a pretrained encoder, and a model aggregates those embeddings into a single slide-level prediction , for cancer subtype, survival risk, or molecular biomarkers. To understand what the model is doing, practitioners overlay the slide with a heatmap that highlights which patches drove the prediction. These heatmaps are treated as a form of model validation and, increasingly, as a tool for biological discovery.
The problem is that almost nobody has rigorously checked whether those heatmaps are actually telling the truth about the model. Heatmaps are widely used to validate MIL models and to discover tissue biomarkers, yet the validity of these heatmaps has barely been investigated. A team from Technische Universität Berlin, BIFOLD, and collaborating clinical institutions has now addressed this gap directly, publishing a paper titled Beyond Attention Heatmaps that introduces both an evaluation framework and a large-scale benchmark for MIL explanations in histopathology.
Why this matters: the attention heatmap problem
The most common way to generate a MIL heatmap is to simply read off the attention weights from the model's aggregation layer. These weights are already computed during inference, require no extra work, and feel intuitive , a high attention weight on a patch seems to say "the model found this region important." But attention weights have a known conceptual limitation: they reflect where the model focuses, not whether that focus is positive or negative evidence, and not whether removing those patches would actually change the prediction.
Various works have reported conceptual and practical limitations of attention heatmaps in accurately reflecting model predictions. A second concern is confirmation bias: reliance on unvalidated visualizations may lead to confirmation bias, where AI practitioners or medical experts interpret heatmaps in ways that align with their expectations, regardless of whether the explanation faithfully reflects the model output. In high-stakes clinical settings , where models might be picking up on staining artifacts or demographic confounders rather than biology , this is a serious problem.

The xMIL evaluation framework
The paper introduces a general framework for evaluating the quality of MIL heatmaps without requiring additional labels. This is the key design constraint: ground-truth patch-level annotations are expensive and rare, so the framework must work with only the model and the slide data it was already trained on.
The core evaluation technique is called patch flipping, a faithfulness test adapted from the broader XAI literature. Here is how it works:
- Generate a heatmap for a slide using an explanation method, producing a relevance score per patch.
- Sort patches by their relevance score, both ascending (least to most important) and descending (most to least important).
- Progressively remove patches in each ordering and re-run the model on the remaining patches, recording how the prediction changes.
- A faithful heatmap should cause a rapid prediction drop when the most relevant patches are removed first, and a slow drop when the least relevant are removed first.
- The gap between these two perturbation curves , called the Symmetric Relevance Gain (SRG) , quantifies heatmap faithfulness. Higher SRG means the heatmap genuinely reflects what the model is using.
Because MIL models naturally handle variable-length bags of patches, removing patches does not create out-of-distribution inputs , a common pitfall in faithfulness testing for other domains. This makes patch flipping particularly well-suited to the MIL setting.

What was benchmarked
The paper conducts a large-scale benchmark experiment to assess six explanation methods across histopathology task types (classification, regression, survival), MIL model architectures (Attention-, Transformer-, Mamba-based), and patch encoder backbones (UNI2, Virchow2). In total, this covers 60 experimental configurations across 10 datasets.
The six explanation methods tested are:
- Attention (Attn) , raw attention weights from the aggregation layer, the current default in most MIL pipelines.
- Gradient × Input (G×I) , element-wise product of input features and their gradients, a fast but naive baseline.
- Gradient squared (Grad2) , squared gradients, another simple gradient-based baseline.
- Integrated Gradients (IG) , gradients integrated along a path from a zero baseline to the actual input, satisfying axiomatic attribution properties.
- Single (perturbation-based) , runs each patch individually through the model and uses that single-patch prediction score as its relevance score.
- Layer-wise Relevance Propagation (LRP) , backpropagates the model's output through the network layer by layer, conserving total relevance, adapted here to attention, transformer, and Mamba architectures.
The datasets span tumor detection (CAMELYON16), cancer subtyping (TCGA NSCLC), biomarker prediction (HPV in head and neck cancer, TP53 in lung adenocarcinoma), gene expression regression (AURKA, HRD in TCGA BRCA), and overall survival prediction (BRCA, KIRC, GBMLGG, COADREAD).
The benchmark results
Results show that explanation quality mostly depends on MIL model architecture and task type, with perturbation ("Single"), layer-wise relevance propagation (LRP), and integrated gradients (IG) consistently outperforming attention-based and gradient-based saliency heatmaps, which often fail to reflect model decision mechanisms.
Two clear groups emerge from the pairwise statistical analysis:
- Better group: Single, LRP, IG , consistently and substantially more faithful across architectures, tasks, and backbones.
- Weaker group: Attention, G×I, Grad2 , often no better than a random baseline in faithfulness.
The best method within the top group depends on the model architecture:
- For Transformer-based MIL (TransMIL), LRP is consistently the top performer.
- For Attention-based MIL (AttnMIL) and Mamba-based MIL (MambaMIL), Single is typically the most faithful method, especially for regression and survival tasks.
- IG serves as a practical alternative when LRP or Single are difficult to implement, and is available off-the-shelf via the Captum library.
Attention heatmaps, the current field default, showed SRG scores near the random baseline in many configurations. This does not mean attention-based models are wrong , the models themselves perform well , it means the attention weights are not a reliable window into what the model is actually computing.
Two proof-of-concept applications
The paper goes beyond the benchmark to demonstrate what better heatmaps enable in practice.
Use case 1: Spatial transcriptomics validation. The authors provide a proof-of-concept that MIL heatmaps of a bulk gene expression prediction model can be correlated with spatial transcriptomics for biological validation. A TransMIL model was trained to predict pseudo-bulk gene expression (FASN, ERBB2) from H&E patches in the HEST-1k breast cancer dataset. The patch-level heatmaps from LRP, IG, and Single were then compared against spatially registered ground-truth gene expression measurements that the model never saw during training. Single and LRP heatmaps achieved Pearson correlations of 0.54–0.78 with the spatial transcriptomics ground truth for FASN on three of four slides. Attention heatmaps were consistently weaker. This opens a new path for validating molecular biomarker prediction models before clinical deployment , using spatial omics as a biological ground truth for the heatmap, not just for the prediction.
Use case 2: Discovering model strategies for HPV prediction. The authors showcase the discovery of distinct model strategies for predicting human papillomavirus (HPV) infection from head and neck cancer slides. Using LRP heatmaps, they extracted the top 10% most relevant patches per slide, characterized those regions with automated cell segmentation (CellViT++), and clustered HPV-positive slides by their resulting morphological profiles. Four distinct groups emerged, each representing a different histological strategy the model used to identify HPV-positive cases , including one group where the model appeared to identify HPV-positive cases by recognizing tonsil anatomy, and another where it found patterns not visually apparent to pathologists.

Practical takeaways
The paper's recommendations are concrete and actionable:
- For TransMIL: use LRP as the default explanation method.
- For AttnMIL or MambaMIL: use Single, particularly for regression and survival tasks.
- For any setup: run the patch flipping evaluation to confirm which method is most faithful for your specific dataset and architecture before using heatmaps for validation or discovery.
- Avoid treating attention weights as a faithful explanation without validation , they frequently perform no better than random at identifying which patches actually drive the prediction.
The evaluation framework itself is model-agnostic and requires no additional annotations, meaning it can be applied to any existing MIL pipeline. Code is provided in a public GitHub repository. The repository covers LRP implementations for AttnMIL, TransMIL, and MambaMIL, along with the patch flipping evaluation pipeline.
What this enables going forward
The work highlights the importance of validating MIL heatmaps and establishes that improved explainability can enable more reliable model validation and yield biological insights, making a case for a broader adoption of explainable AI in digital pathology. The spatial transcriptomics validation experiment in particular points toward a future where heatmaps from bulk omics prediction models could provide cheap spatial analyses at scale , without requiring expensive spatial omics data for every cohort. The authors also note that the framework transfers directly to other domains where MIL is applied, including radiology, single-cell data, and multimodal fusion models.