Robustness evaluation against adversarial examples has become increasingly important to unveil the trustworthiness of the prevailing deep models in natural language processing (NLP). However, in contrast to the computer vision domain where the first-order projected gradient descent (PGD) is used as the benchmark approach to generate adversarial examples for robustness evaluation, there lacks a principled first-order gradient-based robustness evaluation framework in NLP. The emerging optimization challenges lie in 1) the discrete nature of textual inputs together with the strong coupling between the perturbation location and the actual content, and 2) the additional constraint that the perturbed text should be fluent and achieve a low perplexity under a language model. These challenges make the development of PGD-like NLP attacks difficult. To bridge the gap, we propose TextGrad, a new attack generator using gradient-driven optimization, supporting high-accuracy and high-quality assessment of adversarial robustness in NLP. Specifically, we address the aforementioned challenges in a unified optimization framework. And we develop an effective convex relaxation method to co-optimize the continuously-relaxed site selection and perturbation variables and leverage an effective sampling method to establish an accurate mapping from the continuous optimization variables to the discrete textual perturbations. Moreover, as a first-order attack generation method, TextGrad can be baked into adversarial training to further improve the robustness of NLP models. Extensive experiments are provided to demonstrate the effectiveness of TextGrad not only in attack generation for robustness evaluation but also in adversarial defense.
translated by 谷歌翻译
尽管在许多机器学习任务方面取得了巨大成功,但深度神经网络仍然易于对抗对抗样本。虽然基于梯度的对抗攻击方法在计算机视野领域探索,但由于文本的离散性质,直接应用于自然语言处理中,这是不切实际的。为了弥合这一差距,我们提出了一般框架,以适应现有的基于梯度的方法来制作文本对抗性样本。在该框架中,将基于梯度的连续扰动添加到嵌入层中,并在前向传播过程中被放大。然后用掩模语言模型头解码最终的扰动潜在表示以获得潜在的对抗性样本。在本文中,我们将我们的框架与\ textbf {t} Extual \ TextBF {P} ROJECTED \ TextBF {G} Radient \ TextBF {D} excent(\ TextBF {TPGD})进行ronject \ textbf {p}。我们通过在三个基准数据集上执行转移黑匣子攻击来评估我们的框架来评估我们的框架。实验结果表明,与强基线方法相比,我们的方法达到了更好的性能,并产生更精细和语法的对抗性样本。所有代码和数据都将公开。
translated by 谷歌翻译
文本对抗攻击暴露了文本分类器的漏洞,可用于改善其稳健性。现有的上下文感知方法仅考虑黄金标签的概率,并在搜索攻击路径时使用贪婪的搜索,通常会限制攻击效率。为了解决这些问题,我们提出了PDB,这是一种使用概率差的引导光束搜索的上下文感知的文本对抗攻击模型。概率差异是所有类标签概率的总体考虑,PDB使用它来指导攻击路径的选择。此外,PDBS使用Beam搜索找到成功的攻击路径,从而避免搜索空间有限。广泛的实验和人类评估表明,PDB在一系列评估指标中的表现优于以前的最佳模型,尤其是提高 +19.5%的攻击成功率。消融研究和定性分析进一步证实了PDB的效率。
translated by 谷歌翻译
Adversarial training is widely acknowledged as the most effective defense against adversarial attacks. However, it is also well established that achieving both robustness and generalization in adversarially trained models involves a trade-off. The goal of this work is to provide an in depth comparison of different approaches for adversarial training in language models. Specifically, we study the effect of pre-training data augmentation as well as training time input perturbations vs. embedding space perturbations on the robustness and generalization of BERT-like language models. Our findings suggest that better robustness can be achieved by pre-training data augmentation or by training with input space perturbation. However, training with embedding space perturbation significantly improves generalization. A linguistic correlation analysis of neurons of the learned models reveal that the improved generalization is due to `more specialized' neurons. To the best of our knowledge, this is the first work to carry out a deep qualitative analysis of different methods of generating adversarial examples in adversarial training of language models.
translated by 谷歌翻译
离散对手攻击是对保留输出标签的语言输入的象征性扰动,但导致预测误差。虽然这种攻击已经广泛探索了评估模型稳健性的目的,但他们的改善稳健性的效用仅限于离线增强。具体地,给定训练有素的模型,攻击用于产生扰动(对抗性)示例,并且模型重新培训一次。在这项工作中,我们解决了这个差距并利用了在线增强的离散攻击,在每个训练步骤中产生了对抗的例子,适应模型的变化性质。我们提出(i)基于最佳搜索的新的离散攻击,以及(ii)与现有工作不同的随机采样攻击不是基于昂贵的搜索过程。令人惊讶的是,我们发现随机抽样导致鲁棒性的令人印象深刻,优于普通使用的离线增强,同时导致训练时间〜10x的加速。此外,在线增强基于搜索的攻击证明了更高的培训成本,显着提高了三个数据集的鲁棒性。最后,我们表明我们的新攻击与先前的方法相比,我们的新攻击显着提高了鲁棒性。
translated by 谷歌翻译
Pre-trained programming language (PL) models (such as CodeT5, CodeBERT, GraphCodeBERT, etc.,) have the potential to automate software engineering tasks involving code understanding and code generation. However, these models operate in the natural channel of code, i.e., they are primarily concerned with the human understanding of the code. They are not robust to changes in the input and thus, are potentially susceptible to adversarial attacks in the natural channel. We propose, CodeAttack, a simple yet effective black-box attack model that uses code structure to generate effective, efficient, and imperceptible adversarial code samples and demonstrates the vulnerabilities of the state-of-the-art PL models to code-specific adversarial attacks. We evaluate the transferability of CodeAttack on several code-code (translation and repair) and code-NL (summarization) tasks across different programming languages. CodeAttack outperforms state-of-the-art adversarial NLP attack models to achieve the best overall drop in performance while being more efficient, imperceptible, consistent, and fluent. The code can be found at https://github.com/reddy-lab-code-research/CodeAttack.
translated by 谷歌翻译
后门攻击对NLP模型构成了新的威胁。在后门攻击中构建中毒数据的标准策略是将触发器(例如,稀有字)插入所选句子,并将原始标签更改为目标标签。该策略具有从触发器和标签视角轻松检测到的严重缺陷:注入的触发器,通常是一种罕见的单词,导致异常的自然语言表达,因此可以通过防御模型容易地检测到异常的自然语言表达;改变的目标标签会导致误报标记的示例,因此可以通过手动检查容易地检测到。要处理此问题,请在本文中,我们提出了一种新的策略来执行不需要外部触发的文本后门攻击,并且中毒样品被正确标记。拟议策略的核心思想是构建清洁标记的例子,其标签是正确的,但可以导致测试标签在与培训集合融合时的变化。为了产生中毒清洁标记的例子,我们提出了一种基于遗传算法的句子生成模型,以满足文本数据的不可微差特性。广泛的实验表明,拟议的攻击策略不仅有效,而且更重要的是,由于其令人触发和清洁的性质,难以防御。我们的工作标志着在NLP中开发令人触发的攻击策略的第一步。
translated by 谷歌翻译
在过去几年中,已经提出了各种文字攻击方法来揭示自然语言处理中使用的深度神经网络的脆弱性。通常,这些方法涉及一个重要的优化步骤,以确定原始输入中的每个单词使用的替代。然而,从对问题理解和解决问题的角度来看,对这一步骤的目前的研究仍然是有限的。在本文中,我们通过揭示问题的理论属性并提出有效的本地搜索算法(LS)来解决这些问题来解决这些问题。我们建立了一个关于解决问题的第一个可提供的近似保证。涉及5个NLP任务,8个数据集和26个NLP模型的扩展实验表明,LS可能大大降低了Qualies数量,以实现高攻击成功率。进一步的实验表明,LS制造的对抗例通常具有更高的质量,表现出更好的可转移性,并且可以通过对抗培训为受害者模型带来更高的鲁棒性改善。
translated by 谷歌翻译
大规模的预训练语言模型在广泛的自然语言理解(NLU)任务中取得了巨大的成功,甚至超过人类性能。然而,最近的研究表明,这些模型的稳健性可能受到精心制作的文本对抗例子的挑战。虽然已经提出了几个单独的数据集来评估模型稳健性,但仍缺少原则和全面的基准。在本文中,我们呈现对抗性胶水(AdvGlue),这是一个新的多任务基准,以定量和彻底探索和评估各种对抗攻击下现代大规模语言模型的脆弱性。特别是,我们系统地应用14种文本对抗的攻击方法来构建一个粘合的援助,这是由人类进一步验证的可靠注释。我们的调查结果总结如下。 (i)大多数现有的对抗性攻击算法容易发生无效或暧昧的对手示例,其中大约90%的含量改变原始语义含义或误导性的人的注册人。因此,我们执行仔细的过滤过程来策划高质量的基准。 (ii)我们测试的所有语言模型和强大的培训方法在AdvGlue上表现不佳,差价远远落后于良性准确性。我们希望我们的工作能够激励开发新的对抗攻击,这些攻击更加隐身,更加统一,以及针对复杂的对抗性攻击的新强大语言模型。 Advglue在https://adversarialglue.github.io提供。
translated by 谷歌翻译
Machine learning algorithms are often vulnerable to adversarial examples that have imperceptible alterations from the original counterparts but can fool the state-of-the-art models. It is helpful to evaluate or even improve the robustness of these models by exposing the maliciously crafted adversarial examples. In this paper, we present TEXTFOOLER, a simple but strong baseline to generate adversarial text. By applying it to two fundamental natural language tasks, text classification and textual entailment, we successfully attacked three target models, including the powerful pre-trained BERT, and the widely used convolutional and recurrent neural networks. We demonstrate three advantages of this framework:(1) effective-it outperforms previous attacks by success rate and perturbation rate, (2) utility-preserving-it preserves semantic content, grammaticality, and correct types classified by humans, and (3) efficient-it generates adversarial text with computational complexity linear to the text length. 1
translated by 谷歌翻译
Recent studies on adversarial images have shown that they tend to leave the underlying low-dimensional data manifold, making them significantly more challenging for current models to make correct predictions. This so-called off-manifold conjecture has inspired a novel line of defenses against adversarial attacks on images. In this study, we find a similar phenomenon occurs in the contextualized embedding space induced by pretrained language models, in which adversarial texts tend to have their embeddings diverge from the manifold of natural ones. Based on this finding, we propose Textual Manifold-based Defense (TMD), a defense mechanism that projects text embeddings onto an approximated embedding manifold before classification. It reduces the complexity of potential adversarial examples, which ultimately enhances the robustness of the protected model. Through extensive experiments, our method consistently and significantly outperforms previous defenses under various attack settings without trading off clean accuracy. To the best of our knowledge, this is the first NLP defense that leverages the manifold structure against adversarial attacks. Our code is available at \url{https://github.com/dangne/tmd}.
translated by 谷歌翻译
我们专注于在黑框设置中对模型的对抗性攻击的问题,攻击者旨在制作对受害者模型的查询访问有限的对抗性示例。现有的黑框攻击主要基于贪婪的算法,使用预先计算的关键位置来扰动,从而严重限制了搜索空间,并可能导致次优的解决方案。为此,我们提出了使用贝叶斯优化的查询有效的黑盒攻击,该贝叶斯优化使用自动相关性确定(ARD)分类内核动态计算重要位置。我们引入了块分解和历史次采样技术,以提高输入序列长时间时贝叶斯优化的可伸缩性。此外,我们开发了一种优化后算法,该算法找到了具有较小扰动大小的对抗示例。关于自然语言和蛋白质分类任务的实验表明,与先前的最新方法相比,我们的方法始终达到更高的攻击成功率,查询计数和修改率的显着降低。
translated by 谷歌翻译
最近的自然语言处理(NLP)技术在基准数据集中实现了高性能,主要原因是由于深度学习性能的显着改善。研究界的进步导致了最先进的NLP任务的生产系统的巨大增强,例如虚拟助理,语音识别和情感分析。然而,随着对抗性攻击测试时,这种NLP系统仍然仍然失败。初始缺乏稳健性暴露于当前模型的语言理解能力中的令人不安的差距,当NLP系统部署在现实生活中时,会产生问题。在本文中,我们通过以各种维度的系统方式概述文献来展示了NLP稳健性研究的结构化概述。然后,我们深入了解稳健性的各种维度,跨技术,指标,嵌入和基准。最后,我们认为,鲁棒性应该是多维的,提供对当前研究的见解,确定文学中的差距,以建议值得追求这些差距的方向。
translated by 谷歌翻译
我们将自然语言处理模型的脆弱性归因于以下事实:类似的输入转换为嵌入空间中不同的表示形式,导致输出不一致,我们提出了一种新颖的强大训练方法,称为快速三胞胎度量度量学习(FTML)。具体而言,我们认为原始样本应具有相似的表示及其对手对应物,并将其代表与其他样品区分开,以提高鲁棒性。为此,我们将三胞胎度量学习采用标准培训中,以将单词更接近其正样本(即同义词),并在嵌入空间中推出其负面样本(即非综合样品)。广泛的实验表明,FTML可以显着促进模型的鲁棒性,以针对各种高级对抗攻击,同时保持对原始样品的竞争性分类精度。此外,我们的方法是有效的,因为它只需要调整嵌入方式,并且在标准培训上引入了很少的开销。我们的工作显示出通过稳健的单词嵌入来改善文本鲁棒性的巨大潜力。
translated by 谷歌翻译
最近的作品表明了解释性和鲁棒性是值得信赖和可靠的文本分类的两个关键成分。然而,以前的作品通常是解决了两个方面的一个:i)如何提取准确的理由,以便在有利于预测的同时解释; ii)如何使预测模型对不同类型的对抗性攻击稳健。直观地,一种产生有用的解释的模型应该对对抗性攻击更加强大,因为我们无法信任输出解释的模型,而是在小扰动下改变其预测。为此,我们提出了一个名为-BMC的联合分类和理由提取模型。它包括两个关键机制:混合的对手训练(AT)旨在在离散和嵌入空间中使用各种扰动,以改善模型的鲁棒性,边界匹配约束(BMC)有助于利用边界信息的引导来定位理由。基准数据集的性能表明,所提出的AT-BMC优于分类和基本原子的基础,由大边距提取。鲁棒性分析表明,建议的AT-BMC将攻击成功率降低了高达69%。经验结果表明,强大的模型与更好的解释之间存在连接。
translated by 谷歌翻译
基于预先训练的语言模型(PRLMS)在源代码理解任务中取得的巨大成功,当前的文献研究要么进一步改善PRLM的性能(概括)或对对抗性攻击的鲁棒性。但是,他们必须在这两个方面之间的权衡方面妥协,而且它们都没有考虑以有效和实用的方式改善双方。为了填补这一空白,我们建议使用语义保护对抗代码嵌入(空间),以找到最坏的传播语义保留攻击,同时迫使模型在这些最坏情况下预测正确的标签。实验和分析表明,在提高PRLMS代码的性能的同时,空间可以保持强大的防御性攻击。
translated by 谷歌翻译
最近的研究表明,预训练的语言模型(LMS)容易受到文本对抗性攻击的影响。但是,现有的攻击方法要么遭受低攻击成功率,要么无法在指数级的扰动空间中有效搜索。我们提出了一个有效有效的框架Semattack,以通过构建不同的语义扰动函数来生成自然的对抗文本。特别是,Semattack优化了对通用语义空间约束的生成的扰动,包括错字空间,知识空间(例如WordNet),上下文化的语义空间(例如,BERT群集的嵌入空间)或这些空间的组合。因此,生成的对抗文本在语义上更接近原始输入。广泛的实验表明,最新的(SOTA)大规模LMS(例如Deberta-V2)和国防策略(例如Freelb)仍然容易受到Semattack的影响。我们进一步证明,Semattack是一般的,并且能够为具有较高攻击成功率的不同语言(例如英语和中文)生成自然的对抗文本。人类评估还证实,我们产生的对抗文本是自然的,几乎不会影响人类的表现。我们的代码可在https://github.com/ai-secure/semattack上公开获取。
translated by 谷歌翻译
过去几年的对抗性文本攻击领域已经大大增长,其中常见的目标是加工可以成功欺骗目标模型的对抗性示例。然而,攻击的难以察觉,也是基本目标,通常被以前的研究遗漏。在这项工作中,我们倡导同时考虑两个目标,并提出一种新的多优化方法(被称为水合物转速),具有可提供的绩效保证,以实现高稳定性的成功攻击。我们通过基于分数和决策的设置,展示了HydroText通过广泛实验的效果,涉及五个基于基准数据集的现代NLP模型。与现有的最先进的攻击相比,Hydratext同时实现了更高的成功率,更低的修改率和与原始文本更高的语义相似性。人类评估研究表明,由水分精制成的对抗例保持良好的有效性和自然。最后,这些例子也表现出良好的可转移性,并且可以通过对抗性培训为目标模型带来显着的稳健性。
translated by 谷歌翻译
Adversarial attacks in NLP challenge the way we look at language models. The goal of this kind of adversarial attack is to modify the input text to fool a classifier while maintaining the original meaning of the text. Although most existing adversarial attacks claim to fulfill the constraint of semantics preservation, careful scrutiny shows otherwise. We show that the problem lies in the text encoders used to determine the similarity of adversarial examples, specifically in the way they are trained. Unsupervised training methods make these encoders more susceptible to problems with antonym recognition. To overcome this, we introduce a simple, fully supervised sentence embedding technique called Semantics-Preserving-Encoder (SPE). The results show that our solution minimizes the variation in the meaning of the adversarial examples generated. It also significantly improves the overall quality of adversarial examples, as confirmed by human evaluators. Furthermore, it can be used as a component in any existing attack to speed up its execution while maintaining similar attack success.
translated by 谷歌翻译
This paper investigates recently proposed approaches for defending against adversarial examples and evaluating adversarial robustness. We motivate adversarial risk as an objective for achieving models robust to worst-case inputs. We then frame commonly used attacks and evaluation metrics as defining a tractable surrogate objective to the true adversarial risk. This suggests that models may optimize this surrogate rather than the true adversarial risk. We formalize this notion as obscurity to an adversary, and develop tools and heuristics for identifying obscured models and designing transparent models. We demonstrate that this is a significant problem in practice by repurposing gradient-free optimization techniques into adversarial attacks, which we use to decrease the accuracy of several recently proposed defenses to near zero. Our hope is that our formulations and results will help researchers to develop more powerful defenses.
translated by 谷歌翻译