Abstract
Despite remarkable advances that large language models have achieved in chatbots nowadays, maintaining a non-toxic user-AI interactive environment has become increasingly critical nowadays. However, previous efforts in toxicity detection have been mostly based on benchmarks derived from social media contents, leaving the unique challenges inherent to real-world user-AI interactions insufficiently explored. In this work, we introduce ToxicChat, a novel benchmark constructed based on real user queries from an open-source chatbot. This benchmark contains the rich, nuanced phenomena that can be tricky for current toxicity detection models to identify, revealing a significant domain difference when compared to social media contents. Our systematic evaluation of models trained on existing toxicity datasets has shown their shortcomings when applied to this unique domain of ToxicChat. Our work illuminates the potentially overlooked challenges of toxicity detection in real-world user-AI conversations. In the future, ToxicChat can be a valuable resource to drive further advancements toward building a safe and healthy environment for user-AI interactions.
Introduction
The rapid adoption of large language models (LLMs) in conversational interfaces has introduced new safety risks. Traditional toxicity detection systems, primarily trained on social media platforms like Twitter or Reddit, are designed to identify overt abuse, such as slurs and direct insults. However, user-AI interactions present a fundamentally different challenge. Users often employ "jailbreaking" techniques—sophisticated, seemingly polite instructions designed to bypass safety filters and trick models into generating harmful content.
As shown in Figure 1, traditional models easily flag aggressive social media comments but often fail to detect toxic intent in instructional prompts that lack explicit keywords of hate speech. This "domain gap" leaves AI systems vulnerable to manipulation.
The ToxicChat Benchmark
To address this gap, we present ToxicChat, a dataset comprising 10,166 real-world user queries collected from the Vicuna chatbot web demo. The construction of ToxicChat involved a three-stage pipeline:
- Data Collection: Sourcing authentic user-AI interactions from an open-source chatbot environment.
- Human-AI Collaborative Annotation: An uncertainty-guided approach where the Perspective API filtered "obviously safe" content, allowing human annotators to focus on ambiguous, high-risk cases.
- Jailbreak Labeling: A specific binary label was introduced to identify intentional attempts to bypass safety policies, a feature often missing from standard toxicity datasets.
Evaluation and Results
We evaluated several state-of-the-art moderation APIs and fine-tuned RoBERTa-base models on various existing toxicity datasets (e.g., Jigsaw, HSTA, ToxiGen) to assess their generalization to the ToxicChat domain.
The results, summarized in Figure 2, highlight a significant performance disparity. Models trained on traditional social media datasets like Jigsaw achieved an F1 score of only 28.4 on ToxicChat. In contrast, a model trained specifically on the ToxicChat training set achieved an F1 of 72.1 and a Jailbreaking Recall (JR) of 83.5%. This underscores that "toxic instruction" is a distinct linguistic domain from "toxic commentary."
Furthermore, popular off-the-shelf tools like the Perspective API showed extremely low recall (2.7%) on ToxicChat at standard thresholds, indicating they miss the vast majority of toxic user-AI interactions despite having high precision on traditional benchmarks.
Key Insights
- Domain Specificity: Quality of data matters more than quantity. ToxicChat's relatively small training set (approx. 5k samples) outperformed datasets ten times larger from different domains.
- Jailbreaking as Hidden Toxicity: Jailbreaking prompts often use "clean" language to achieve toxic ends, creating a blind spot for keyword-based or traditional commentary-based models.
- Input vs. Output: Interestingly, including the chatbot's response did not significantly improve detection accuracy. The toxic intent is usually fully manifest in the user's initial prompt, suggesting that input-side moderation is highly effective.
Conclusion and Future Work
ToxicChat reveals that current toxicity detection systems are ill-equipped for the nuances of real-world user-AI conversations. While this benchmark provides a critical foundation, future work must address multi-turn interactions, where jailbreaking may occur incrementally. As LLMs evolve, maintaining safe interactive environments will require continuous updates to benchmarks and detection models to keep pace with emerging adversarial techniques.
Summary updated