Gradient-based Adversarial Attacks against Text Transformers
Chuan Guo∗ Alexandre Sablayrolles Hervé Jégou Douwe Kiela Facebook AI Research ∗Equal contribution.
Abstract
We propose the first general-purpose gradient-based attack against transformer models. Instead of searching for a single adversarial example, we search for a distribution of adversarial examples parameterized by a continuous-valued matrix, hence enabling gradient-based optimization. We empirically demonstrate that our white-box attack attains state-of-the-art attack performance on a variety of natural language tasks. Furthermore, we show that a powerful black-box transfer attack, enabled by sampling from the adversarial distribution, matches or exceeds existing methods, while only requiring hard-label outputs.
中文速览
针对自然语言处理中的对抗样本生成难题,传统方法因文本的离散性无法直接使用梯度下降,只能依赖启发式词替换和黑盒搜索,导致攻击效果有限且生成文本不自然。本文提出 GBDA(基于梯度的分布式攻击,Gradient-based Distributional Attack),核心思路是不再寻找单一对抗样本,而是用 Gumbel-softmax 参数化一个连续可导的对抗样本分布,从而让梯度优化得以施展;同时引入语言模型困惑度和 BERTScore 作为可微的软约束,保证生成文本的流畅性和语义相似度。实验表明,GBDA 在新闻分类、情感分析、自然语言推理等多项任务上均达到最先进的攻击成功率,例如将 BERT 在 AG News 上的准确率从 94.2% 压低至 2.5%,远优于此前最好方法的 10.6%;此外,通过从优化好的对抗分布中采样并迁移到未知目标模型,仅凭硬标签输出即可实现强力的黑盒迁移攻击,对评估和提升大型语言模型的鲁棒性具有重要价值。
原文 arXiv:2104.13733;中英对照 + 大白话阅读 https://aha.fim.ai/paper/2104.13733v1