[论文解读] BERT-ATTACK: Adversarial Attack Against BERT Using BERT
BERT-ATTACK 通过使用 BERT 的掩码语言模型来替换易受攻击的词,生成流畅且语义保持的对抗文本,在多种 NLP 任务中以低扰动实现高攻击成功率。
Adversarial attacks for discrete data (such as texts) have been proved significantly more challenging than continuous data (such as images) since it is difficult to generate adversarial samples with gradient-based methods. Current successful attack methods for texts usually adopt heuristic replacement strategies on the character or word level, which remains challenging to find the optimal solution in the massive space of possible combinations of replacements while preserving semantic consistency and language fluency. In this paper, we propose extbf{BERT-Attack}, a high-quality and effective method to generate adversarial samples using pre-trained masked language models exemplified by BERT. We turn BERT against its fine-tuned models and other deep neural models in downstream tasks so that we can successfully mislead the target models to predict incorrectly. Our method outperforms state-of-the-art attack strategies in both success rate and perturb percentage, while the generated adversarial samples are fluent and semantically preserved. Also, the cost of calculation is low, thus possible for large-scale generations. The code is available at https://github.com/LinyangLee/BERT-Attack.
研究动机与目标
- 推动对 NLP 模型在对抗文本扰动下的鲁棒性评估。
- 提出一种高质量的攻击方法,通过利用预训练语言模型(BERT)来保持流畅性和语义完整性。
- 展示在文本分类和自然语言推理任务中的有效性。
- 展示对其他架构的对抗样本的效率与可迁移性。
提出的方法
- 两阶段框架:识别最具影响力的词并用来自 BERT 掩码语言模型的上下文感知替换词进行替换。
- 通过对每个标记进行掩蔽并测量目标模型正确性对数值的下降来计算词的重要性,以对候选词进行排序。
- 使用 BERT 的 MLM 的前 K 个预测替换所选词,结合 BERT 的 BPE 分词对齐来处理整词和子词。
- 对每个候选替换,检查目标模型的预测是否改变;在找到成功攻击时停止。
- 对子词扰动使用困惑度(perplexity)排序,以确保语法性和语义连贯性。
- 通过 MLM 的一次前向传播实现扰动,避免使用昂贵的评分模型。
实验结果
研究问题
- RQ1是否可以使用一个预训练的掩码语言模型(BERT)来生成流畅且语义保持的对抗文本,从而欺骗下游的 NLP 模型?
- RQ2在多样任务(文本分类和自然语言推理 NLI)及不同模型上,基于 BERT 的扰动策略有多有效?
- RQ3攻击成功率、扰动幅度与流畅性/语义之间存在哪些权衡?
- RQ4BERT-Attack 样本对其他体系结构的可迁移性如何?对抗性数据是否能通过对抗性训练提升模型鲁棒性?
主要发现
- BERT-Attack 在多任务上实现高攻击成功率,显著降低微调模型的攻击后准确率。
- 在评估任务中扰动比例保持在 10% 以下,显示出强语义保持性。
- 由于避免重复评分模型,该方法需要的查询次数更少,速度比若干基线更快。
- 人工评估显示对抗样本在语法和语义完整性方面与原始文本相似。
- 该攻击可迁移到其他模型(如基于 LSTM 的模型和 BERT-Large 目标),显示出跨模型的有效性。
- 通过使用 BERT-Attack 样本进行对抗性训练可以提高模型鲁棒性,提升程度因任务而异。
更好的研究,从现在开始
从论文设计到论文写作,大幅缩短您的研究时间。
无需绑定信用卡
本解读由 AI 生成,并经人工编辑审核。