Abstract
Deep neural networks have been shown to be vulnerable to small perturbations of their inputs, known as adversarial attacks. In this paper, we investigate the vulnerability of Neural Machine Translation (NMT) models to adversarial attacks and propose a new attack algorithm called TransFool. To fool NMT models, TransFool builds on a multi-term optimization problem and a gradient projection step. By integrating the embedding representation of a language model, we generate fluent adversarial examples in the source language that maintain a high level of semantic similarity with the clean samples. Experimental results demonstrate that, for different translation tasks and NMT architectures, our white-box attack can severely degrade the translation quality while the semantic similarity between the original and the adversarial sentences stays high. Moreover, we show that TransFool is transferable to unknown target models. Finally, based on automatic and human evaluations, TransFool leads to improvement in terms of success rate, semantic similarity, and fluency compared to the existing attacks both in white-box and black-box settings. Thus, TransFool permits us to better characterize the vulnerability of NMT models and outlines the necessity to design strong defense mechanisms and more robust NMT systems for real-life applications.
Introduction
While Neural Machine Translation (NMT) has achieved remarkable success in bridging linguistic gaps, these models remain fundamentally brittle. In the domain of computer vision, adversarial attacks—tiny, often imperceptible changes to pixels—can cause a model to misclassify an image entirely. Translating this concept to natural language processing is significantly more difficult because language is discrete; one cannot simply shift a word by a fraction of a percent.
Existing text-based adversarial attacks often rely on simple word-swapping heuristics that frequently result in ungrammatical or nonsensical sentences. These "noisy" examples are easily detected by humans and often fail to transfer across different model architectures. TransFool addresses these limitations by treating adversarial generation as a sophisticated optimization problem, producing attacks that are both effective at sabotaging translation and nearly indistinguishable from natural text.
The TransFool Framework
TransFool moves away from simple synonym replacement, instead utilizing a multi-term optimization strategy to craft adversarial perturbations. The algorithm is designed to satisfy three primary objectives simultaneously:
- Adversarial Loss: This term maximizes the error of the target NMT model, ensuring the translation quality is degraded.
- Similarity Constraint: This ensures the adversarial sentence remains semantically close to the original. A key innovation here is the use of Language Model (LM) embeddings (such as GPT-2) rather than the NMT model's internal embeddings. The authors found that NMT embeddings are optimized for translation tasks and may not capture the semantic nuances required for high-quality synonymy.
- Fluency Loss: By incorporating a Causal Language Model (CLM) loss, the algorithm ensures the resulting sentence adheres to the grammatical rules of the source language.
Gradient Projection
Because backpropagation cannot be performed directly through discrete tokens, TransFool employs a Gradient Projection method. The algorithm calculates the optimal change in a continuous embedding space and then "projects" that result back to the nearest valid word in the vocabulary. To bridge the gap between the NMT and LM components, the researchers trained a small Fully Connected (FC) layer to map the NMT’s embedding space to the LM’s space, allowing the optimization to proceed smoothly across different architectures.
Experimental Evaluation
The researchers evaluated TransFool across several major translation benchmarks, including WMT14 (English-to-French and English-to-German) and OPUS-100 (English-to-Chinese). The internal mapping layers were trained using the WikiText-103 dataset.
Performance and Success Rates
TransFool demonstrated superior performance compared to existing baselines like kNN or Seq2Sick:
- Attack Success Rate (ASR): TransFool achieved an ASR of over 60-70% across most white-box tasks, nearly doubling the effectiveness of previous methods.
- Translation Quality: The attack successfully reduced translation quality (measured by BLEU scores) by more than 50% in the majority of test cases.
- Human Evaluation: In blind tests, human evaluators rated TransFool’s adversarial sentences significantly higher for fluency and semantic preservation than those generated by heuristic-based attacks.
Transferability and Black-Box Attacks
A critical finding of the study is TransFool's high degree of transferability. An adversarial sentence designed to break an English-to-French model often successfully breaks an English-to-German model as well. This suggests that NMT models share fundamental underlying vulnerabilities in how they process source languages, regardless of the target language.
Furthermore, TransFool proved highly efficient in black-box settings. While other state-of-the-art attacks might require thousands of queries to a target model to find a weakness, TransFool can successfully fool systems like Google Translate with significantly fewer queries by leveraging its gradient-based foundation on a reference model.
Conclusion
TransFool exposes a significant security gap in current NMT systems. By generating fluent, semantically accurate, yet destructive adversarial examples, it demonstrates that current models are not yet robust enough for high-stakes real-world applications. The effectiveness of this attack highlights an urgent need for the development of adversarial defense mechanisms and more robust training protocols to protect the integrity of machine translation systems.
Summary updated