Model editing offers a promising paradigm for efficiently and precisely updating knowledge in pre-trained transformers without the computational burden of full retraining. While this field has been extensively studied in Large Language Models (LLMs), model editing for Vision Transformers (ViTs) remains underexplored. Traditional methods often adapt LLM-based techniques by modifying the Multi-Layer Perceptron (MLP) modules, but this overlooks the unique architectural characteristics of ViTs.
To address this gap, researchers have introduced RefineViT, a novel model editing framework specifically designed to fix errors in ViTs. By shifting the focus from MLP layers to multi-head self-attention (MSA) modules, RefineViT identifies and suppresses the specific "spurious" features causing misclassifications, achieving state-of-the-art performance in both error correction and model stability.
The Core Insight: Attention Over MLPs
When a massive pre-trained ViT makes a mistake—such as misidentifying a bird because it appears against an unusual background—the traditional solution is fine-tuning. However, fine-tuning is expensive and often leads to "catastrophic forgetting," where fixing one error degrades the model's performance on previously learned tasks.
Model editing aims to make precise, surgical updates to bypass this issue. In LLMs, factual knowledge is largely stored in the MLP modules, making them the primary target for edits. However, applying these same MLP-focused edits to ViTs yields underwhelming results. The authors of RefineViT identified a fundamental mismatch: in ViTs, the "knowledge" and decision-making logic are driven much more by the attention mechanisms than by the MLPs.
The paper's most striking finding is that ablating (removing) all MLP contributions in a ViT has almost zero effect on its accuracy until the very final layers. In stark contrast, removing MSA (attention) contributions causes accuracy to plummet. This proves that effective ViT editing must target the attention heads, which often over-rely on non-causal, spurious features like background textures rather than the core object.
The RefineViT Framework
Building on this insight, the authors propose a two-stage framework to correct model predictions efficiently:
Stage One: Identify the Cause
The framework first decomposes the final image representation into the individual contributions of every MLP layer and every attention head. Using "utility scores" calculated via zero-ablation or mean-ablation, the method ranks which attention heads are most responsible for a specific misclassification. Essentially, it isolates the specific "eyes" of the model that are focusing on distracting or incorrect features.
Stage Two: Rectify the Representation
Once the problematic heads are identified, the model needs to "ignore" them for that specific type of error. Instead of permanently deleting the heads—which might still be useful for other, unrelated tasks—RefineViT learns a lightweight projection matrix. This matrix is trained with two primary objectives:
- Success: Shift the representation of "failed" images toward a corrected version where the problematic features are suppressed.
- Locality: Ensure the representations of "correct" images remain unchanged, preserving the model's existing performance on unrelated data.
Because this projection matrix is tiny and sits at the end of the transformer blocks, the massive transformer backbone remains frozen. This makes RefineViT incredibly fast, capable of performing an edit in under 0.3 seconds on a single A100 GPU.
Evaluation and Key Results
The researchers evaluated RefineViT across a wide variety of challenging scenarios, including a custom ViT Editing Benchmark, datasets testing spurious correlations (Waterbirds, CelebA), and datasets containing adversarial or out-of-distribution renditions (ImageNet-R, ImageNet-A).
Key achievements include:
- Superior Generalization: On the ViT editing benchmark, RefineViT significantly outperformed previous state-of-the-art methods. It successfully fixed the model's underlying logic for similar images, rather than just memorizing the specific image it was shown.
- Robustness to Spurious Cues: On the Waterbirds dataset, RefineViT improved "worst-group accuracy" (the hardest cases where backgrounds are misleading) from 45.6% to 61.4% for a ViT-B/16 model.
- Cross-Architecture Success: The method works seamlessly with CLIP-ViT models, demonstrating its ability to improve zero-shot classification and adapt to complex tasks like image segmentation.
Limitations and Future Directions
While RefineViT marks a significant step forward for vision model editing, the authors note a few limitations. The current method only considers the "direct effect" of individual heads, ignoring complex, multi-layer interactions where heads pass information to one another. Additionally, while preliminary success was shown in segmentation, dense prediction tasks like object detection will require more sophisticated attribution strategies. Finally, achieving "perfect" locality—ensuring absolutely zero impact on unrelated data—remains an ongoing challenge in the broader field of model editing.
Summary updated