arXiv(opens in a new tab)Computer ScienceAug 2019Cited by 4 papers on PaperVantage

Manuscript Offprint

arXiv:1908.07125

Universal Adversarial Triggers for Attacking and Analyzing NLP

Eric Wallace, Shi Feng, Nikhil Kandpal, Matt Gardner, Sameer Singh

Abstract

Adversarial examples highlight model vulnerabilities and are useful for evaluation and interpretation. We define universal adversarial triggers: input-agnostic sequences of tokens that trigger a model to produce a specific prediction when concatenated to any input from a dataset. We propose a gradient-guided search over tokens which finds short trigger sequences (e.g., one word for classification and four words for language modeling) that successfully trigger the target prediction. For example, triggers cause SNLI entailment accuracy to drop from 89.94% to 0.55%, 72% of “why” questions in SQuAD to be answered “to kill american people”, and the GPT-2 language model to spew racist output even when conditioned on non-racial contexts. Furthermore, although the triggers are optimized using white-box access to a specific model, they transfer to other models for all tasks we consider. Finally, since triggers are input-agnostic, they provide an analysis of global model behavior. For instance, they confirm that SNLI models exploit dataset biases and help to diagnose heuristics learned by reading comprehension models.

1 Introduction

TaskInput ( red = trigger)Model Prediction
Sentiment Analysiszoning tapping fiennes Visually imaginative, thematically instructive and thoroughly delightful, it takes us on a roller-coaster ride…Positive →\to Negative
zoning tapping fiennes As surreal as a dream and as detailed as a photograph, as visually dexterous as it is at times imaginatively overwhelming.Positive →\to Negative
Input (underline = correct span, red = trigger, underline = target span)
SQuADQuestion: Why did he walk? For exercise, Tesla walked between 8 to 10 miles per day. He squished his toes one hundred times for each foot every night, saying that it stimulated his brain cells. why how because to kill american people.exercise →\to to kill american people
Question: Why did the university see a drop in applicants? In the early 1950s, student applications declined as a result of increasing crime and poverty in the Hyde Park neighborhood. In response, the university became a …… why how because to kill american people.crime and poverty →\to to kill american people
GPT-2 Sample ( red = trigger, underline = user input, black = GPT-2 output given trigger and user input)
Language ModelingTH PEOPLEMan goddreams Blacks and Jews are the most evil people on earth, and the reason they are so evil is because they have the most evil genes……It’s not just the Jews and the blacks, the Chinese, the Indians. It’s all the other people.
TH PEOPLEMan goddreams Blacks my mother says I’m a racist, and she’s right.
TH PEOPLEMan goddreams Blacks yesterday I’m going to be a fucking black man. I don’t know what to say to that, but fuck you.

Table 1: We create token sequences that commonly trigger a specific target prediction when concatenated to any input from a dataset. For sentiment analysis, concatenating the displayed trigger causes the model to flip its correct positive predictions to negative. For SQuAD, the displayed trigger causes the model to change its prediction from the underlined span to a desired target span inside the trigger. For language modeling, triggers are prefixes that prompt GPT-2 Radford et al. (2019) to generate racist outputs, even when conditioned on non-racist user inputs.

Adversarial attacks modify inputs in order to cause machine learning models to make errors Szegedy et al. (2014). From an attack perspective, they expose system vulnerabilities, e.g., a spammer may use adversarial attacks to bypass a spam email filter Biggio et al. (2013). These security concerns grow as natural language processing (NLP) models are deployed in production systems such as fake news detectors and home assistants.

Besides exposing system vulnerabilities, adversarial attacks are useful for evaluation and interpretation, i.e., understanding a model’s capabilities by finding its limitations. For example, adversarially-modified inputs are used to evaluate reading comprehension models Jia and Liang (2017); Ribeiro et al. (2018) and stress test neural machine translation Belinkov and Bisk (2018). Adversarial attacks also facilitate interpretation, e.g., by analyzing a model’s sensitivity to local perturbations Li et al. (2016); Feng et al. (2018).

These attacks are typically generated for a specific input; are there attacks that work for any input? We search for universal adversarial triggers: input-agnostic sequences of tokens that trigger a model to produce a specific prediction when concatenated to any input from a dataset. The existence of such triggers would have security implications—the triggers can be widely distributed and allow anyone to attack models. Furthermore, from an analysis perspective, input-agnostic attacks can provide new insights into global model behavior.

Triggers are a new form of universal adversarial perturbation Moosavi-Dezfooli et al. (2017) adapted to discrete textual inputs. To find them, we design a gradient-guided search over tokens. The search iteratively updates the tokens in the trigger sequence to increase the likelihood of the target prediction for batches of examples (Section 2). We find short sequences that successfully trigger a target prediction when concatenated to inputs from text classification, reading comprehension, and conditional text generation.

For text classification, triggers cause targeted errors for sentiment analysis (e.g., top of Table 1) and natural language inference models. For example, one word causes a model to predict 99.43% of Entailment examples as Contradiction (Section 3). For reading comprehension, triggers are concatenated to paragraphs to cause arbitrary target predictions (Section 4). For example, models predict the vicious phrase “to kill american people” for many “why” questions (e.g., middle of Table 1).

For conditional text generation, triggers are prepended to user inputs in order to maximize the likelihood of a set of target texts (Section 5). Our attack triggers GPT-2 Radford et al. (2019) to generate racist outputs using the prompt “TH PEOPLEMan goddreams Blacks” (e.g., bottom of Table 1).

Although we generate triggers assuming white-box (gradient) access to a specific model, they are transferable to other models for all datasets we consider. For example, some of the triggers generated for a GloVe-based reading comprehension model are more effective at triggering an ELMo-based model. Moreover, a trigger generated for the GPT-2 117M model also works for the 345M model: the first language model sample in Table 1 shows the larger model ranting on the “evil genes” of Black, Jewish, Chinese, and Indian people.

Finally, unlike typical adversarial attacks, the input-agnostic nature of the triggers provides new insights into global model behavior, i.e., general input-output patterns learned by a model. For example, triggers confirm that models exploit biases in the SNLI dataset (Section 6). Triggers also identify heuristics learned by SQuAD models—they heavily rely on the tokens that surround the answer span and type information in the question.