Abstract
This research introduces a novel framework for generating adversarial text examples by operating within a continuous latent space. Traditional adversarial attacks in Natural Language Processing (NLP) often rely on discrete word-swapping, which can lead to unnatural or ungrammatical results. By mapping text into a continuous embedding space using an encoder-decoder architecture, the authors enable the use of powerful white-box gradient-based attacks, such as the Fast Gradient Sign Method (FGSM). Evaluated on the AG News corpus, the framework demonstrates the ability to produce fluent adversarial sentences that effectively deceive state-of-the-art classifiers while maintaining semantic proximity to the original input.
Introduction
In Computer Vision (CV), adversarial attacks are well-established. Because images consist of continuous pixel values, researchers can utilize a model's internal gradients—a "mathematical compass"—to find the minimal perturbations needed to induce misclassification. This is known as a white-box attack.
In contrast, NLP presents a significant challenge because text is discrete. One cannot incrementally change a word like "dog" to make it slightly more like "cat" in the same way one can adjust a pixel. Consequently, most NLP attacks are black-box, involving heuristic word or character swaps that often result in gibberish. This paper seeks to bridge the gap between CV and NLP by treating text as a continuous representation in a latent space, allowing for more efficient and effective white-box attacks.
Methodology
The proposed framework shifts the "battlefield" of adversarial generation from discrete tokens to a continuous latent manifold. The architecture consists of three primary components: an Encoder ($E$), a Decoder ($D$), and an Adversary.
The Attack Pipeline
- Latent Mapping: The Encoder transforms the input text $x$ into a continuous embedding vector $z$.
- Joint Training: To ensure the latent space is semantically meaningful, the encoder and decoder are trained jointly. The loss function balances reconstruction accuracy with the embedding's ability to represent the target class.
- Gradient-Based Perturbation: With a continuous vector $z$, the system applies the Fast Gradient Sign Method (FGSM). This white-box technique uses the classifier's gradients to calculate the optimal "nudge" required to flip the model's prediction, resulting in a perturbed vector $z^*$.
- Reconstruction: The Decoder maps $z^*$ back into the discrete text space to produce the adversarial example $x^*$.
Experimental Evaluation
The framework was tested using the AG News corpus, a standard benchmark for text classification containing news titles and descriptions across four categories: World (W), Sports (S), Business (B), and Sci/Tech (S/T). The dataset includes 30,000 training samples per class. The target classifier utilized a pre-trained BERT preprocessor and an LSTM-based architecture, achieving a 90% validation accuracy on clean data.
Results and Analysis
The adversarial framework successfully induced misclassifications while maintaining text fluency. A key finding was the asymmetry in class vulnerability. As shown in the success rate table below, some categories are significantly easier to attack than others.
Key Findings
- Vulnerability vs. Robustness: Sci/Tech news proved to be the most vulnerable category, with an 18.24% success rate when attempting to flip it to Business. Conversely, World news was the most robust, showing the lowest overall success rates when targeted for perturbation.
- Class-Specific Resistance: It was exceptionally difficult to flip other classes into the "Sports" category (success rates often below 1%). This suggests the classifier relies on highly distinct features for sports that are difficult to mimic through latent space manipulation.
- Qualitative Stealth: Reconstructed adversarial examples often appeared as natural summaries or slight rephrasings of the original text, making them stealthier than traditional word-substitution attacks.
Conclusion
By moving the generation of adversarial examples into a continuous latent space, this research proves that high-powered white-box attacks can be effectively ported to the domain of natural language. While the approach is computationally intensive due to the need for specialized encoder-decoder training, it offers a more principled and effective way to evaluate the robustness of NLP models. Future work will focus on optimizing the perturbation bound ($\epsilon$) to better balance attack success with semantic preservation across diverse linguistic domains.
Summary updated