Unsupervised Foundation Model-Agnostic Slide-Level Representation Learning

Tim Lenz, Peter Neidlinger, Marta Ligero, Georg Wölflein, Marko van Treeck, Jakob Nikolas Kather · DOI

Introduction

Whole-slide images (WSIs) in digital pathology present a unique challenge for machine learning due to their "gigapixel" scale. Standard neural networks cannot process these images directly, necessitating Multiple Instance Learning (MIL) approaches that operate on small patches. However, conventional MIL is often limited by its reliance on weak supervision for specific clinical tasks, failing to produce general-purpose slide-level summaries. Furthermore, existing slide-level self-supervised learning (SSL) models typically require massive datasets—often exceeding 100,000 slides—to achieve high performance.

To address these challenges, we present COBRA (COntrastive Biomarker Representation Alignment), a novel self-supervised framework designed to generate high-quality, slide-level representations without human labels. COBRA achieves state-of-the-art performance while being significantly more data-efficient than previous leading models.

Methodology: Feature-Space Augmentation

The core innovation of COBRA lies in its approach to data augmentation. Traditional pixel-level augmentations are often ineffective for the abstract feature vectors produced by patch encoders. Instead, COBRA employs feature-space augmentation, treating the outputs of different pathology foundation models (FMs)—such as UNI, Virchow2, or CTransPath—and varying image magnifications as distinct "views" of the same slide.

The COBRA architecture utilizes random tile, magnification, and foundation model selection to create diverse views for contrastive learning.

The architecture consists of four primary stages:

  1. Preprocessing: WSIs are tiled into patches, and embeddings are extracted using various pretrained FMs.
  2. Encoding: A Mamba-2 state-space model architecture is used to process the long sequences of patches efficiently.
  3. Aggregation: A multi-head gated attention mechanism pools patch sequences into a single d-dimensional slide-level vector.
  4. Pretraining: The model is trained using a MoCo-v3 style contrastive loss, learning to align different representations of the same slide (e.g., a "Virchow2 view" at 20x vs. a "UNI view" at 5x) while distinguishing them from other slides.

Experimental Setup

COBRA was pretrained on a dataset of 3,048 WSIs from The Cancer Genome Atlas (TCGA), covering five major tissue types (Breast, Colorectal, Lung Adenocarcinoma, Lung Squamous Cell, and Stomach). For evaluation, external validation was conducted on 1,604 WSIs from the Clinical Proteomic Tumor Analysis Consortium (CPTAC) to ensure generalizability across different laboratory environments and scanning hardware.

Results and Discussion

Despite being trained on approximately 30x less data than competitors like Gigapath or PRISM, COBRA demonstrates superior performance across multiple benchmarks.

Performance and Data Efficiency

COBRA outperformed state-of-the-art slide encoders on four CPTAC cohorts by an average of +4.4% AUC. In downstream classification tasks, such as predicting EGFR or KRAS mutations and molecular status (MSI), COBRA achieved a macro-AUC of 75.3%, outperforming all baselines.

Few-shot performance comparison across CPTAC cohorts shows COBRA consistently outperforming larger-scale models like GigaPath and PRISM.

Key Insights

  • Foundation Model Agnosticism: COBRA can "plug and play" with new foundation models it was not exposed to during training, as it learns the fundamental structural relationships between pathology features.
  • Magnification Robustness: By forcing the model to align low- and high-magnification views, it learns scale-invariant representations, enhancing robustness to varying scanning protocols.
  • Interpretability: Even without explicit labels, COBRA naturally produces attention heatmaps that highlight tumor regions, providing clinical interpretability.

Conclusion and Future Work

COBRA establishes a new benchmark for data-efficient, slide-level representation learning in pathology. While currently focused on five tissue types and contrastive loss, future work will expand tissue diversity and explore alternative SSL objectives like masked autoencoding. Additionally, moving beyond linear aggregation of patch embeddings may capture more complex biological interactions within the WSI.

Summary updated

BibTeX
@inproceedings{lenz2025unsupervised,
  author = {Tim Lenz and Peter Neidlinger and Marta Ligero and Georg Wölflein and Marko van Treeck and Jakob Nikolas Kather},
  title = {{Unsupervised Foundation Model-Agnostic Slide-Level Representation Learning}},
  booktitle = {IEEE/CVF Conference on Computer Vision and Pattern Recognition},
  year = {2025},
  doi = {10.1109/cvpr52734.2025.02869},
}
Figure