Unifying Multiple Foundation Models for Advanced Computational Pathology

Wenhui Lei, Yusheng Tan, Anqi Li, Hanyu Chen, Hengrui Tian, Ruiying Li, Zhengqun Jiang, Fang Yan, Xiaofan Zhang, Shaoting ZhangarXiv 2025

TL;DR

Shazam is a novel online integration framework that adaptively combines multiple pretrained pathology foundation models to maximize downstream performance without expensive offline retraining. By leveraging a lightweight Mixture-of-Experts (MoE) mechanism and multi-level feature fusion, Shazam consistently outperforms individual state-of-the-art models across 30 diverse benchmarks spanning spatial transcriptomics, survival prognosis, and visual question answering.

What Problem Does This Paper Address?

Pathology foundation models (such as UNI, Virchow, and H-Optimus-1) have revolutionized computational pathology by learning powerful visual representations from millions of tissue image tiles. However, these models exhibit significant performance variability across different clinical tasks and organs. Because they are often trained on massive, proprietary datasets that cannot be shared due to privacy constraints, the research community cannot easily combine or cumulatively expand them.

Previous attempts to merge these models relied on offline knowledge distillation. This strategy requires assembling a massive, curated distillation dataset and retraining a student model from scratch every time a new foundation model is released. Furthermore, offline distillation is task-agnostic, meaning it cannot dynamically emphasize the specific model strengths required for a particular downstream clinical task.

Methods

To overcome these limitations, the authors developed Shazam, an online integration model that dynamically fuses complementary representations from multiple frozen foundation models.

Overview of the Shazam framework architecture showing multi-model feature extraction, MoE gating, and online distillation.

Key components of the Shazam architecture include:

  • Multi-Scale Feature Extraction: Instead of using only the final layer outputs, Shazam places non-invasive forward hooks at the one-third, two-thirds, and final depth positions of each frozen teacher model to capture low-, mid-, and high-level semantic features.
  • Mixture-of-Experts (MoE) Gating: A lightweight multilayer perceptron (MLP) acts as a gating network, dynamically assigning weights to each foundation model's features based on the input tile or slide.
  • Self-Attention Fusion: Stacked self-attention layers refine the cross-model interactions, allowing information exchange across different semantic scales.
  • Online Distillation Objective: During training on a downstream task, a student model is optimized using a joint loss function. This combines the task-specific loss (e.g., cross-entropy or negative log-likelihood) with a multi-level distillation loss (combining cosine distance and element-wise Huber loss) to align the student's representations with the frozen teachers.

Datasets

Shazam was comprehensively evaluated across 30 distinct benchmarks categorized into four major clinical task types:

  1. Spatial Transcriptomics (ST) Prediction: Evaluated on the HEST-1k dataset across 8 organ-specific cohorts (bowel, liver, breast, prostate, skin, brain, kidney, and bladder).
  2. Survival Analysis: Tested on 10 TCGA cohorts (including BRCA, BLCA, CESC, COADREAD, GBMLGG, KIRC, LUAD, LUSC, SKCM, and STAD).
  3. Tile-Level Classification: Benchmarked across 11 datasets spanning tissue subtyping, lymphocyte assessment, and tumor recognition (ESCA, PanCancer-TCGA, PanCancer-TIL, Chaoyang, BACH, CCRCC-TCGA-HEL, CRC-MSI, PCAM, UniToPatho, CRC-100K, and HunCRC).
  4. Pathology Visual Question Answering (VQA): Evaluated using the PathVQA dataset containing over 32,000 image-question-answer triplets.

Key Insights and Ideas

  • Compositional over Monolithic: Shazam represents a paradigm shift away from training isolated, monolithic foundation models toward modular, compositional systems that can adaptively ingest new models as they emerge.
  • Dynamic Task Adaptation: The MoE gating mechanism allows Shazam to mitigate the organ-dependent performance drops seen in individual models. For instance, if one foundation model specializes in neuroepithelial tissues and another excels in glandular structures, Shazam dynamically routes features based on the input context.
  • The Power of Feature Depth: Ablation studies revealed that combining low-level (local morphology), mid-level (tissue architecture), and high-level (global context) features yields significantly better prognostic performance than relying on any single abstraction level.

Key Results

Shazam demonstrated robust, state-of-the-art performance across the evaluation suite, achieving an average ranking score of 1.17 across all 30 benchmarks and ranking first in 26 of them.

Overall performance ranking heatmap demonstrating Shazam's superior performance across 30 benchmarks compared to individual foundation models.
  • Spatial Transcriptomics: Shazam achieved an average improvement of 0.08–0.17 in Pearson Correlation Coefficient (PCC) over the strongest individual models, accurately capturing heterogeneous gene expression patterns like IDH1 in bowel cancer.
  • Survival Prognosis: Shazam achieved the highest overall performance with a mean C-index of 0.666, outperforming the best individual model, H-Optimus-1 (0.642), and Virchow2 (0.631).
Radar charts comparing model performance in spatial transcriptomics (PCC) and survival prediction (C-Index).
  • Pathology VQA: Despite no explicit cross-modal pretraining, Shazam achieved a top accuracy of 0.575 on PathVQA, outperforming the second-best model (UNI 2) by 1%.

Limitations and Future Work

The primary limitation of Shazam is its linear computational overhead. Because all constituent foundation models must remain active to perform feature extraction during both training and inference, the computational cost scales linearly with the number of integrated models.

The authors note that incorporating emerging, lightweight pathology foundation models could significantly reduce this overhead in future iterations. Additionally, while internal benchmarking was extensive, further validation on completely independent, real-world institutional datasets is required to fully confirm the framework's clinical readiness.

Summary updated

BibTeX
@misc{lei2025unifying,
  author = {Wenhui Lei and Yusheng Tan and Anqi Li and Hanyu Chen and Hengrui Tian and Ruiying Li and Zhengqun Jiang and Fang Yan and Xiaofan Zhang and Shaoting Zhang},
  title = {{Unifying Multiple Foundation Models for Advanced Computational Pathology}},
  year = {2025},
  eprint = {2503.00736},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2503.00736},
}
Figure