Are Vision Transformer Representations Semantically Meaningful? A Case Study in Medical Imaging

Montasir Shams, Chashi Mahiul Islam, Shaeke Salman, Phat Tran, Xiuwen Liu · 2025

Read Are Vision Transformer Representations Semantically Meaningful? A Case Study in Medical Imaging by Montasir Shams, Chashi Mahiul Islam, Shaeke Salman, Phat Tran, Xiuwen Liu (2025) in the Tower of Babel, a free online library of public-domain works preserved in clean, searchable text. No sign-up. The full text is served as a plain-text file at a predictable URL, where text is present: https://antarctic-labs.com/tower-of-babel/arxiv-2507-01788.txt.

Introduction

Shams, Islam, Salman, Tran, and Liu ask whether vision transformers, star performers in medical imaging, actually understand what they see. Their inner representations might only look meaningful. Using a gradient-based search, the team crafts image pairs that expose the gap.

Some images differ by changes no eye can see yet land far apart in the model's inner space. Others belong to plainly different classes yet sit nearly on top of each other there. Those tiny nudges can slash classification accuracy by more than sixty percent. The 2025 paper calls this the first systematic proof that such representations lack semantic grounding for medical images. The authors warn against deploying them blindly in safety-critical care.

Catalog record

CREATORMontasir Shams, Chashi Mahiul Islam, Shaeke Salman, Phat Tran, Xiuwen Liu
YEAR2025
COLLECTIONPAPERS
FORMATTXT
FILE SIZE27 KB
VERSION1.0
LICENSEhttp://creativecommons.org/licenses/by/4.0/
RIGHTSCC BY
SOURCEarXiv

Source: https://arxiv.org/abs/2507-01788

Browse the full library · About the Tower of Babel

Full text

The opening of the work, from the library's hosted text:

