TransMIL: Transformer based Correlated Multiple Instance Learning for Whole Slide Image Classication

Zhuchen Shao, Hao Bian, Yang Chen, Yifeng Wang, Jian Zhang, Xiangyang Ji, Yongbing Zhang

Abstract

TransMIL is a novel Transformer-based framework for Whole Slide Image (WSI) classification that breaks the traditional "independent patch" assumption in Multiple Instance Learning (MIL). By leveraging an efficient Nyström-based self-attention mechanism and a spatial encoding module, it captures complex correlations between tissue regions, achieving state-of-the-art performance and faster convergence on major pathology benchmarks.

Introduction: The Challenge of Gigapixel Pathology

In digital pathology, Whole Slide Images (WSIs) are "gigapixel" files—too massive to fit into GPU memory all at once. The standard workaround is Multiple Instance Learning (MIL): the image is decomposed into thousands of small patches (instances), and a model predicts a label for the whole "bag" of patches.

Whole slide image showing patch extraction for MIL.

However, most current MIL methods rely on the i.i.d. (independent and identically distributed) hypothesis. They treat each patch as if it exists in a vacuum, ignoring the morphological and spatial relationships between different tissue areas. Real-world pathologists don't work this way; they look at the "big picture" and how different regions relate to one another. The challenge is that standard Transformers, which are excellent at modeling correlations, have a computational complexity of $O(n^2)$, making them unusable for WSIs that can contain upwards of 10,000 patches.

Methodology: Correlated Multiple Instance Learning

The authors introduce TransMIL, which consists of three primary innovations to address the limitations of i.i.d. MIL:

  1. Correlated MIL Framework: The authors provide a theoretical proof showing that a "correlated" MIL approach has lower information entropy (less uncertainty) than the traditional i.i.d. approach. This shifts the focus from simple pooling to modeling inter-patch interactions.
  2. Nyström-based Self-Attention: To handle the massive number of patches, TransMIL uses the Nyström method to approximate the self-attention mechanism. This reduces the computational complexity from $O(n^2)$ to $O(n)$, allowing the model to process thousands of tokens efficiently.
  3. Pyramid Position Encoding Generator (PPEG): Since patches are often flattened into a 1D sequence, spatial information is lost. PPEG "squares" the sequence back into a 2D-like grid and applies multi-scale convolutions ($3\times3$, $5\times5$, $7\times7$) to capture local and global spatial context before re-flattening it for the Transformer layers.
Comparison between standard MIL attention (a) and the proposed self-attention mechanism (b).

The workflow involves extracting features via a pre-trained ResNet50, processing them through the TransMIL TPT (Transformer-PPEG-Transformer) module, and using a class token for the final diagnostic prediction.

Experimental Evaluation

The model was evaluated on three large-scale, public clinical datasets: CAMELYON16 (breast cancer metastasis), TCGA-NSCLC (lung cancer subtyping), and TCGA-RCC (renal cell carcinoma subtyping). TransMIL outperformed all existing state-of-the-art (SOTA) methods across all three datasets:

Dataset Metric TransMIL Result Improvement over next best
CAMELYON16 AUC 93.09% ~4.3% over MIL-RNN
TCGA-NSCLC AUC 96.03% ~1.4% over Max-pooling
TCGA-RCC AUC 98.82% ~0.1% over Max-pooling

Notably, on the CAMELYON16 dataset—where tumor regions are often very small—TransMIL's ability to model long-range dependencies gave it a significant edge over methods that ignore patch correlations.

Key Insights and Discussion

  • Correlation is King: Moving from simple "pooling" (where patches are just averaged or weighted) to "correlation modeling" (where patches interact) provides a significant boost in performance.
  • Spatial Context Matters: Ablation studies showed that the PPEG module is crucial. Even in a weakly supervised setting, knowing where a patch is relative to its neighbors helps the model identify relevant morphological structures.
  • Efficiency and Interpretability: Using the Nyström approximation makes the model feasible and fast, converging 2 to 3 times faster than previous SOTA methods like CLAM. Furthermore, the attention weights allow for the generation of heatmaps that correlate strongly with actual cancerous regions identified by pathologists.

Limitations and Future Work

While TransMIL is efficient, moving to 40x magnification would result in even longer sequences, which might eventually hit memory limits. Future work involves using pathology-specific feature extractors (e.g., via self-supervised learning) and exploring TransMIL for tasks like survival analysis where long-range correlation is even more critical.

Summary updated

BibTeX
@inproceedings{shao2021transmil,
  author = {Zhuchen Shao and Hao Bian and Yang Chen and Yifeng Wang and Jian Zhang and Xiangyang Ji and Yongbing Zhang},
  title = {{TransMIL: Transformer based Correlated Multiple Instance Learning for Whole Slide Image Classication}},
  booktitle = {Advances in Neural Information Processing Systems},
  year = {2021},
  url = {https://openreview.net/forum?id=NJMcDzEaxlQ},
}
Figure