RepTran: Search-Based Repair of Transformer Models

Yuta Ishimoto, Paolo Arcaini, Fuyuki Ishikawa, Masanari Kondo, Naoyasu Ubayashi, Yasutaka KameiarXiv 2026 · arXiv

TL;DR

REPTRAN is a novel search-based repair method specifically designed to fix targeted misbehaviors in Transformer models without the need for costly full retraining. By focusing on the model's feed-forward networks (FFNs) and combining a new variance-based neuron score with evolutionary optimization, REPTRAN achieves an average repair rate of 74.7%, significantly outperforming existing deep neural network (DNN) repair baselines.

What Problem Does This Paper Address?

When a deep learning model misbehaves—such as consistently misclassifying a specific critical object—fully retraining the model from scratch is often prohibitively expensive and doesn't guarantee the specific bug will be fixed. Deep Neural Network (DNN) repair has emerged as a lightweight alternative, aiming to surgically adjust a small set of weights to correct specific errors while preserving the model's existing correct behaviors.

However, almost all existing DNN repair frameworks were built for conventional architectures like Convolutional Neural Networks (CNNs). They completely overlook the unique structural components of Transformers, such as Multi-Head Self-Attention (MSA) and Feed-Forward Networks (FFNs). As Transformers become the backbone of safety-critical AI systems (e.g., autonomous driving), there is a glaring gap for a repair method tailored specifically to their architecture.

Methods

REPTRAN tackles this challenge by focusing its repair efforts on the FFNs of the Transformer, which recent interpretability research suggests act as "key-value memories" storing learned knowledge. The method operates in two main phases:

  1. Selection Phase (Localization): To avoid modifying millions of parameters, REPTRAN calculates a weight suspiciousness score to find the small subset of weights most responsible for the misbehavior. This score introduces a novel neuron score combined with an existing bidirectional score (from a baseline method called ARACHNE).
  2. The neuron score measures two things using a single forward pass: VDiff (how differently an intermediate FFN neuron's activation variance behaves between correct and incorrect inputs) and MisAct (how strongly the neuron fires on average during a misbehavior).
  3. Search Phase (Optimization): Once the top suspicious weights are selected, REPTRAN uses Differential Evolution (DE)—a population-based genetic algorithm—to iteratively optimize these weight values. The search is guided by a custom fitness function designed to maximize correct predictions on the broken samples while minimizing the "break rate" (disrupting previously correct classifications).
An overview of the REPTRAN repair process, showing the selection and search phases.

Datasets

The authors evaluated REPTRAN using the Vision Transformer (ViT) architecture across 18 distinct fault benchmarks generated from two widely used image classification datasets:

  • CIFAR-100: 50,000 training and 10,000 test images across 100 classes.
  • Tiny-ImageNet: A subset of ImageNet featuring 100,000 training and 10,000 test images across 200 classes.

The 18 benchmarks were constructed by isolating specific frequent misclassification patterns, categorized into three types: specific source-to-target swaps (SRC-TGT), false positives (TGT-FP), and false negatives (TGT-FN).

Key Insights and Ideas

  • The Final Layer is the Prime Target: Why only repair the final layer of the Transformer? The authors analyzed the neuron scores across all layers and discovered that the final layer's FFN consistently exhibits significantly higher scores than preceding layers. This empirically proves that the final layer captures the most distinguishable behavioral differences between correct and incorrect inputs.
  • Efficiency via Single-Pass Metrics: Previous methods for identifying important "knowledge neurons" rely on techniques like Integrated Gradients, which require computationally heavy backward passes. REPTRAN’s neuron score achieves high localization accuracy using only a single forward pass per input, making the repair process highly efficient.
  • Overcoming the Scalability Wall: Global solver-based repair methods (like linear programming) hit a scalability wall when dealing with large label spaces like Tiny-ImageNet, often resulting in timeouts. REPTRAN's localized search avoids this bottleneck entirely.

Key Results

  • High Repair Effectiveness: REPTRAN achieved an average repair generalization rate of 74.7% across all 18 benchmarks, reaching up to 95.2% in the best case. In comparison, directly applying the state-of-the-art ARACHNE baseline to the FFNs yielded an average repair rate of just 17.1%.
  • Impressive Speed and Convergence: Despite optimizing a larger pool of selected weights than ARACHNE (472 vs. 11), REPTRAN was faster, clocking an average total repair time of 476.19 seconds compared to ARACHNE's 620.93 seconds. This efficiency is due to rapid fitness convergence, allowing REPTRAN to trigger early stopping in 87.8% of its runs.
  • Low Side Effects: The average "break rate" (the percentage of previously correct samples that were accidentally broken during repair) remained safely low at 1.5%, demonstrating a highly controlled modification process.

Limitations and Future Work

  • Hyperparameter Tuning: The performance of REPTRAN relies on parameters like the number of selected weights ($N_w$) and balance coefficients ($p$ and $\alpha$). While the paper explores these, an automated way to tune them per fault remains future work.
  • Extension to NLP and LLMs: The evaluation was strictly bounded to Vision Transformers (ViT) for image classification. Testing whether FFN-only repair scales effectively to Large Language Models (LLMs) with billions of parameters is a critical next step.
  • Broader Quality Attributes: The current definition of "successful repair" is limited to accuracy correctness. Future iterations will need to explore how such repairs impact other vital model attributes like robustness, fairness, and safety.

Summary updated

Abstract

To ensure the overall quality of AI-enabled software, not only traditional software components but also AI components need to be tested and repaired. Among AI components, Transformer models are increasingly integrated into software systems, which makes their misbehaviors critical. Although prior work in the software engineering community has proposed deep neural network (DNN) repair methods, most overlook Transformer-specific structures. We propose RepTran, a search-based repair method for Transformer models. It targets their feed-forward networks (FFNs), which play a central role in the architecture. RepTran identifies suspicious weights by combining two types of scores: a variance-based neuron score and an existing bidirectional score. It then iteratively optimizes these weights using differential evolution. Our evaluation includes 18 fault benchmarks constructed from CIFAR-100 and Tiny-ImageNet. We compare RepTran against three baselines: random weight selection, Arachne (a state-of-the-art DNN repair method), and ArachneW, which enables Arachne to control the number of selected weights. RepTran achieved an average repair rate of 74.7%, statistically outperforming random selection and Arachne across all benchmarks. Effect size analysis revealed that RepTran achieved higher repair rates than ArachneW regardless of the number of selected weights. These results suggest that RepTran is effective for enhancing the reliability of AI-enabled software.
BibTeX
@misc{ishimoto2026reptran,
  author = {Yuta Ishimoto and Paolo Arcaini and Fuyuki Ishikawa and Masanari Kondo and Naoyasu Ubayashi and Yasutaka Kamei},
  title = {{RepTran: Search-Based Repair of Transformer Models}},
  year = {2026},
  eprint = {2607.11193},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2607.11193},
}
Figure