A Study of the Attention Abnormality in Trojaned BERTs

Weimin Lyu, Songzhu Zheng, Tengfei Ma, Chao Chen
5/13/2022
cs.CRcs.AIcs.LG

Official code: weimin17/AttenTD (8 stars, Python, last commit 2023-09-05).

Abstract

Trojan attacks raise serious security concerns. In this paper, we investigate the underlying mechanism of Trojaned BERT models.

Show full abstract

We observe the attention focus drifting behavior of Trojaned models, i.e., when encountering an poisoned input, the trigger token hijacks the attention focus regardless of the context. We provide a thorough qualitative and quantitative analysis of this phenomenon, revealing insights into the Trojan mechanism. Based on the observation, we propose an attention-based Trojan detector to distinguish Trojaned models from clean ones. To the best of our knowledge, this is the first paper to analyze the Trojan mechanism and to develop a Trojan detector based on the transformer's attention.

View on arXivView PDF

Code Implementations(1)

weimin17/AttenTDOfficial100%

Codes for NAACL'22 "A Study of the Attention Abnormality in Trojaned BERTs", a textural Trojan Detector

81Python, ShellApr 30, 20223 years ago

Similar Papers

Cite this paper

@article{lyu2022study,
  title  = {A Study of the Attention Abnormality in Trojaned BERTs},
  author = {Weimin Lyu and Songzhu Zheng and Tengfei Ma and Chao Chen},
  year   = {2022},
  eprint = {2205.08305},
  archivePrefix = {arXiv},
  url    = {https://arxiv.org/abs/2205.08305}
}

Add a badge to your README

Shows whether official code is linked for this paper.

Code of Paper badge
[![Code of Paper](https://codeofpaper.com/badge/2205.08305.svg)](https://codeofpaper.com/paper/2205.08305)

Discussion