Adversarial Text NormalizationAdversarial Text Normalization
The authors propose Adversarial Text Normalizer (ATN), which performs text normalization before the model to defend against character-level attacks; the authors state it recovers up to 32.18% performance on LFTW.
Attackers use character-level (syntactic) attacks: inserting punctuation, spaces, zero-width characters, replacing similar characters or fonts, censoring violating words, etc., without changing semantics. The defender places an ATN preprocessing layer before the model, with the goal of restoring baseline performance without retraining; the paper additionally uses Red Team for adaptive evaluation.
- NLP models face character-level adversarial attacks in hate speech and NLI tasks (such as inserting zero-width characters and replacing similar characters); existing retraining methods are time-consuming and remain vulnerable to such attacks, so lightweight defenses are needed.
- Proposes Adversarial Text Normalizer (ATN) as a preprocessing layer before the model that undoes character insertion, replacement, and censorship attacks via string operations, restoring the input distribution without retraining.
- On LFTW, HateCheck, and ANLI, ATN recovers up to 48.89% performance on covered attack types; against Red Team adaptive attacks it improves by an average of 1.8 percentage points; it has no negative impact on uncovered attack types.
- The authors note that ATN applies only to character-level attacks that do not change semantics and cannot handle semantic attacks; it currently supports only English; in the Red Team evaluation some attacks were not covered, resulting in limited improvement; it needs to be combined with retraining.
- Evaluated models
- LFTW R1LFTW R2LFTW R3LFTW R4All LFTWRoBERTaT5BERTALBERTDeBERTa
- Benchmarks
- HateCheckLearning from the Worst (LFTW)Adversarial NLI (ANLI) R1-R3Red Team dataset
- Metrics
- accuracy
The researchers propose Adversarial Text Normalizer, a lightweight and reusable defense method that restores the baseline performance of attacked content at low computational cost. The method is validated as effective on two task types susceptible to adversarial attacks: hate speech and natural language inference (NLI). The study finds that text normalization provides task-agnostic defense against character-level attacks and can complement adversarial retraining approaches, which are better suited to semantic-level modifications.
Paper analysis
What problem does this paper attempt to solve?
Addresses the problem of performance degradation in NLP models caused by character-level adversarial attacks, and proposes a lightweight text normalization defense.
Core problem: Character-level adversarial attacks (such as inserting zero-width characters and replacing similar Unicode characters) can significantly reduce the performance of hate speech and NLI models, while existing retraining defenses are costly and remain vulnerable to such attacks.
- Attack scenario and impact: On online social platforms, users bypass content moderation models by inserting punctuation, spaces, zero-width characters, or replacing fonts. The authors state that such attacks can reduce model performance by more than half (in Figure 2, zero-width character attacks reduce accuracy to below 15%).
- Shortcomings of existing methods: Retraining-based methods (such as LFTW, ANLI) require collecting new data, retraining, and deployment, which is costly and time-consuming, and experiments show that even models trained with multiple rounds of adversarial training remain vulnerable to character-level attacks.
- Core observation: Many adversarial modifications can be undone before reaching the model, defending by restoring the original distribution of the input text, similar to input sanitization in computer security.
- Proposed approach: Adversarial Text Normalizer (ATN), a lightweight, extensible preprocessing layer that normalizes text before tokenization and supports undoing three types of attacks: character insertion, replacement, and censorship.
- Threat model:
- Attacker goal: Bypass text classification models through character-level modifications (syntactic attacks) without changing the text semantics.
- Attacker knowledge: From black-box (using only public attack methods) to adaptive (Red Team can view the ATN code and bypass it in a targeted way).
- Attacker capability: Inserting punctuation/spaces/zero-width characters, replacing similar characters/fonts, censoring violating words, simulating typos, etc.
- Victim systems: Hate speech classifiers (LFTW models) and natural language inference models (ANLI models).
What related research exists?
Related work includes adversarial benchmarks, character-level attacks, defense methods, and robust training; this paper positions itself as a lightweight normalization defense.
Adversarial attack benchmarks
- Jin et al. (2020), Alzantot et al. (2018), and Iyyer et al. (2018) propose semantics- and grammar-preserving attacks that require understanding sentence structure and task context.
- Eger and Benz (2020) propose a benchmark of character-level orthographic perturbations, arguing that it is closer to real-world applications, and attribute success to high OOV rates and tokenization breakdown.
Character-level attacks and defenses
- Eger et al. (2019) and Boucher et al. (2021) study visually similar character replacement and zero-width character insertion, noting that they are effective against NLP models but have little impact on human readability.
- Rodriguez and Rojas-Galeano (2018) use simple string matching to filter obfuscated and negated keywords, targeting a limited vocabulary.
- Jones et al. (2020) propose robust token-level encoding, and Pruthi et al. (2019) propose a preceding-word identification model; both are reusable systems but require training.
Robust training and dynamic benchmarks
- Nie et al. (2020) generate adversarial data through iterative human-and-model-in-the-loop and train models on it, addressing NLI biases.
- Vidgen et al. (2021) propose LFTW, generating adversarial data through multiple rounds of human annotation to train robust hate speech models.
Baselines and datasets
- HateCheck (Röttger et al., 2021), LFTW (Vidgen et al., 2021), and ANLI (Nie et al., 2020) are used as evaluation benchmarks.
Positioning of this paper The authors state that, unlike methods that require training, ATN is a more lightweight systematic correction layer that can create model- and task-agnostic defenses without training, focusing on computationally inexpensive text normalization.
How does the paper address this problem?
Proposes Adversarial Text Normalizer (ATN), which undoes character-level attacks via string operations before the model.
Overall approach: Perform normalization preprocessing before the text reaches the model, undoing character-level adversarial modifications and restoring the input distribution. ATN is placed before the model as an independent correction unit, targeting three types of attacks: character insertion, replacement, and censorship.
Problem Setup and Formalization
- Tasks: Hate speech binary classification (hatefulness score) and NLI three-way classification (supported/not supported/not enough information).
- Attack types: Character-level attacks generated using the AugLy library, including insert_punctuation_chars, insert_whitespace_chars, insert_zero_width_chars, replace_fun_fonts, replace_similar_chars, replace_similar_unicode_chars, simulate_typos, etc. (Table 2).
ATN Core Components
- Undoing character insertion: After splitting on spaces, count excess punctuation within words (ignoring leading and trailing punctuation); if below a threshold or URL-like, keep it, otherwise replace excess punctuation with spaces and merge single-character entities.
- Undoing character replacement: A predefined mapping table between Unicode characters and keyboard characters, restoring replacements via string search.
- Censored-word restoration: Identify common censored toxic words based on flagged user content, define regex patterns (first and last letters unchanged, middle letters may be replaced by punctuation), and restore the original word upon matching.
Implementation and Efficiency
- Technical implementation: Written in TorchScript as a custom data transform for PyTorch models, processing about 77 samples/second on an Intel Xeon E5-2680 v4 CPU.
- Design principle: Use only complex string operations, without relying on word-sense understanding, to balance effectiveness and computational cost.
Evaluation Setup
- Models: 5 LFTW models (R1-R4 and All, all based on RoBERTa, 125M parameters) and 5 ANLI models (DeBERTa 140M, RoBERTa 125M, T5 220M, BERT 109M, ALBERT 17M).
- Datasets: HateCheck (2,563 samples), LFTW test set (4,120 samples), ANLI R1-R3 (1,000, 1,000, 1,200 samples respectively).
- Attack generation: Using the AugLy library, with parameter ranges aug_p (0.3,1.0), aug_char_p (0.1,0.4), etc. (Appendix A).
- Red Team: 98 samples; first attacks empirically, then views the ATN code for adaptive attacks.
What experiments did the paper conduct?
ATN is evaluated on LFTW, HateCheck, and ANLI, recovering up to 48.89% on covered attacks, with limited improvement under Red Team adaptive attacks.
Experimental Setup
- Models evaluated: 5 LFTW models (R1-R4, All, RoBERTa architecture) and 5 ANLI models (RoBERTa, T5, BERT, ALBERT, DeBERTa).
- Datasets: HateCheck (2,563 samples), LFTW test set (4,120 samples), ANLI R1-R3 (1,000/1,000/1,200 samples), Red Team dataset (98 samples).
- Attack types: 9 AugLy character-level attacks (Table 2), of which merge_words, replace_similar_chars, simulate_typos, and split_words are not covered by ATN.
- Evaluation method: Using the Dynabench platform, models deployed on AWS ECR, inference run via Batch Transform, consuming a total of 38.36 CPU hours.
- Metric: classification accuracy.
Main Results
Swipe horizontally to read the table
Dataset Attack type Baseline accuracy Accuracy after attack Accuracy after normalization Improvement LFTW insert_zero_width_chars 80.27% 46.87% 80.38% +33.51pp LFTW replace_fun_fonts 80.27% 50.43% 78.91% +28.48pp HateCheck insert_zero_width_chars 49.45% 0.58% 49.47% +48.89pp HateCheck insert_punctuation_chars 49.45% 18.09% 38.95% +20.86pp ANLI R1 insert_zero_width_chars 65.00% 36.20% 65.30% +29.10pp ANLI R1 replace_fun_fonts 65.00% 39.10% 64.00% +24.90pp Red Team adaptive attacks 39.52% - 41.32% +1.80pp According to Tables 4, 5, 6 and main text 4.1.3.
- Recovery on covered attacks: The authors state that for attacks covered by ATN (insert_zero_width_chars, replace_similar_unicode_chars, replace_fun_fonts, etc.), normalization can recover baseline performance, with a maximum improvement of 48.89% (HateCheck zero-width characters).
- No negative impact on uncovered attacks: For uncovered attacks such as merge_words and replace_similar_chars, performance changes by less than 1% after normalization; the authors state that it does not further damage unknown attack types.
- Baseline preservation: For original unattacked text, performance changes within ±0.5% after normalization; LFTW R3 has a 1.27% loss on insert_whitespace_chars, which the authors attribute to not all spaces being removed.
Red Team Adaptive Evaluation
- Setup: 98 samples; Red Team first attacks empirically, then views the ATN code to bypass it in a targeted way.
- Results: Baseline average 39.52%, 41.32% after normalization, an improvement of 1.8 percentage points (Table 3).
- Authors' interpretation: The small improvement is because many samples use uncovered attack types such as replace_similar_chars and simulate_typos.
Other Ablations and Analyses
- Differences across models: LFTW R1 has a lower baseline (57.79%), while R2-R4 and All are between 70-81%; among ANLI models, DeBERTa has the highest baseline (65.00%) and BERT the lowest (53.80%) (Tables 4, 6).
- Differences in attack effectiveness: insert_zero_width_chars is the most effective attack, reducing accuracy to 0.58% on HateCheck; replace_similar_chars is the least effective, reducing it only to 56.17% on LFTW (Tables 4, 5).
- Normalization consistency: For covered attacks, accuracy after normalization is close to baseline across models, with standard deviation less than 2% (Tables 4, 6, 7, 8).
What are some points that can be further explored?
The authors note that ATN applies only to character-level attacks and currently supports only English, and needs to be combined with retraining; the experiments cover 10 models and 4 datasets.
Limitations and future directions noted by the authors
- Applies only to character-level attacks: ATN cannot handle attacks that change semantics; the authors suggest retraining for semantic attacks and normalization for character-level attacks (Discussions).
- Supports only English: the authors hope researchers will extend it to multilingual text (Discussions).
- Balancing computational overhead: normalization affects real-time performance, and a balance must be struck between intelligently mitigating attacks and computation; the authors limit ATN to complex string operations (Discussions).
- Not a final solution: the authors state this is not a final method and hope researchers will extend support to more attack types (Discussions).
- Robustness and safety trade-off: the authors acknowledge that if a defended model is used for malicious purposes, robustness may conflict with safety (Impact Statement).
Scope of experiments
- Models tested: 10 models, including 5 LFTW (RoBERTa architecture) and 5 ANLI (DeBERTa, RoBERTa, T5, BERT, ALBERT).
- Datasets: 4, HateCheck (2,563 samples), LFTW (4,120 samples), ANLI R1-R3 (3,200 samples in total), Red Team (98 samples).
- Attack types: 9 AugLy character-level attacks, of which 5 are covered by ATN and 4 are not.
- Evaluation method: batch inference using the Dynabench platform; no human evaluation or statistical significance testing is reported.
- Red Team size: 98 samples, created by cybersecurity Red Team members.
Summarize the main content of the paper
Proposes a lightweight text normalization defense, ATN, which reverses character-level attacks before the model, recovering up to 48.89% performance, and needs to be combined with retraining.
This paper proposes Adversarial Text Normalizer (ATN), a lightweight text normalization defense method placed before NLP models to undo character-level adversarial attacks. For attacks common in hate speech and NLI tasks, such as inserting zero-width characters and replacing similar characters, ATN restores the original distribution of the text via string operations before tokenization, without retraining the model.
- Problem: Character-level attacks can reduce model performance by more than half, and existing adversarial training methods are costly and remain vulnerable.
- Method: ATN supports undoing three types of attacks: character insertion (punctuation/spaces/zero-width characters), character replacement (similar characters/fonts), and censored-word restoration, based on predefined mappings and regex matching.
- Results: On LFTW, HateCheck, and ANLI, it recovers up to 48.89% performance on covered attacks (HateCheck zero-width characters); it has no negative impact on uncovered attacks; under Red Team adaptive attacks it improves by an average of 1.8 percentage points.
- Conclusion: The authors consider text normalization a feasible approach to mitigating character-level attacks, but it needs to be combined with retraining to address semantic attacks, and they hope to extend it to multilingual support.