Invariance-based Adversarial Attack on Neural Machine Translation Systems

Akshay Chaturvedi, Abijith Kp, Utpal Garain

Abstract

Neural machine translation (NMT) systems have been shown to give undesirable translation when a small change is made in the source sentence. In this paper, we study the behaviour of NMT systems when multiple changes are made to the source sentence. In particular, we ask the following question: "Is it possible for an NMT system to predict the same translation even when multiple words in the source sentence have been replaced?". To this end, we propose a soft-attention based technique to make the aforementioned word replacements. The experiments are conducted on two language pairs: English-German (en-de) and English-French (en-fr) and two state-of-the-art NMT systems: BLSTM-based encoder-decoder with attention and Transformer. The proposed soft-attention based technique achieves a high success rate and outperforms existing methods like HotFlip by a significant margin for all the conducted experiments. The results demonstrate that state-of-the-art NMT systems are unable to capture the semantics of the source language. The proposed soft-attention based technique is an invariance-based adversarial attack on NMT systems. To better evaluate such attacks, we propose an alternate metric and argue its benefits in comparison with success rate.

Introduction

While Neural Machine Translation (NMT) has seen rapid advancement, these models often exhibit "undesirable invariance." In computer vision, adversarial attacks can trick a model into misclassifying an image with imperceptible pixel changes. In NMT, a similar vulnerability exists where models may produce the same output despite significant, often nonsensical, changes to the input. This suggests that models may be latching onto specific "anchor" words rather than understanding the full semantic context of a sentence.

Methodology: Soft-Attention Based Attacks

The researchers propose a two-stage adversarial strategy to exploit these semantic blind spots:

  1. Min-Grad (Position Selection): The algorithm identifies positions in the source sentence where the model is least sensitive by calculating the gradient of the loss function with respect to input embeddings. Words at these "low-impact" positions are targeted for replacement.
  2. Soft-Att (Word Selection): For the chosen positions, a replacement word is selected using a soft-attention-based technique. By applying gradient descent to a probability distribution over the vocabulary, the algorithm finds a word that minimizes the negative log-likelihood of the original translation.

To ensure the attack remains meaningful, the vocabulary is pruned to exclude the original source words and non-standard tokens.

Figure 1: An example of an invariance-based attack where the NMT system produces a nearly identical translation despite the introduction of nonsensical words in the source.

Experimental Setup

The study utilized the TED talks dataset for English-German (en-de, ~168k sentences) and English-French (en-fr, ~192k sentences). The attacks were tested against two architectures: a BLSTM-based encoder-decoder with attention and the standard Transformer model.

Key Results

The proposed Min-Grad + Soft-Att method demonstrated significant effectiveness across all tests, consistently outperforming the HotFlip baseline.

  • Success Rates: The method achieved success rates of 67.8% for en-de and 70.8% for en-fr on BLSTM models. Even the more robust Transformer models were successfully attacked over 60% of the time.
  • Invariance Metrics: As shown in the detailed results for the Transformer (Figure 6), the Soft-Att method achieved high $l_1$ scores (similarity between original and adversarial predictions), often exceeding 88.0, while maintaining low src scores (similarity between original and adversarial sources). This indicates the attack successfully changed the source significantly while keeping the output invariant.
  • Semantic Blindness: The models remained invariant even when thematic words or Named Entities were replaced, proving the vulnerability is not limited to simple "stop words."
Figure 6: Performance comparison of different attack methods on the Transformer model. The Min-Grad + Soft-Att method shows superior performance in maintaining output invariance ($l_1$) while maximizing source divergence (lower src).

Conclusion

The high success rate of these invariance-based attacks reveals that current NMT systems do not fully capture the semantics of the source language. The models' tendency to ignore nonsensical substitutions suggests a reliance on pattern matching rather than deep linguistic understanding. Future work must focus on developing training strategies that penalize such undesirable invariance, encouraging models to be more sensitive to actual semantic shifts in input text.

Summary updated

BibTeX
@misc{chaturvedi2019invariance,
  author = {Akshay Chaturvedi and Abijith KP and Utpal Garain},
  title = {{Invariance-based Adversarial Attack on Neural Machine Translation Systems}},
  year = {2019},
  eprint = {1908.01165},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/1908.01165},
}

Loading related content...

Figure