Character-level White-Box Adversarial Attacks against Transformers via Attachable Subwords Substitution

Aiwei Liu, Honghai Yu, Xuming Hu, Shu'ang Li, Li Lin +3 more
10/31/2022
cs.CL
transformer-attention

Official code: THU-BPM/CWBA (10 stars, Python, last commit 2023-04-04).

Abstract

We propose the first character-level white-box adversarial attack method against transformer models. The intuition of our method comes from the observation that words are split into subtokens before being fed into the transformer models and the substitution between two close subtokens has a similar effect to the character modification.

Show full abstract

Our method mainly contains three steps. First, a gradient-based method is adopted to find the most vulnerable words in the sentence. Then we split the selected words into subtokens to replace the origin tokenization result from the transformer tokenizer. Finally, we utilize an adversarial loss to guide the substitution of attachable subtokens in which the Gumbel-softmax trick is introduced to ensure gradient propagation. Meanwhile, we introduce the visual and length constraint in the optimization process to achieve minimum character modifications. Extensive experiments on both sentence-level and token-level tasks demonstrate that our method could outperform the previous attack methods in terms of success rate and edit distance. Furthermore, human evaluation verifies our adversarial examples could preserve their origin labels.

View on arXivView PDF

Code Implementations(1)

THU-BPM/CWBAOfficial100%

The source code of paper "Character-level White-Box Adversarial Attacks against Transformers via Attachable Subwords Substitution" at EMNLP 2022.

100PythonOct 14, 20223 years ago

Similar Papers

Cite this paper

@article{liu2022characterlevel,
  title  = {Character-level White-Box Adversarial Attacks against Transformers via Attachable Subwords Substitution},
  author = {Aiwei Liu and Honghai Yu and Xuming Hu and Shu'ang Li and Li Lin and Fukun Ma and Yawen Yang and Lijie Wen},
  year   = {2022},
  eprint = {2210.17004},
  archivePrefix = {arXiv},
  url    = {https://arxiv.org/abs/2210.17004}
}

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/2210.17004.svg)](https://codeofpaper.com/paper/2210.17004)

Discussion