Rethinking Targeted Adversarial Attacks for Neural Machine Translation

Junjie Wu, Lemao Liu, Wei Bi, Dit-Yan Yeung

TL;DR

Existing targeted adversarial attacks on Neural Machine Translation (NMT) often cheat by modifying the very words they are trying to "attack," leading to misleadingly high success rates. This paper introduces a more rigorous attack setting that forbids modifying the target word's source-side counterpart and proposes TWGA, a new gradient-based attack that effectively breaks NMT systems while maintaining sentence fluency.

What Problem Does This Paper Address?

Adversarial attacks involve making tiny, imperceptible changes to an input to trick an AI into making a mistake. In NMT, a targeted attack tries to force the model to either include a specific wrong word (Setting 1) or omit a specific correct word (Setting 2) in the translation.

The authors identify a major flaw in how these attacks are currently evaluated. Most existing methods operate under a "label-preserving assumption"—the idea that the meaning of the sentence shouldn't change. However, many current attacks "succeed" simply by deleting or changing the source word they want to disappear. For example, if you want the word "working" to disappear from the translation, and your attack just deletes "working" from the English source sentence, the NMT model isn't "failing"—it's correctly translating a modified sentence.

The paper argues that these are invalid adversarial examples. To be a true attack, the target word must remain in the source, and the model must be tricked into omitting it by changing other words in the sentence.

Methods

The authors propose a new, stricter attack setting and a corresponding method called Targeted Word Gradient adversarial Attack (TWGA).

  1. The New Setting:
    • Constraint: Only non-targeted tokens in the source sentence can be modified.
  2. Dictionary Check: To ensure a word truly "disappears," the attack must ensure that none of the possible translations of that word (found via a bilingual dictionary) appear in the output.
  3. Fluency: The resulting adversarial sentence must remain fluent and meaningful.
  4. The TWGA Algorithm:
    • Differentiable Search: Since selecting discrete words is hard for gradient-based optimizers, TWGA uses the Gumbel-softmax trick to create a differentiable approximation of word selection.
  5. Margin Loss: It uses a specific loss function ($L_{mar}$) that pushes the logit scores of the target word's translations below the scores of other potential words.
  6. Fluency Regularization: To keep the sentences readable, they incorporate a loss from pre-trained GPT-2 models (running both left-to-right and right-to-left) to ensure the adversarial input remains high-probability (fluent) English.

Datasets

  • WMT20 En-Zh: The standard benchmark for English-to-Chinese news translation.
  • Para: A large-scale evaluation set (30k sentences) constructed by the authors using monolingual data from ParaCrawl. This allows for a more robust, unbiased evaluation of attack scalability.

Key Insights and Ideas

  • The "Invalidity" Trap: The most striking insight is that a huge portion of "successful" NMT attacks in previous literature are actually invalid because they break the semantic link between source and target.
  • Bilingual Dictionaries are Essential: A single word (like "working") can be translated into Chinese in many ways (工作, 运行, 作用). An attack is only successful if all valid translations are suppressed, not just the one found in a single reference sentence.
  • White-box Efficiency: By using gradients to guide the search (white-box), TWGA finds successful perturbations much faster and more reliably than heuristic-based methods like word substitution.

Key Results

The authors tested TWGA against several baselines (like Seq2sick and WTextFooler) on both LSTM and Transformer-based NMT models.

  • Higher Success Rates: Under the new, stricter rules, TWGA achieved a success rate of 82.82% on LSTM and 72.91% on Transformers, significantly outperforming baselines which struggled to reach 50-60%.
  • Better Fluency: Human evaluations showed that 94% of TWGA-generated examples were "mediocre" to "meaningful," with a higher percentage of "meaningful" results (34%) compared to other attack methods.
  • Scalability: The method remained effective on the large-scale 30k-sentence "Para" dataset, proving it wasn't just over-fitting to a small test set.

Limitations and Future Work

  • White-box Requirement: TWGA is a white-box attack, meaning it requires access to the NMT model's internal gradients. It is unclear how well these specific perturbations would transfer to "black-box" systems (like Google Translate) where gradients are unavailable.
  • Dictionary Dependency: The effectiveness of the "Setting" depends on the quality and coverage of the bilingual dictionary used to identify target word translations.
  • Language Scope: The study focused on English-to-Chinese; future work could explore if these findings hold for more morphologically rich languages or different language pairs.

Summary updated

Abstract

Targeted adversarial attacks are widely used to evaluate the robustness of neural machine translation systems. Unfortunately, this paper first identifies a critical issue in the existing settings of NMT targeted adversarial attacks, where their attacking results are largely overestimated. To this end, this paper presents a new setting for NMT targeted adversarial attacks that could lead to reliable attacking results. Under the new setting, it then proposes a Targeted Word Gradient adversarial Attack (TWGA) method to craft adversarial examples. Experimental results demonstrate that our proposed setting could provide faithful attacking results for targeted adversarial attacks on NMT systems, and the proposed TWGA method can effectively attack such victim NMT systems. In-depth analyses on a large-scale dataset further illustrate some valuable findings. 1 Our code and data are available at https://github.com/wujunjie1998/TWGA.
BibTeX
@inproceedings{wu2024rethinking,
  author = {Junjie Wu and Lemao Liu and Wei Bi and Dit-Yan Yeung},
  title = {{Rethinking Targeted Adversarial Attacks for Neural Machine Translation}},
  booktitle = {IEEE International Conference on Acoustics, Speech and Signal Processing},
  year = {2024},
  doi = {10.1109/icassp48485.2024.10447368},
}

Loading related content...

Figure