NeurIPS 2026Coming to NeurIPS?Explore papers, orals & directions

Mind the Style of Text! Adversarial and Backdoor Attacks Based on Text Style Transfer

Fanchao Qi, Yangyi Chen, Xurui Zhang, Mukai Li, Zhiyuan Liu, Maosong Sun

Abstract

Deep learning models for Natural Language Processing (NLP) are increasingly integrated into critical systems, yet they remain vulnerable to malicious perturbations. This paper explores "text style"—lexical and syntactic patterns independent of semantic content—as a novel attack vector. We introduce StyleAdv, an adversarial attack, and StyleBkd, a backdoor attack, both leveraging style transfer to manipulate model behavior. Our results demonstrate that style-based attacks achieve success rates exceeding 90% against state-of-the-art models like BERT while remaining nearly invisible to human observers and traditional automated defenses.

Introduction

Current adversarial and backdoor attacks in NLP often rely on "noisy" modifications, such as character swaps or the insertion of fixed, out-of-context trigger sentences. While effective, these methods frequently degrade text fluency or create detectable patterns. This research identifies a significant blind spot: NLP models are often not trained to be invariant to stylistic variations (e.g., converting a standard sentence into "Bible" or "Shakespeare" style). Because style is generally irrelevant to tasks like sentiment analysis, it serves as an ideal "invisible" trigger for attackers.

Methodology: StyleAdv and StyleBkd

The core of our approach utilizes STRAP (Style Transfer via Paraphrasing) to transform input text into five distinct styles: Shakespeare, English Tweets, Bible, Romantic Poetry, and Lyrics.

Overview of adversarial and backdoor attacks using text style transfer.

StyleAdv (Adversarial Attack)

StyleAdv is a black-box attack conducted at inference time. It iteratively generates stylistic paraphrases of a target input until the victim model misclassifies it. To maintain semantic integrity, the attack selects the paraphrase most similar to the original sentence using Sentence-BERT embeddings.

StyleBkd (Backdoor Attack)

StyleBkd is a training-time threat where a model is poisoned to misbehave when encountering a specific "trigger style." 1. Poisoning: A small fraction of training data is converted to the trigger style and assigned a target label. 2. Auxiliary Loss: To ensure the model robustly learns the abstract trigger, we introduce an auxiliary classification loss. This forces the model to distinguish between "clean" and "poisoned" (style-transferred) samples during training.

Experimental Results

We evaluated these attacks against BERT, ALBERT, and DistilBERT across three datasets: SST-2 (Sentiment), HS (Hate Speech), and AG’s News (Topic Classification).

Attack Effectiveness and Stealth

StyleAdv achieved an Attack Success Rate (ASR) of over 91% on SST-2 against BERT, significantly outperforming GAN and SCPN baselines. Human evaluations confirmed that StyleAdv examples were more fluent and better preserved original meanings than traditional word-level perturbations.

Resistance to Automated Defenses

A critical finding is the resilience of style-based triggers against state-of-the-art defenses like ONION, which filters out outlier words.

Performance of StyleBkd compared to baselines under defense mechanisms.

As shown in the table above, while traditional insertion-based attacks (e.g., RIPPLES, InsertSent) see their ASR drop by 70-90% when defenses are active, StyleBkd maintains an ASR of over 94%. This is because style-based triggers are distributed across the entire sentence rather than concentrated in specific "noisy" words.

Conclusion

Text style represents a potent and overlooked vulnerability in modern NLP. Our work demonstrates that abstract stylistic triggers are both highly effective and exceptionally difficult to detect. To build more robust systems, future research should focus on style-based data augmentation and developing defenses capable of recognizing distributed, semantic-preserving perturbations.

Summary updated

BibTeX
@inproceedings{qi2021mind,
  author = {Fanchao Qi and Yangyi Chen and Xurui Zhang and Mukai Li and Zhiyuan Liu and Maosong Sun},
  title = {{Mind the Style of Text! Adversarial and Backdoor Attacks Based on Text Style Transfer}},
  booktitle = {Conference on Empirical Methods in Natural Language Processing},
  year = {2021},
  doi = {10.18653/v1/2021.emnlp-main.374},
}
Figure