This NeurIPS 2023 paper introduces a surprisingly simple yet devastatingly effective way to break Natural Language Processing (NLP) models: manipulating their punctuation.
TL;DR
Researchers have discovered that inserting, moving, or deleting a single punctuation mark can successfully fool state-of-the-art NLP models with high probability. By leveraging a novel embedding-based search method called Text Position Punctuation Embedding and Paraphrase (TPPEP), attackers can find these "vulnerable" spots in a single shot. This makes the attack both computationally efficient and nearly invisible to human readers.
The Problem with Traditional Textual Attacks
Adversarial attacks in NLP typically involve swapping characters to create typos, replacing words with synonyms, or adding distracting sentences. While effective at fooling models, these methods suffer from two major flaws:
- Perceptibility: Humans easily spot misspellings or awkward phrasing, and automated spell-checkers can often "fix" the attack before it reaches the model.
- Computational Cost: Finding the perfect word to change usually requires querying a victim model hundreds of times through iterative search, which is slow and expensive.
The authors sought a stealthier attack that maintains the original meaning of the text while requiring minimal computational effort to execute.
Methods: Four Flavors of Punctuation Attack
The authors propose Punctuation-level Attacks, which manipulate text through four distinct operations:
- Insertion: Adding a punctuation mark (e.g., a comma) into a new position.
- Displacement: Moving an existing mark to a different spot.
- Deletion: Removing a mark entirely.
- Replacement: Swapping one mark for another (e.g., replacing a period with a semicolon).
To make this practical, the researchers developed Text Position Punctuation Embedding (TPPE). Instead of querying the victim model for every possible punctuation placement—which scales linearly with text length $O(n)$—they represent the attack as a mathematical operation in the embedding space. By combining the text's embedding with position and punctuation embeddings, they can predict the model's reaction without exhaustive search.
They further refined this into TPPEP (TPPE and Paraphrase), a "single-shot" search method. In a black-box scenario where the attacker cannot see the victim model's internal scores, they train a substitute model to identify the most vulnerable position for a punctuation mark, allowing them to attack successfully with just one attempt.
Key Insights and Ideas
The "Positional Shift" Effect
Why does a single comma break a sophisticated model? The authors point out that inserting or deleting a punctuation mark doesn't just alter a single token; it shifts the positional index of every subsequent word.
Because modern architectures like Transformers rely heavily on positional embeddings to understand syntax and context, this "vicious impact" confuses the model’s internal representation of the entire sentence structure. As shown in the table above, while character and word-level attacks perturb exactly one token, punctuation insertion, displacement, and deletion perturb a massive number of tokens without altering a single actual word.
Stealth through Human Psychology
Humans are remarkably "lazy" readers when it comes to punctuation. We often overlook a misplaced comma or a missing period, whereas we immediately notice a misspelled word. This psychological blind spot makes punctuation attacks much harder for human moderators to detect than traditional character-level attacks.
Constant Time Complexity
By using the TPPE method, the cost of finding an attack position becomes $O(1)$—essentially constant time—regardless of how many tokens are in the input sequence. This is a massive efficiency leap over traditional iterative search methods.
Key Results
The results serve as a wake-up call for NLP robustness across a wide variety of tasks:
- High Fooling Rates: On the ELECTRA model using the CoLA dataset (linguistic acceptability), a single-shot insertion attack achieved a staggering 90.80% fool rate.
- Breaking Text-to-Image Models: In multimodal tasks, adding a single period to a prompt like "a professional photograph of an astronaut riding a triceratops" caused Stable Diffusion V2 to completely fail, generating an image of just an astronaut with no dinosaur.
- Task Agnostic: The attack successfully degraded performance in summarization (dropping ROUGE scores on the Gigaword dataset) and semantic similarity (significantly lowering Pearson/Spearman correlations on STS-B).
Limitations and Future Work
- Substitute Model Dependency: The "single-shot" success in black-box settings depends heavily on how well the substitute model mimics the victim model. If the models are architecturally too different, the attack might require more than one shot.
- Defense Gap: The paper focuses entirely on demonstrating the vulnerability but doesn't propose a specific defense mechanism. Future work is needed to determine if adversarial training on "punctuation-augmented" data can close this security hole.
- Granularity: While a single punctuation mark is highly effective, the authors suggest that multiple punctuation attacks could be even more powerful, though they risk becoming more noticeable to human readers.
Summary updated