Diagnosing Transformers: Illuminating Feature Spaces for Clinical Decision-Making

Aliyah R. Hsu, Yeshwanth Cherapanamjeri, Briton Park, Tristan Naumann, Anobel Odisho, Bin Yu

Pre-trained transformers are increasingly fine-tuned to aid clinical decision-making using limited clinical notes. However, in high-stakes domains like medicine, treating AI as a "black box" is unacceptable. When a model classifies a pathology report, clinicians need to understand why it made that choice and whether the model is genuinely suitable for the task to establish trust and ensure patient safety.

While pre-training on domain-specific data (like medical journals) is known to help, the interaction between pre-training and the fine-tuning process remains poorly understood. There is a natural tension between using general-domain models—which see a vast diversity of language—and domain-specific models, which understand technical jargon but might be brittle. To bridge this gap, researchers have introduced SUFO, a systematic diagnostic framework designed to peek under the hood of fine-tuned Transformers and analyze how their feature spaces evolve.

The SUFO Framework

The authors propose SUFO as a four-part systematic framework to evaluate model interpretability and trust:

  1. Supervised Probing: Testing how much task-relevant information exists in the "frozen" pre-trained features before any fine-tuning occurs.
  2. Unsupervised Similarity Analysis (RSA): Measuring how much the internal representations change or distort across layers during the fine-tuning process.
  3. Feature Dynamics: Using Principal Component Analysis (PCA) to visualize how clusters of data points (e.g., different cancer grades) "disambiguate" or separate across different layers and training epochs.
  4. Outlier Analysis: Identifying data points that fall outside typical clusters and collaborating with medical experts (e.g., Urologists) to explain why the model struggled with them.

Datasets

The framework was evaluated using two primary sources:

  • Prostate Cancer Pathology Reports: A private dataset of 2,907 structured reports from UCSF (2001–2018). Tasks included predicting Primary and Secondary Gleason grades, margin status, and seminal vesicle invasion.
  • MedNLI: A public clinical Natural Language Inference dataset used to validate the findings from the pathology reports.

Key Insights and Results

The study evaluated five 110M-parameter pre-trained transformer models categorized into general-domain (BERT, TNLR), mixed-domain (BioBERT, Clinical BioBERT), and domain-specific (PubMedBERT) groups.

The PubMedBERT Paradox and Probing

Supervised probing revealed that PubMedBERT (trained from scratch on medical text) possessed the highest quality "raw" features initially, proving it starts with a better foundational understanding of the text.

Probing performance across models and tasks

However, despite this strong start, PubMedBERT was surprisingly prone to overfitting when faced with imbalanced data—a common occurrence in medicine. On the highly imbalanced "Path-PG" task, PubMedBERT’s F1 score dropped to 0.77, failing on minority classes.

The Mixed-Domain "Sweet Spot"

Models like Clinical BioBERT (general BERT + medical fine-tuning) proved to be the most robust, maintaining an F1 score of 0.959 on the imbalanced Path-PG task. The authors suggest that general-domain "knowledge" acts as a regularizer, preventing the model from collapsing onto a single class when training data is skewed. Overall, Clinical BioBERT and BioBERT performed best on average across all tasks (F1 scores ~0.95-0.96).

Representational Shifts and In-Domain Speed

Using Unsupervised Similarity Analysis (RSA), the researchers tracked how representations changed across the models' layers.

Cross-model RSA similarity across layers for four clinical tasks

They found that pre-training on medical data significantly accelerates "feature disambiguation." In-domain models started separating classes around epoch 6, while general models took until epoch 9.

Extreme Sparsification and Outliers

One of the most striking findings from the Feature Dynamics analysis was that after fine-tuning, just two Principal Components (PCs) explained ~95% of the variance in the feature space. The models essentially "throw away" almost all other dimensions to focus entirely on the classification labels.

Because of this extreme sparsification, outlier analysis became highly effective. Expert validation revealed that models consistently fail on "Hard Outliers"—reports that are truncated, inconsistently written, or contain multiple conflicting sources of information.

Limitations and Future Work

This study focused on 110M-parameter encoder-only models. As the field rapidly shifts toward Large Language Models (LLMs) with billions of parameters and decoder-only architectures, future research must determine if these "sparsification" and "imbalance" trends hold true at scale. Additionally, while the pathology dataset provided deep insights, it was relatively small and sourced from a single institution. Applying SUFO to a broader range of clinical tasks and larger, more diverse datasets will help confirm if the "mixed-domain" advantage is a universal rule for medical AI.

Summary updated

BibTeX
@inproceedings{hsu2024diagnosing,
  author = {Aliyah R. Hsu and Yeshwanth Cherapanamjeri and Briton Park and Tristan Naumann and Anobel Odisho and Bin Yu},
  title = {{Diagnosing Transformers: Illuminating Feature Spaces for Clinical Decision-Making}},
  booktitle = {International Conference on Learning Representations},
  year = {2024},
  url = {https://openreview.net/forum?id=k581sTMyPt},
}
Figure