Mechanistic Analysis of Adversarial Fine-Tuning of Vision TransformersA Mechanistic Analysis of Adversarial Fine-tuning of Vision Transformers
The authors adversarially fine-tune ViT-B/16 on Gaussian blur/noise and conduct mechanistic analysis, reporting that the performance gains do not transfer across perturbation families and that sparse representations show no fundamental change.
- Image classification models degrade in performance under common perturbations such as blur and noise, and as the vision backbone of VLMs/VLAs, ViT's robustness to common perturbations lacks mechanistic study.
- Apply 3 levels of Gaussian blur and 3 levels of Gaussian noise to 10k images from the ImageNet validation set, fine-tune ViT-B/16 separately, then use logit lens, attention entropy analysis and SAE representation analysis to compare the internal processing differences before and after fine-tuning.
- On new blurred images, the blur-fine-tuned model's top-1 rises from 0.649 to 0.753 (Blur 4 tuned, Table 1), but the improvement does not transfer to the other perturbation family; the fine-tuned model predicts the correct class earlier and more confidently; the SAE activation cosine similarity distributions are almost identical between the two models.
- The authors state that future work could study transfer between different filters within the same family, and separating and controlling the key differences between base and fine-tuned models (Section 5). The experiments cover only one model, ViT-B/16, and two perturbation types, Gaussian blur and Gaussian noise.
- Evaluated models
- ViT-B/16
- Benchmarks
- ImageNet ILSVRC2012ImageNet21
- Metrics
- top-1 accuracytop-5 accuracytop-10 accuracyECEattention entropycosine similarity
Researchers analyze the impact of adversarial fine-tuning on the robustness of Vision Transformers (ViT) from a mechanistic perspective, adversarially training ViT on low-frequency and high-frequency image corruptions respectively, and explaining performance changes from attention mechanisms, internal representations, and knowledge evolution. The results show that fine-tuning on common corruptions improves the model's performance and certainty on new corruption samples, but does not transfer to other corruption categories unseen in training; despite changes in visual attention and knowledge evolution across layers, adversarial training does not fundamentally change the sparse representations learned by ViT.
Paper analysis
What problem does this paper attempt to solve?
The authors aim to explain mechanistically how adversarially fine-tuning ViT on common perturbations changes its performance and internal processing.
Core question: what actually changes inside the model when adversarial fine-tuning improves ViT robustness to image perturbations.
- Problem setting: Image classification models are used in high-risk settings such as medical imaging and autonomous driving, where blur, noise and other perturbations are common in reality; ViTs are being directly integrated into VLM and VLA models for perception, and the authors consider studying their robustness increasingly important.
- Gaps in existing research: The authors state that existing work on common corruptions only focuses on downstream performance effects and proposes mitigations such as adversarial training, without further mechanistic understanding of why performance changes; analyses of ViT robustness to perturbations are also relatively scarce.
- Core motivation: Fine-tuning has been shown to bring unexpected side effects (e.g., catastrophic forgetting, ref. [27]), so the authors believe a mechanistic understanding of how adversarial training affects the model is needed.
- Research questions: 1) What effect does adversarial training have on ViT downstream performance? 2) How can the performance change be explained mechanistically?
- Paper approach: Adversarially fine-tune ViT on ImageNet with low-frequency (Gaussian blur) and high-frequency (Gaussian noise) perturbations respectively, then use logit lens, attention analysis and SAE representation analysis to compare the models before and after fine-tuning (Figure 1).
What related research exists?
Related work falls into two groups: research on visual model robustness and research on mechanistic interpretability of visual models.
Visual model robustness
- Adversarial attack direction: Goodfellow et al. (2015), Madry et al. (2019), Rowe et al. (2022) and others study adversarial attacks against visual models; the authors state that most work concentrates on this direction.
- Common perturbation direction: Hendrycks & Dietterich (2019) propose the common corruptions benchmark (ImageNetC); Wang et al. (2024) survey the robustness of visual models to common perturbations; Usama et al. (2025) analyze the robustness of VLMs to common perturbations. These studies find that visual models exhibit varying degrees of vulnerability to multiple types of common perturbations (especially high-frequency perturbations).
- ViT robustness: Mahmood et al. (2021) study the robustness of ViTs to adversarial examples; the authors state that robustness analyses of ViTs against image perturbations, especially common perturbations, are relatively scarce, and existing work only focuses on downstream performance and proposes mitigations such as adversarial training (e.g., C-LEAD by Ghosh et al. 2025), without mechanistic explanation.
Mechanistic interpretability of visual models
- Transfer of language model techniques: The authors state that most mechanistic interpretability work focuses on language models (e.g., SAE by Cunningham et al. 2023, Meng et al. 2023, Wang et al. 2022), and only recently has work adapted techniques such as activation inspection, logit attribution and SAE to visual models (Jiang et al. 2025; Joseph & Nanda 2024; Stevens et al. 2025).
- Vision-specific techniques: Grad-CAM by Selvaraju et al. (2019), Diffusion Lens by Toker et al. (2024), etc.
Positioning: The authors state that the internal working mechanisms of visual models are understudied, especially in fine-tuning and robustness settings; this paper uses mechanistic interpretability methods to study the model's internal processing of perturbed images, filling this gap. The paper sets no comparison baseline method; the comparison object is the un-fine-tuned base ViT.
How does the paper address this problem?
Adversarially fine-tune ViT-B/16 with blur/noise respectively, then compare before and after differences along three mechanistic analysis lines: logit lens, attention entropy and SAE.
Overall approach: first apply common perturbations to ImageNet images and adversarially fine-tune ViT, then compare the downstream performance of the base and fine-tuned models, and analyze the differences using a set of mechanistic interpretability techniques (Figure 1).
Adversarial training setup
- Two perturbation types: Gaussian blur for low-frequency perturbations and Gaussian noise for high-frequency perturbations, each at severity levels 1, 2, and 4.
- Severity definition: the blur level is used as the standard deviation of the blur kernel; the noise level follows the ImageNetC implementation; higher levels mean stronger perturbations.
- Fine-tuning data: 6 perturbations were each applied to 10k images held out from the ImageNet validation set, and one ViT was fine-tuned separately for each perturbation.
- Training hyperparameters: at most 10 epochs, early stopping, learning rate 5e-5, AdamW optimizer, linear learning rate schedule.
Evolution of class predictions across layers (modified logit lens)
- Method: adapt the LLM logit lens to the ViT classifier—apply the classification head to the CLS token representation c(l) of intermediate layer l to obtain logits(l), then apply softmax to obtain the class probability distribution at that layer.
- Two quantities: the average probability of predicting the correct class at each layer; and, on inputs where the model can predict correctly at some layer, the layer at which the correct answer first becomes the prediction (first emergence layer).
Attention analysis
- Measures: for the original and perturbed images, compare the squared difference and cosine similarity of each layer's attention output.
- Attention entropy: Hh,i(l) = −∑j=1T Ah,i,j(l) log(Ah,i,j(l)), i.e., the entropy of the attention distribution of head h and query token i at layer l; averaging over all heads and query tokens gives the average entropy H(l) per layer. The entropy difference between the original image x and the perturbed image x̃ is compared to measure how concentrated or diffuse attention is over image patches.
SAE representation analysis
- Location: SAE is trained on the output of the penultimate layer of ViT, based on the recommendation in [6] to place SAEs near the end of the model.
- Two SAEs: Vanilla ReLU SAE, with a loss of reconstruction error plus an L1 sparsity term; BatchTopK SAE, with a loss of ||x − Dec(ztopk)||22 + λ||ztopk||1 + α Laux, where ztopk is the BatchTopK encoder output.
- Hyperparameters: expansion factor 32; for BatchTopK, α=1/32, k=32; trained for 15 epochs, early stopping, initial learning rate 1e-3, Cosine Annealing schedule; training data mixes unperturbed and perturbed images.
- Similarity measure: compute the cosine similarity of SAE activations for corresponding patches of the original and perturbed images, and compare the distributions of the base and fine-tuned models.
What experiments did the paper conduct?
Fine-tune 6 perturbation models on ViT-B/16, and measure downstream performance, cross-layer predictions, attention entropy differences and SAE representation similarity.
Experimental setup
- Models tested: Google's ViT-B/16 (pretrained on ImageNet21, fine-tuned on ImageNet ILSVRC2012), and 6 models obtained by fine-tuning it separately with 6 perturbations (Gaussian blur level 1/2/4, Gaussian noise level 1/2/4).
- Data: fine-tuning used 10k images held out from the ImageNet validation set (one set per perturbation); evaluation used 1k new blurred and noisy image samples.
- Metrics: top-1, top-5, top-10 accuracy and ECE; under the logit lens, the per-layer correct-class probability and the layer where the correct answer first appears; attention entropy difference; SAE activation cosine similarity distribution.
- Evaluation method: all are automatic metrics; the paper did not use human or LLM review; the paper did not report the number of repetitions.
Main results
Table 1 reports the results of the base model and three blur fine-tuned models on new blurred images:
Swipe horizontally to read the table
Model Acc. Top 5 Acc. Top 10 Acc. ECE Base 0.649 0.860 0.903 0.054 Blur 1 tuned 0.725 0.905 0.941 0.046 Blur 2 tuned 0.744 0.922 0.953 0.054 Blur 4 tuned 0.753 0.929 0.954 0.055 (According to Table 1; the test condition is new blurred images, and the paper does not state the test perturbation level in the table caption)
- Monotonic improvement: the authors state that each accuracy of the blur fine-tuned models rises monotonically with the blur level used in training, with Blur 4 tuned performing best; the noise fine-tuned models show the same trend on new noise samples (Figure 3), but the paper does not provide a corresponding numerical table for the noise models.
- Largest top-1 gain: the authors state that on blur-4 and noise-4 test data, the top-5 and top-10 of the models are close, and the improvement is mainly in top-1 (Figure 2, Figure 3).
- No transfer and no harm: the authors observe that the accuracy of blur fine-tuned models on noise-4 and of noise fine-tuned models on blur-4 is almost unchanged; it is also almost unchanged on unperturbed ImageNet images. The authors therefore conclude that the robustness gained from single-family perturbation training does not transfer (but is also not harmful), and neither benefits nor harms regular performance.
Evolution of class predictions across layers
- What was measured: the average probability of predicting the correct class at each layer for each fine-tuned model (Figure 4, blur and noise at severity 4).
- Results: the authors state that all models start with similar probabilities, and models fine-tuned at the highest severity overtake in the middle-to-later layers; on inputs restricted to "the model can predict correctly at some layer", the fine-tuned models first predict correctly at an earlier layer than the base model (Figure 5, Figure 6), and the effect is more pronounced for blur than for noise.
- Authors' interpretation: the mechanism of the performance gain may be localized to the middle-to-later layers, but whether a controllable mechanism exists requires further research.
Attention analysis
- What was measured: the average attention entropy difference between original and perturbed images at each layer (Figure 7 blur, Figure 8 noise).
- Results: under both perturbations, the entropy difference is initially negative (attention in the perturbed image is more concentrated), then turns positive; on blurred data, the base model has the highest entropy difference; on noise data, the base model has a higher entropy difference at roughly layers 2 to 5, but this effect weakens in later layers.
- Authors' interpretation: robustness fine-tuning for blur may make the model focus on more specific patches; high-frequency noise fine-tuning may change the attention distribution little.
SAE representation analysis
- What was measured: on the blur-4-tuned ViT and the base ViT, the cosine similarity distribution of SAE activations for corresponding patches of the original and blurred images (Figure 9 Vanilla SAE, Figure 10 BatchTopK SAE).
- Results: the authors state that the cosine similarity distributions of the two models are nearly identical.
- Authors' interpretation: the robustness gain from adversarial training may have little to do with fundamental differences in the representations learned by the model.
Other ablations and analyses
- The paper does not report other independent ablations; the SAE section cross-validates with two variants, Vanilla and BatchTopK (Figure 9, Figure 10).
What are some points that can be further explored?
The authors propose two future directions: transfer between filters within the same family, and separating and controlling the key differences between the base and fine-tuned models.
Limitations and future directions noted by the authors
- Within-family transfer: The authors state that future work could study how training transfers between different filters within the same perturbation family (Section 5).
- Mechanism separation and control: The authors state that future directions for mechanistic analysis include attempting to separate and control the key differences between the base and fine-tuned models (Section 5).
- Mid-to-late layer mechanisms to be investigated: The authors state that the phenomenon of the fine-tuned model overtaking in mid-to-late layers suggests the mechanism may be localized to these layers, but further research is needed to determine whether this mechanism exists and whether it is controllable (Section 4.2).
Experimental coverage
- Models tested: Only one model, Google ViT-B/16, and its 6 fine-tuned versions (Section 4).
- Perturbation types: Only two types, Gaussian blur and Gaussian noise, each with 3 severity levels (1, 2, 4) (Section 3.1).
- Data scale: 10k ImageNet validation set images per perturbation for fine-tuning, and 1k new perturbed samples for evaluation (Section 4, Section 4.1).
- SAE analysis object: The SAE representation analysis reports only the comparison between the blur-4-tuned model and the base (Figure 9, Figure 10), and does not report corresponding results for the noise-fine-tuned model.
- Not reported: The paper does not report the number of experimental repetitions, statistical significance tests, or a numerical table for the noise-fine-tuned model under conditions corresponding to Table 1.
Summarize the main content of the paper
Adversarially fine-tune ViT-B/16 with blur/noise and conduct mechanistic analysis: performance gains do not transfer across families, and representations show no fundamental change.
A mechanistic analysis paper on adversarial fine-tuning of ViT, studying the internal changes behind improved robustness to common image perturbations.
- Problem: ViTs are being widely integrated into VLM/VLA models, but the authors state that existing common perturbation studies only look at downstream performance and lack mechanistic understanding.
- Method: Apply Gaussian blur and Gaussian noise (each at severity 1/2/4) to 10k ImageNet validation images, fine-tune ViT-B/16 separately; then use an adapted logit lens, attention entropy analysis and SAE (Vanilla and BatchTopK) representation analysis to compare the models before and after fine-tuning.
- Performance results: On new blurred images, the blur-fine-tuned model's top-1 rises from 0.649 for the base to 0.753 for Blur 4 tuned (Table 1), and increases monotonically with the training perturbation level; the improvement is concentrated in top-1, with top-5/top-10 close across models.
- Transfer results: The blur-fine-tuned model on noise-4 and the noise-fine-tuned model on blur-4 show almost no improvement; on unperturbed images there is also almost no change, and the authors state that robustness does not transfer across perturbation families but is also not harmful.
- Mechanistic results: The authors state that the fine-tuned model first predicts the correct class at earlier layers and is more confident about the correct answer (Figure 4–6); blur fine-tuning may make attention more focused on specific patches (Figure 7); however, the SAE activation cosine similarity distributions are almost identical between the base and blur-4-tuned (Figure 9, 10), and the authors believe the robustness improvement may not stem from fundamental changes in representation.
- Authors' conclusion: Adversarial fine-tuning improves performance and confidence on same-family perturbations but does not transfer to other perturbation families; the authors believe this highlights the importance of comprehensive adversarial training data; future work could study transfer between filters within the same family and the separation and control of key differences.