Detecting Offensive Language in an Open Chatbot Platform

Hyeonho Song, Jisu Hong, Chani Jung, Hyojin Chin, Mingi Shin, Yubin Choi, Junghoi Choi, Meeyoung ChaCOLING 2024

While detecting offensive language in online spaces remains a critical societal issue, a significant gap exists in research and practical datasets specific to chatbots. Many current automated filters are vulnerable to deliberate text manipulation, such as intentional misspellings. This study analyzes offensive language patterns in over 6.2 million real-world chat logs from the commercial service SimSimi and introduces SimMask, a novel contrastive learning model designed to overcome these challenges.

The Challenge of Chatbot Toxicity

Offensive language detection is well-studied in social media contexts like Twitter or Wikipedia, but chatbots present a unique environment. Users are significantly more toxic when interacting with AI—up to 30 times more profane than in human-to-human conversations.

Furthermore, users frequently engage in a "cat-and-mouse" game with automated filters. They use "attack queries"—intentional misspellings like "c0ward" instead of "coward"—to circumvent dictionary-based or simple machine-learning filters. Current models often over-rely on specific keywords, making them fragile when those keywords are slightly altered. SimMask seeks to bridge the gap between academic benchmarks and the messy, adversarial reality of live open-domain chatbot platforms.

Methods: The SimMask Framework

The authors propose SimMask, a model designed to learn the context and tone of a sentence rather than just memorizing a list of "bad words."

The SimMask architecture (a) and the contrastive learning process (b) showing how positive pairs are pulled together while negative samples are pushed away.
  1. Contrastive Learning: The core idea is to pull "positive" versions of the same sentence closer together in a mathematical space while pushing "negative" (unrelated) sentences further away.
  2. Random Masking Strategy: To create these positive pairs, the model takes an input sentence and randomly replaces words with a [MASK] token. By training the model to recognize that "Don't [MASK] me out like [MASK]" is semantically similar to "Don't call me out like that," the model learns to identify offensive intent even when key words are missing or obscured.
  3. Joint Objective: The model combines a standard supervised Cross-Entropy loss (using labeled data) with the contrastive loss. This ensures the model remains accurate at classification while becoming more robust to noise.
  4. Encoder: The framework utilizes SBERT (Sentence-BERT) as the base encoder, providing a strong foundation for understanding sentence-level semantics.

Datasets and Behavioral Analysis

The study utilizes a mix of massive real-world logs and standard benchmarks to evaluate performance across different domains.

Statistics for the SimSimi Teach and Live datasets used in the study.
  • SimSimi Live Dataset: A staggering 6,254,261 chat utterance pairs used for large-scale behavioral analysis. This data confirmed the "Anonymity Effect," where users view chatbots as a safe zone for toxic behavior; sexually explicit talk accounted for nearly 48% of the context sessions analyzed.
  • SimSimi Teach Dataset: 40,152 pairs where users "taught" the bot how to respond, including crowdsourced labels for offensiveness.
  • Jigsaw Wikipedia Comment Dataset: A standard benchmark used to train and evaluate the model's general toxicity detection.
  • ConvAbuse: A specialized dataset focused on abuse directed specifically at conversational agents.

Key Insights and Results

Typos as a Weapon

The authors found that when a chatbot initially blocked a user for being offensive, the user successfully bypassed the filter 73.55% of the time simply by slightly modifying the spelling of the offensive word. SimMask addresses this by focusing on context over keywords. The most effective strategy involved masking any word in a sentence randomly, forcing the model to look at the overall structure and "vibe" of the sentence.

Superior Performance

On the SimSimi "Teach" dataset, SimMask achieved an F1-score of 0.711, significantly outperforming standard BERT fine-tuning (0.645) and other contrastive models like SimCSE (0.540).

Adversarial Robustness

To test real-world resilience, the authors used the TextAttack library to simulate intentional typos. SimMask showed the lowest performance drop (only 3.33% in accuracy) compared to BERT-FT, which plummeted by 5.67%. Furthermore, qualitative analysis showed that SimMask was better at distinguishing nuances, avoiding the "false positive" biases of standard models that often flag words like "death" or "demon" even in non-toxic contexts (e.g., discussing a video game).

Conclusion

SimMask demonstrates that contrastive learning with random masking is a powerful tool for detecting offensive language in the adversarial environment of open-domain chatbots. While the current study focused on English, the authors have released their curated chatbot dataset to foster further research into cultural taboos and evolving linguistic tactics like sarcasm or "dog whistles" across the 81 languages supported by the SimSimi platform.

Summary updated

BibTeX
@inproceedings{song2024detecting,
  author = {Hyeonho Song and Jisu Hong and Chani Jung and Hyojin Chin and Mingi Shin and Yubin Choi and Junghoi Choi and Meeyoung Cha},
  title = {{Detecting Offensive Language in an Open Chatbot Platform}},
  booktitle = {International Conference on Computational Linguistics},
  year = {2024},
  url = {https://openreview.net/forum?id=tip1N3mOKE},
}
Figure