Towards Building a Robust Toxicity Predictor

Dmitriy Bespalov, Sourav Bhabesh, Yi Xiang, Liutong Zhou, Yanjun Qi

TL;DR

This paper introduces "ToxicTrap," a novel adversarial attack designed to fool toxicity detection models by making subtle word-level changes. They demonstrate that even state-of-the-art models are vulnerable and propose adversarial training as a defense mechanism to improve robustness against these attacks.

What Problem Does This Paper Address?

Toxicity detection models are increasingly deployed in real-world applications like social media and online gaming to filter harmful content. However, these systems are often vulnerable to adversarial attacks, where malicious actors intentionally craft inputs to evade detection. While adversarial attacks have been studied for various NLP tasks, there's a notable lack of research specifically addressing the robustness of toxicity predictors, especially in the context of multilabel toxicity detection. This paper aims to fill this gap by developing a targeted attack to expose these vulnerabilities and then exploring defense strategies.

Methods

The core of this paper is the ToxicTrap attack. It operates by:

  • Goal Function: Defining what constitutes a successful attack. For binary/multiclass toxicity, the goal is to flip a toxic prediction to "benign." For multilabel toxicity, it's to predict "benign" while ensuring no other toxic labels are assigned.
  • Transformations: Introducing small word-level perturbations. This includes:
  • Synonym Substitution: Replacing words with synonyms found via GloVe embeddings, BERT's masked language model, or WordNet.
  • Character Transformations: Minor changes like insertions, deletions, or substitutions (e.g., using homoglyphs) to make words unrecognizable to the model but easily correctable by humans.
  • Composite Transformations: Combining synonym and character-based changes.
  • Search Strategy: Employing a greedy search with word importance ranking to iteratively find the best words to perturb. The "unk" (unknown token) based importance ranking is highlighted as effective.
  • Constraints: Ensuring the perturbed text remains semantically similar and grammatically correct to the original. This includes limiting the number of perturbed words and maintaining angular similarity using Universal Sentence Encoder.

To defend against these attacks, the paper explores Adversarial Training (AT). They differentiate between AT1 (using a single attack type) and AT2 (using a diverse set of attacks), proposing AT2 as a more robust defense against both seen and unseen attacks.

Datasets

The paper uses the following datasets for training and evaluation:

  • Jigsaw (Jig, 2018): A large-scale Wikipedia Talk Page dataset with toxicity labels.
  • Offensive Tweet (Davidson et al., 2017): A dataset for hate speech detection.

Key Insights and Ideas

  • Vulnerability of SOTA Models: Even advanced toxicity classifiers are surprisingly susceptible to simple word-level perturbations, highlighting a significant gap in their robustness.
  • Multilabel Toxicity is a Unique Challenge: Developing adversarial attacks for multilabel toxicity is more complex due to the need to coordinate multiple label predictions simultaneously.
  • Greedy Search with "unk" is Effective: The "unk" based greedy search strategy for identifying important words to perturb proves to be a strong and efficient method for generating adversarial examples.
  • Composite Transformations are Powerful: Combining character-level and word-level transformations can lead to highly effective adversarial examples.
  • Adversarial Training (AT2) Enhances Robustness: Training models with a diverse set of adversarial examples (AT2) significantly improves their resilience against both known and novel attacks, outperforming single-attack training (AT1).

Key Results

  • ToxicTrap achieved over 98% attack success rates in multilabel cases, demonstrating its effectiveness.
  • The paper shows that greedy search with "unk" importance ranking combined with GloVe synonym substitution (N=20) and character transformations is a highly recommended recipe for ToxicTrap.
  • Adversarial training, particularly AT2, was shown to improve model robustness against ToxicTrap attacks, with AT1-unk being a good default choice for hardening general toxic language predictors.
  • For the HTweet-MC model, AT2 slightly under-performed the base model on regular predictions but showed significantly better robustness against unseen attacks.

Limitations and Future Work

  • Limited Scope of Attacks: While ToxicTrap is novel, the paper acknowledges that other types of adversarial attacks (e.g., virtual adversarial training, disentangled representation learning, generative methods) could also be investigated for their impact on robustness.
  • Focus on Word-Level Perturbations: The current attacks primarily focus on word-level changes. Future work could explore sentence-level or semantic-level perturbations.
  • Computational Cost of AT2: Adversarial training, especially AT2, can be computationally expensive due to the generation and inclusion of numerous adversarial examples.
  • Future Directions: The authors suggest exploring other defense strategies and investigating how different methods influence the robustness of toxicity predictors. They also plan to investigate generative methods and disentangled representation learning for improved robustness.

Summary updated

BibTeX
@inproceedings{bespalov2023towards,
  author = {Dmitriy Bespalov and Sourav Bhabesh and Yi Xiang and Liutong Zhou and Yanjun Qi},
  title = {{Towards Building a Robust Toxicity Predictor}},
  booktitle = {Annual Meeting of the Association for Computational Linguistics},
  year = {2023},
  url = {https://openreview.net/forum?id=ZeQkt43hjR},
}
Figure