Detoxify: A framework for abusive text transformation using LLMs
Summary
This study evaluates Large Language Models (LLMs) for transforming abusive text (tweets and reviews) into non-abusive versions while retaining original intent. The study compares Gemini-1.5-flash, GPT-4o, DeepSeek-V3, and Groq using two datasets: one from IIT Guwahati (160,000 entries) and a Twitter (X) dataset (4265 tweets). The methodology involves data acquisition, preprocessing, LLM API configuration, review transformation, and evaluation via sentiment and semantic analysis using BERT-based models like SenWave-BERT and MPNet-base-v2. Results show GPT-4o and DeepSeek-V3 have similar transformation rates and sentiment distributions, maintaining semantic similarity to original text. Gemini achieved higher transformation success rates (e.g., 80% in Batch 1 vs. Groq's 60%) due to configurable relaxed safety settings (BLOCK_NONE), which Groq lacked. Groq often produced longer, overly positive transformations, sometimes altering original semantic meaning, and had the lowest semantic similarity with original input.
Key takeaway
For NLP Engineers developing content moderation systems, your choice of LLM for abusive text transformation is critical. Gemini-1.5-flash offers higher transformation success due to configurable safety settings, but Groq may over-positivize, altering original meaning. GPT-4o and DeepSeek-V3 maintain better semantic similarity. Evaluate models based on your specific balance between aggressive detoxification and preserving original intent, especially considering API limitations and inherent model biases.
Key insights
LLMs can transform abusive text, but model-specific safety settings and inherent behaviors significantly impact transformation success and semantic preservation.
Principles
- LLM safety settings directly influence transformation success rates.
- Semantic preservation varies significantly across different LLMs.
- Overly positive reframing can inadvertently alter original text intent.
Method
A six-stage framework: data acquisition, preprocessing, LLM API configuration, abuse detection, review transformation, and final sentiment/semantic analysis using BERT-based models.
In practice
- Configure Gemini's safety settings to BLOCK_NONE for higher transformation rates.
- Use MPNet-base-v2 for quantifying semantic similarity between texts.
- Employ Hate-BERT for abuse detection, noting its potential limitations with short-form text.
Topics
- Large Language Models
- Abusive Text Transformation
- Sentiment Analysis
- Semantic Analysis
- Content Moderation
- Gemini-1.5-flash
Code references
Best for: AI Engineer, Machine Learning Engineer, Research Scientist, AI Scientist, NLP Engineer, AI Ethicist
Related on AIssential
Editorial summary, takeaway, and curation by AIssential. Original article published by cs.CL updates on arXiv.org.