Are Vision Transformer Representations Semantically Meaningful? A Case Study in Medical Imaging Montasir Shams, Chashi Mahiul Islam, Shaeke Salman, Phat Tran, Xiuwen Liu Abstract Vision transformers (ViTs) have rapidly gained prominence in medical imaging tasks such as disease classification, segmentation, and detection due to their superior accuracy compared to conventional deep learning models. However, due to their size and complex interactions via the self-attention mechanism, they are not well understood. In particular, it is unclear whether the representations produced by such models are semantically meaningful. In this paper, using a projected gradient-based algorithm, we show that their representations are not semantically meaningful and they are inherently vulnerable to small changes. Images with imperceptible differences can have very different representations; on the other hand, images that should belong to different semantic classes can have nearly identical representations. Such vulnerability can lead to unreliable classification results; for example, unnoticeable changes cause the classification accuracy to be reduced by over 60%. To the best of our knowledge, this is the first work to systematically demonstrate this fundamental lack of semantic meaningfulness in ViT representations for medical image classification, revealing a critical challenge for their deployment in safety-critical systems. I Introduction The rapid evolution of large pre-trained foundation models has reshaped the landscape of artificial intelligence across multiple disciplines. Foundation models, built upon massive amounts of data and extensive pre-training, have demonstrated unprecedented generalization capabilities across domains such as natural language processing, computer vision, and multimodal reasoning tasks [ 1 , 2 , 3 , 4 , 5 ] . These models rely on a relatively small application-specific component, which is fine-tuned on top of the shared foundation model. At the core of these models are their representations or embeddings, which capture high-level features of the input data. Such models, however, are not well understood due to their complexity, even though the need for understanding and the risks of lacking are widely recognized and acknowledged. For example, transformers have become a hallmark component in models for diverse applications [ 6 , 7 , 8 ] , including medical imaging tasks like disease classification, segmentation, and detection [ 9 ] . Their ability to model long-range dependencies and capture global contextual information via the self-attention mechanism has led to consistent improvements over traditional convolutional neural networks (CNNs) in several medical imaging benchmarks [ 10 , 11 , 12 ] . Although vision transformers have achieved impressive success in medical image classification, detection, and segmentation, a crucial question remains: Do the internal representations produced by vision transformers correspond to semantically meaningful clinical concepts? The answer to this question holds profound implications for clinical adoption, where interpretability, robustness, and trustworthiness are paramount. In clinical practice, a semantically meaningful representation should exhibit two key properties: stability (similar medical conditions should have similar representations) and distinctiveness (different medical conditions should have distinguishable representations). In medical diagnosis, practitioners rely on specific visual patterns and features to identify conditions. For example, in diabetic retinopathy grading, doctors look for specific patterns of blood vessel changes and lesions. If transformer representations are semantically meaningful, they should organize images based on these clinically relevant features rather than superficial visual similarities. While numerous studies have focused on evaluating the classification performance of ViTs in medical imaging [ 13 , 9 , 14 , 10 ] , relatively little attention has been paid to systematically evaluating whether their learned representations satisfy these desirable semantic properties. This gap is particularly concerning in safety-critical domains such as healthcare, where unreliable representations may lead to incorrect predictions with severe consequences. In this paper, we explore the semantic meaningfulness of vision transformer representations in medical imaging. Rather than merely evaluating model robustness at the level of classification outputs, we directly probe the structure of the representation space itself. Specifically, we introduce Projected Representation Matching (PRM) framework that enables controlled manipulation of an input image’s embedding towards that of a target image, while strictly limiting pixel-level modifications to remain imperceptible to human observers. Through extensive experiments using multiple medical imaging datasets and vision transformer architectures [ 11 , 12 ] , we provide compelling evidence that current transformer representations lack robust semantic grounding. In summary, our main contributions are as follows: • We investigate the semantic meaningfulness of representations in vision transformers and demonstrate their sensitivity to subtle perturbations where a normal image can be changed to a different class even though the changes are imperceptible. For instance, the embedding of a normal image can be modified to match that of a diseased image, with imperceptible changes to the original image. • We demonstrate the results on multiple models (MIL-VT [ 11 ] , MedViT [ 12 ] ) and datasets, providing empirical evidence of the representation dynamics. Our experiments reveal that the proposed approach is model-agnostic and dataset-agnostic. II Related Work The robustness and semantic reliability of representations in deep neural networks have attracted growing research attention across multiple domains. In this section, we review prior works related to (i) vision transformers in medical imaging, and (ii) adversarial robustness of deep models. II-A Vision Transformer in Medical Imaging Transformers, originally designed for language tasks [ 6 ] , have demonstrated superior performance in computer vision and are now widely adopted in medical imaging. Vision Transformers (ViTs), which process images as sequences of patch embeddings via self-attention, have been applied to classification, segmentation, detection, synthesis, and clinical reporting tasks [ 9 , 7 ] . ViT-based models such as MIL-VT [ 11 ] and MedViT [ 12 ] tailor these architectures for medical contexts. MIL-VT integrates multi-instance learning for weakly labeled data, while MedViT combines convolutional and transformer layers to enhance multi-scale feature learning. Additionally, large-scale pretraining on biomedical corpora has given rise to medical foundation models like BioMedCLIP and PMC-CLIP [ 15 , 16 ] . Despite strong task performance, most of these studies focus on end-to-end accuracy, with limited attention to the semantic structure of the learned representations. In clinical settings, however, explainability and semantic alignment are vital for interpretability, physician trust, and regulatory compliance. II-B Adversarial Robustness in Medical Imaging It is well known that deep neural networks are susceptible to adversarial examples; small, imperceptible perturbations lead to drastic changes in model output [ 17 , 18 , 19 ] . However, relatively few studies have been done to evaluate the effect of adversarial attacks on these transformer-based models in the medical field. Using the attack methods developed for CNN models [ 20 , 21 , 22 , 23 ] , recent studies [ 24 , 25 ] show that ViTs exhibit greater resilience against typical attacks compared to CNN models due to more structured latent spaces. While these findings are promising, they also highlight the need for a deeper understanding of vision transformer representations, particularly their semantic meaningfulness. In this paper, using a gradient-based optimization algorithm, we are able to explore the representations in the neighborhood of an image. More specifically, we can modify the representation of an image to match that of another image with unnoticeable changes. The results show that images with imperceptible differences can have very different representations, and at the same time, very different images can have very similar representations. Therefore, the representations

Read the complete text