一句话:提出 AtPatch,在推理时动态重分布注意力图,热修复 Transformer 的过度注意力,缓解后门与不公平。
受后门攻击和不公平影响的 Transformer 常出现异常注意力模式,表现为过度关注后门触发器或受保护属性。现有神经元编辑缓解方法难以处理该问题,且缺乏灵活性并容易扭曲特征表示。受增量调试与热补丁等软件工程范式启发,AtPatch 在模型推理过程中动态重分布注意力图:先提取注意力图,用预训练检测器识别异常列并替换为统一的良性注意力,再重缩放其他列以减轻过度注意力,最后将重分布后的注意力图返回模型继续推理;若未检测到异常列,则直接返回原始注意力图。该方法无需修改模型参数或重新训练,更适合已部署模型。实验表明,与现有方法相比,AtPatch 能更有效缓解后门攻击和不公平,同时更好保留模型原有功能。
Transformer-based deep neural networks (DNNs) affected by backdoor attacks and unfairness typically exhibit anomalous attention patterns, leading to over-attend to backdoor triggers or protected attributes. Existing neuron-editing mitigation strategies often struggle to handle such situation and most of them lack flexibility and tend to distort feature representations. Motivated by such over-attention phenomenon and software engineering paradigms such as delta debugging and hot patching, we propose AtPatch, a hot-fix method that dynamically redistributes attention maps during model inference. Specifically, for a given input, AtPatch first extracts the attention map from the model's inference process. Then, it uses a pre-trained detector to identify anomalous columns and replace them with unified benign attention. Then, AtPatch rescales other columns to mitigate the impact of over-attention. Finally, AtPatch returns the redistributed attention map to the model for continued inference. Notably, if the detector does not report any anomalous columns, AtPatch directly returns the original attention map to the model. Unlike existing techniques, AtPatch selectively redistributes the attention map, making it better at preserving the model's original functionality. Furthermore, AtPatch's on-the-fly nature allows it to work without modifying model parameters or retraining, making it better suited for deployed models. We conducted extensive experiments to validate AtPatch. Experimental results show that, compared to existing methods, AtPatch can more effectively mitigate backdoor attacks and unfairness while better preserving the model's original functionality.
@inproceedings{paperbot11925,
title = {AtPatch: Debugging Transformers via Hot-Fixing Over-Attention},
author = {Shihao Weng and Yang Feng and Jincheng Li and Yining Yin and Xiaofei Xie and Jia Liu},
booktitle = {ICSE},
year = {2026},
doi = {10.1145/3744916.3764559}
}