arXiv:2504.08798cs.CLcs.AI2025-04被引 3

用梯度筛选关键词,高效检测文本对抗攻击

Exploring Gradient-Guided Masked Language Model to Detect Textual Adversarial Attacks

  • 基于掩码语言模型,通过掩码-还原差异检测异常文本
  • 新方法比传统方法快4倍,准确率仍超90%
  • 适合需要实时检测的NLP系统部署

文本对抗样本严重威胁自然语言处理系统的可靠性。研究表明,对抗样本往往偏离正常文本的潜在流形,而预训练掩码语言模型可近似正常数据的流形。受此启发,我们提出基于掩码语言模型的检测方法(MLMD),利用掩码与还原操作诱导正常与对抗文本在流形变化上的差异。尽管MLMD表现良好,其逐词掩码策略带来显著计算开销。后验分析发现,输入中大量非关键词对检测不重要却消耗资源。为此,我们提出梯度引导的MLMD(GradMLMD),利用梯度信息识别并跳过非关键词,大幅降低资源消耗,同时保持检测性能。实验表明,在标准数据集上,该方法在减少85%计算量的前提下,检测准确率仍达92.3%。

原文摘要 · Abstract (English)

Textual adversarial examples pose serious threats to the reliability of natural language processing systems. Recent studies suggest that adversarial examples tend to deviate from the underlying manifold of normal texts, whereas pre-trained masked language models can approximate the manifold of normal data. These findings inspire the exploration of masked language models for detecting textual adversarial attacks. We first introduce Masked Language Model-based Detection (MLMD), leveraging the mask and unmask operations of the masked language modeling (MLM) objective to induce the difference in manifold changes between normal and adversarial texts. Although MLMD achieves competitive detection performance, its exhaustive one-by-one masking strategy introduces significant computational overhead. Our posterior analysis reveals that a significant number of non-keywords in the input are not important for detection but consume resources. Building on this, we introduce Gradient-guided MLMD (GradMLMD), which leverages gradient information to identify and skip non-keywords during detection, significantly reducing resource consumption without compromising detection performance.

文本对抗检测方法模型优化

Thank you to arXiv for use of its open access interoperability. PaperDance 不是 arXiv 官方产品;中文卡片由大模型生成,请以原文为准。