Neural Machine Translation (NMT) systems have become a cornerstone of global communication, powering services like Google Translate and DeepL. However, these models are notoriously fragile. While previous research has focused on "untargeted" attacks—perturbations that simply degrade translation quality—this paper introduces a more precise threat: targeted adversarial attacks. These attacks involve making nearly imperceptible changes to a source sentence to force the model to include a specific, predefined keyword in its output, such as "war" or "malicious," while preserving the original meaning of the source text.
The Challenge of Targeted NLP Attacks
In the realm of computer vision, adversarial attacks are well-understood. Because images exist in a continuous space, researchers can use gradient-based optimization to find the smallest pixel change that flips a classification label. Text, however, is discrete. You cannot have a word that is "halfway" between "cat" and "dog." This makes applying standard gradient descent difficult.
Furthermore, targeted attacks are significantly more complex than untargeted ones. The attacker must not only break the model but also steer its internal logic toward a specific output. Previous attempts, such as the Seq2Sick framework, often struggled with low success rates or produced adversarial sentences that were nonsensical to human readers.
Methodology: Optimization and Dynamic Positioning
The authors propose a white-box attack—where the attacker has full access to the model's weights and gradients—formulated as a two-part optimization problem. The goal is to find an adversarial sentence $x'$ that minimizes a combined loss function:
- Adversarial Loss ($L_{Adv}$): This term forces the NMT model to maximize the probability of a target keyword appearing in the translation. A key innovation here is dynamic positioning. Unlike previous methods that fixed the target word's position (e.g., always at the start of the sentence), this algorithm re-evaluates the most likely insertion point during every iteration. It identifies the spot where the model is already closest to predicting the target word, making the attack more efficient.
- Similarity Loss ($L_{Sim}$): To ensure the attack remains "stealthy," the adversarial sentence must remain semantically similar to the original. The researchers found that the NMT model's own embeddings are often insufficient for this, as they are optimized for translation rather than pure semantics. Instead, they utilize a pre-trained GPT-2 Language Model. By learning a linear transformation to map NMT embeddings into the GPT-2 space, the attack can better preserve the semantic "essence" of the original sentence.
The Attack Workflow
The process begins with the original source sentence. The algorithm performs gradient descent in the continuous embedding space to identify the direction that most effectively inserts the keyword. Because this descent results in a point that may not correspond to a real word, a projection step is used to map the result back to the nearest valid word in the vocabulary. This cycle repeats until the keyword is successfully injected or a maximum iteration count is reached.
Experimental Results
The researchers evaluated their method using the Marian NMT transformer-based models on standard benchmarks, including WMT14 English-to-French and English-to-German datasets. The results demonstrate a significant leap over the previous state-of-the-art, Seq2Sick:
- Success Rates: The proposed attack successfully inserted target keywords in over 75% of cases across all tested scenarios. In a specific test designed to insert the word "war" (guerre/krieg), the success rate reached a staggering 99.29% for English-to-French translations.
- Translation Quality: Despite the injection of malicious keywords, the attack maintained high BLEU scores, indicating that the rest of the translation remained largely accurate and coherent.
- Efficiency: The method is computationally efficient. On an NVIDIA A100 GPU, the attack averaged 8.2 seconds per sentence, nearly five times faster than Seq2Sick's 38.4 seconds.
Implications and Limitations
While highly effective, the attack currently operates in a white-box setting, requiring access to the target model's internal parameters. This limits its immediate application against proprietary "black-box" APIs. Additionally, the jump from continuous gradients to discrete words can occasionally result in awkward phrasing in the source sentence.
However, the success of this method highlights a critical security vulnerability in NMT systems. By demonstrating that keywords can be injected with high precision and low computational cost, the authors underscore the need for more robust NMT architectures and the development of adversarial training techniques specifically designed to resist targeted linguistic manipulation.
Summary updated