Seq2Sick: Evaluating the robustness of sequence-to-sequence models with adversarial examplesSeq2Sick: Evaluating the Robustness of Sequence-to-Sequence Models with Adversarial Examples
The authors propose the Seq2Sick attack framework, which on text summarization and machine translation can make a seq2seq model output specified content by changing fewer than 3 words, with a success rate of up to 100%.
The attacker's target is a seq2seq model (text summarization, machine translation), and a small number of words in the input text can be modified; the attack is white-box (gradient based, requiring backpropagation to compute gradients); it is divided into two types: non-overlapping attack (the output completely does not overlap with the original output) and targeted keywords attack (the output must contain all specified keywords); success is judged by whether the output satisfies the condition.
- Existing adversarial example research focuses on image classification, and the robustness of seq2seq models (safety-sensitive applications such as machine translation and text summarization) with discrete input and nearly infinite output lacks evaluation.
- Propose Seq2Sick: use projected gradient descent to handle the discrete input space, group lasso to ensure sparse perturbations, gradient regularization to pull the solution back near the word embeddings, and design hinge-style loss functions for the two attacks, non-overlapping and targeted keywords.
- On text summarization and machine translation, changing an average of 2–3 words can make the output completely non-overlapping (success rate 84.2%–89.4%) or contain specified keywords (99.6%–100% with 1 keyword); the authors state that seq2seq models are more robust than CNN classifiers.
- The authors note that seq2seq outputs are difficult to fully control and that discrete inputs make perturbations more noticeable to humans; the experiments cover only LSTM and one subword transformer model, no human evaluation was done, and semantic preservation was verified only with an external sentiment API.
- Evaluated models
- Text summarization model (word-level LSTM encoder with word-based attention decoder, on OpenNMT-py)English-German machine translation model (word-level LSTM encoder with word-based attention decoder, on OpenNMT-py)Subword transformer model
- Benchmarks
- GigawordDUC2003DUC2004WMT'16 Multimodal Translation (Multi30K)
- Metrics
- Success rateBLEU# changed wordsPerplexity
In the paper, the researchers propose the Seq2Sick method, which constructs adversarial examples for sequence-to-sequence models whose input is discrete text and whose output space is nearly infinite, using projected gradient descent combined with group lasso and gradient regularization to address the challenges posed by discrete input. They also design new loss functions to achieve non-overlapping attacks and target keyword attacks. On machine translation and text summarization tasks, changing fewer than 3 words can make the model produce a specified output with a high success rate; the authors also believe that, compared with thoroughly evaluated CNN classifiers, seq2seq models are themselves more robust to adversarial attacks.
Paper analysis
What problem does this paper attempt to solve?
How to generate adversarial examples for seq2seq models, whose input is discrete and output is nearly infinite, and evaluate their robustness.
Core question: how to generate adversarial examples for sequence-to-sequence (seq2seq) models in order to evaluate the robustness of such models.
- Problem setting: the authors point out that seq2seq models are widely used in safety-sensitive applications such as machine translation, text summarization, and speech recognition, but existing adversarial example research almost all targets image classification, because image inputs are continuous and outputs have a limited number of classes.
- Two difficulties: text input is discrete, and word-level modifications easily change semantics, so sparse word-level changes are required; the output is a sequence with nearly infinite possibilities, so the search space for targeted attacks is enormous.
- Research questions: the authors explicitly raise two questions—can the seq2seq output be drastically changed by only slightly modifying the input? Are seq2seq models more robust than CNN image classifiers?
- Paper's approach: propose the optimization-based attack framework Seq2Sick, which uses projected gradient plus group lasso and gradient regularization to handle discrete input, and designs two types of loss functions, non-overlapping and targeted keywords.
- Threat model:
- Attacker's goal: make the seq2seq model output completely non-overlapping with the original output, or contain all specified keywords.
- Knowledge and capability: gradient based (white-box, requiring backpropagation through the model to compute gradients), can modify a small number of words in the input sequence.
- Victim systems: seq2seq models for text summarization and English-German machine translation.
- Success criterion: non-overlapping requires the output to differ from the original output at every position; keyword attack requires the output to contain all target keywords.
What related research exists?
Existing work mostly attacks text classification or reading comprehension; the authors of this paper state that theirs is the earliest work to evaluate seq2seq robustness.
Methods that attack RNNs/text classification
- Papernot et al. (2016)—used FGSM to attack RNN/LSTM-based classification problems.
- Li, Monroe, and Jurafsky (2016)—used reinforcement learning to locate important words that can be deleted in sentiment classification.
- Samanta and Mehta (2017), Liang et al. (2017)—generated adversarial sequences by inserting typos and substituting synonyms.
- Gao et al. (2018)—black-box attack on sentiment classification, using a scoring function to find words to modify; Alzantot et al. (2018) used a genetic algorithm to attack sentiment analysis; Yang et al. (2018) used a greedy method and the Gumbel trick for acceleration. The paper points out that these methods study simple text classification, whereas this paper targets the harder seq2seq sequence output.
Other NLP attacks
- Jia and Liang (2017)—attacked reading comprehension systems by adding misleading sentences; the paper states that its focus differs from this paper.
- Zhao, Dua, and Singh (2017)—used a GAN to generate natural adversarial examples; the paper points out that it can only perform untargeted attacks and is computationally expensive.
- Gong et al. (2018)—solved in continuous space and then mapped back to the nearest word embedding; the paper reports that when this idea was applied to targeted keywords attacks, all 100 attacked sequences on Gigaword failed.
Dimensions of comparison with this paper's method
- Table 1 of the paper compares the above methods with Seq2Sick along four dimensions: whether gradient based, whether word-level RNN, whether sequence output, and targeted attack type; the authors state that existing methods are mostly based on greedy search, where the search space grows rapidly with input length, whereas Seq2Sick uses group lasso plus projected gradient to simultaneously search all replacement positions.
Baselines and benchmarks
- The paper does not set an attack baseline method; experiments are conducted on Gigaword, DUC2003, DUC2004 (text summarization) and WMT'16 Multimodal Translation (machine translation), and the comparison targets are mainly the seq2seq models trained by the authors themselves and a subword transformer.
The authors state that this paper is the earliest work to evaluate the robustness of seq2seq models, and mention that subsequent work such as Michel et al. (2019) builds on Seq2Sick.
How does the paper address this problem?
Seq2Sick formulates the attack as a constrained optimization problem and solves it using projected gradient, group lasso, and gradient regularization.
Overall idea: formalize the attack as the optimization problem minδ L(X+δ) + λ · R(δ), where L penalizes attack failure and R measures perturbation magnitude; under this framework, loss functions are designed for the two types of attacks, and three techniques are used to handle the discrete input space.
Loss functions for the two types of attacks
- Non-overlapping attack: requires the adversarial output to differ from the original output at every position, i.e., Lnon-overlapping = ∑t=1M max{−ϵ, zt(st) − maxy ≠ st zt(y)}, where ε is the confidence margin; the authors state that a larger ε gives a higher success rate but more iterations. The authors point out that this task is harder than untargeted attacks, which are trivial for this paper's framework and can reach a 100% success rate, so they are not studied.
- Targeted keywords attack: requires the output to contain all specified keywords, without specifying positions; for each keyword, take the minimum of the hinge loss over all positions and then sum. The authors point out that multiple keywords can cause "keyword collision" (multiple keywords competing for the same position), and for this they define a mask function: when a position is already occupied by a keyword as top-1, it is masked out.
Handling the discrete input space
- Projected gradient descent: add the constraint xi + δi ∈ W (the word embedding set), and project the current solution back to W at each iteration, ensuring mapping to a concrete input word. The authors report that solving directly in continuous space and then finding the nearest neighbor (the idea of Gong et al. 2018) failed on all 100 cases on Gigaword, because the solution is infeasible and the nearest neighbor may be far away.
- Group lasso regularization: treat the d-dimensional perturbation of each word as a group, and use R(δ) = Σ‖δt‖₂ to encourage only a few words to be changed; the authors point out that ℓ2 regularization perturbs almost all words and is not suitable for this task.
- Gradient regularization: add an extra term penalizing the distance from xi + δi to the nearest word embedding, pulling the solution back to dense embedding regions; its gradient depends only on the single nearest wj and can be computed efficiently.
Algorithm flow and parameters
- Algorithm 1: iterate T rounds; each round backpropagates to compute gradients, updates group lasso with a proximal operator (threshold ηλ1), takes a gradient step, and projects back to W.
- Computational cost: each iteration requires only one backpropagation; the bottleneck is the nearest-neighbor search in the projection step, which can be accelerated with ANN; the model does not depend on pretrained word embeddings.
- Hyperparameters: λ = 1 for non-overlapping experiments; λ1 = λ2 = 1 for targeted keywords experiments; beam search size is 5.
Victim models and training
- Both applications are based on OpenNMT-py: a word-level LSTM encoder plus an attention decoder; the summarization model is a 2-layer 500-hidden-unit LSTM, trained on 380k Gigaword training pairs, in two variants: using 300-dimensional GloVe pretrained embeddings and training from scratch; the translation model is trained on 453k German-English sentence pairs from Europal, common crawl, and news-commentary, with hyperparameters using OpenNMT's recommended values.
What experiments did the paper conduct?
Changing 2–3 words in summaries and translations achieves an 84%–100% success rate, and semantic preservation and differences in transformer robustness were verified.
Experimental setup
- Models tested: LSTM encoder + attention decoder seq2seq models on OpenNMT-py (one each for summarization and English-German translation); additionally, one subword transformer model is tested.
- Datasets: for text summarization, Gigaword (1,000), DUC2003 (624), DUC2004 (500); for machine translation, 500 from WMT'16 Multimodal Translation (Table 2).
- Metrics: attack success rate, BLEU (exponential average of BLEU 1–4, measuring similarity between adversarial input and original source), average number of changed words; additionally, perplexity is used to measure syntax, and the DeepAI sentiment analysis API is used to measure semantic preservation.
- Success criterion: non-overlapping requires the output to share no words with the original output at every position; keyword attack requires the output to contain all keywords, with keywords randomly selected from the output vocabulary after removing stop words.
- Hyperparameters: λ = 1 for non-overlapping, λ1 = λ2 = 1 for keyword attack; the paper does not report the number of iterations T or the number of repetitions.
Main results
Text summarization (according to Table 3, Table 4):
Swipe horizontally to read the table
Dataset Attack Success rate BLEU Number of changed words Gigaword non-overlap 86.0% 0.828 2.17 DUC2003 non-overlap 85.2% 0.774 2.90 DUC2004 non-overlap 84.2% 0.816 2.50 Gigaword 1-keyword 99.8% 0.801 2.04 Gigaword 3-keyword 43.0% 0.413 8.86 DUC2003 1-keyword 99.6% 0.782 2.25 DUC2004 1-keyword 99.6% 0.773 2.21 Machine translation (according to Table 5): non-overlap 89.4% (BLEU 0.349, 3.5 words changed); 1-keyword 100.0% (0.705, 1.8 words); 2-keyword 91.0% (0.303, 4.0 words); 3-keyword 69.6% (0.205, 5.3 words).
- The authors state that changing an average of only 2–3 words can make the output of more than 80% of sentences completely different.
- The authors state that the task is harder when |K| = 3, but the algorithm can still find many adversarial examples (on DUC2003, 2-keyword is 87.6% and 3-keyword is 38.3%; on DUC2004, 87.8% and 37.4% respectively).
Syntactic and semantic preservation
- Syntax: on DUC2003/DUC2004, the perplexity of adversarial examples rises from 102.02/121.09 for the original source to 114.02/149.15 for non-overlap and 352.12/384.80 for 2-keyword (Table 6); the authors state that the examples preserve the original syntactic structure.
- Semantics: using the DeepAI sentiment API on 500 sentences from DUC2003, only 2.2% of adversarial examples have a sentiment classification different from the original source; the authors state that almost all adversarial examples preserve the semantic classification.
Attacks on the transformer and discussion of robustness
- When attacking the subword transformer, the 1-keyword attack success rate is 17% lower and BLEU is 0.13 lower; the authors state that the transformer model has stronger adversarial robustness and consider this related to the attention layer.
- The authors observe that the changed words co-occur with the target keywords in the training data, and consider that the model has learned the relationship between the changed words and the keywords but fails to decide which positions to attend to.
- The authors consider seq2seq more robust than CNN classifiers: it is difficult to turn the entire output into a specified sentence (some sentences may even be impossible to generate), and the discrete input makes perturbations easier for humans to notice.
Other ablations and analyses
- Solving in continuous space and then mapping to the nearest neighbor (the idea of Gong et al. 2018): all 100 targeted keywords attacks on Gigaword failed.
- The paper states that importance validation experiments were conducted separately for the three techniques of projected gradient, group lasso, and gradient regularization, but the main text does not give specific numbers for each.
- Untargeted attacks: the authors state that they are trivial for this paper's framework and can easily reach a 100% success rate, so they are not included in the experiments.
What are some points that can be further explored?
The authors note that seq2seq outputs are difficult to fully control and that perturbations are more noticeable, and suggest switching to self-attention models.
Limitations and future directions noted by the authors
- The authors acknowledge that, compared with targeted attacks on CNNs that succeed almost 100% of the time and are imperceptible, turning the entire seq2seq output into a specific sentence is harder, and some sentences may even be impossible for a seq2seq model to generate (Analysis and Discussions).
- The authors point out that because the input space is discrete, even if only one or two words are changed, it is relatively easy for humans to notice the difference between the adversarial sequence and the original source (Analysis and Discussions).
- The authors observe that the model fails to decide which positions to attend to, consider this related to the attention layer, and propose that self-attention structures such as transformers could instead be used to extract attention between any two words (Analysis and Discussions).
- The authors point out that words close in the word embedding space are not guaranteed to be semantically similar, so they additionally conduct experiments on syntactic and semantic validation (Analysis of Syntactic structure and Semantic Meaning Preservation).
Scope of experiments
- The models tested are LSTM seq2seq models based on OpenNMT-py (summarization, translation) and one subword transformer, two architecture types in total.
- The datasets are Gigaword, DUC2003, DUC2004, and WMT'16 Multimodal Translation, with 500–1,000 test samples (Table 2).
- Semantic preservation was evaluated using the DeepAI online sentiment API on 500 sentences from DUC2003; the paper did not conduct human evaluation.
- The paper does not report the number of attack iterations, running time, or number of repetitions.
- The attack tasks are limited to non-overlapping and targeted keywords; untargeted attacks were regarded by the authors as trivial and were not experimented on.
Summarize the main content of the paper
Seq2Sick uses optimization methods to attack seq2seq models; changing a small number of words can control the output, and the authors state that seq2seq is more robust than CNN.
An attack paper on the adversarial robustness of seq2seq models, proposing the optimization-based attack framework Seq2Sick to address the two difficulties of discrete inputs and near-infinite outputs.
- Problem: Existing adversarial example research focuses on image classification; the authors want to answer whether slightly modifying the input can greatly change the seq2seq output, and whether seq2seq is more robust than CNN classifiers.
- Method: Projected gradient descent constrains the solution back into the word embedding space, group lasso ensures only a few words are changed, and gradient regularization pulls the solution back into dense embedding regions; hinge-style losses are designed separately for non-overlapping and targeted keywords attacks, and a mask function resolves position conflicts among multiple keywords.
- Text summarization: The non-overlapping attack achieves success rates of 86.0%/85.2%/84.2% on Gigaword/DUC2003/DUC2004, changing 2.17–2.90 words on average (Table 3); the 1-keyword attack success rate is 99.6%–99.8%, dropping to 37.4%–43.0% for 3-keyword (Table 4).
- Machine translation: The 1-keyword success rate is 100.0%, changing 1.8 words, and 69.6% for 3-keyword (Table 5).
- Semantic preservation: Among the 500 sentences in DUC2003, only 2.2% of adversarial examples changed sentiment classification; when attacking the subword transformer, the 1-keyword success rate is 17% lower, and the authors state that the transformer is more robust.
- Authors' conclusion: Because of discrete inputs and a near-infinite output space, seq2seq models are inherently more robust than CNN image classifiers, and their adversarial example perturbations are larger and more noticeable to humans.