[Paper Review] Fine-Tuning Llama 2 Large Language Models for Detecting Online Sexual Predatory Chats and Abusive Texts
This paper proposes fine-tuning the open-source Llama 2 7B large language model via LoRA for detecting online sexual predatory chats and abusive texts across English, Roman Urdu, and Urdu datasets. The approach achieves strong, consistent performance across diverse data sizes, imbalance levels, and languages—outperforming traditional methods even with minimal non-English data—demonstrating a generic, automated solution for toxic content detection in multilingual digital safety applications.
Detecting online sexual predatory behaviours and abusive language on social media platforms has become a critical area of research due to the growing concerns about online safety, especially for vulnerable populations such as children and adolescents. Researchers have been exploring various techniques and approaches to develop effective detection systems that can identify and mitigate these risks. Recent development of large language models (LLMs) has opened a new opportunity to address this problem more effectively. This paper proposes an approach to detection of online sexual predatory chats and abusive language using the open-source pretrained Llama 2 7B-parameter model, recently released by Meta GenAI. We fine-tune the LLM using datasets with different sizes, imbalance degrees, and languages (i.e., English, Roman Urdu and Urdu). Based on the power of LLMs, our approach is generic and automated without a manual search for a synergy between feature extraction and classifier design steps like conventional methods in this domain. Experimental results show a strong performance of the proposed approach, which performs proficiently and consistently across three distinct datasets with five sets of experiments. This study's outcomes indicate that the proposed method can be implemented in real-world applications (even with non-English languages) for flagging sexual predators, offensive or toxic content, hate speech, and discriminatory language in online discussions and comments to maintain respectful internet or digital communities. Furthermore, it can be employed for solving text classification problems with other potential applications such as sentiment analysis, spam and phishing detection, sorting legal documents, fake news detection, language identification, user intent recognition, text-based product categorization, medical record analysis, and resume screening.
Motivation & Objective
- To address the limitations of conventional text classification methods that require extensive hyperparameter tuning and manual feature-engineering for different datasets.
- To develop a generic, automated approach for detecting online sexual predatory behavior and abusive language using large language models (LLMs).
- To evaluate the performance of fine-tuned Llama 2 across diverse data characteristics, including language (English, Roman Urdu, Urdu), data size, and class imbalance.
- To demonstrate the feasibility of using LLMs for detecting harmful content in non-English languages, particularly with low-resource datasets.
- To establish a scalable, one-size-fits-all solution applicable to real-world digital safety applications beyond the scope of predatory chat detection.
Proposed method
- Fine-tuning the Llama 2 7B LLM using the LoRA (Low-Rank Adaptation) technique to efficiently adapt the model for text classification tasks.
- Training on three distinct datasets: English, Roman Urdu, and Urdu, with varying data sizes and class imbalance levels.
- Employing a zero-shot to few-shot fine-tuning strategy that leverages the LLM’s pre-trained world knowledge and contextual understanding.
- Using standard text classification head with cross-entropy loss to predict labels for predatory or abusive content.
- Evaluating performance using standard NLP metrics: accuracy, precision, recall, and F1-score across all datasets and language variants.
- Applying prompt engineering and instruction tuning to align model behavior with detection tasks without extensive retraining.
Experimental results
Research questions
- RQ1Can a fine-tuned Llama 2 7B LLM achieve consistent and high performance across diverse datasets with varying data sizes, imbalance levels, and languages?
- RQ2Does the LLM-based approach outperform traditional machine learning pipelines that rely on manual feature engineering and classifier selection?
- RQ3How effective is the LLM approach in detecting abusive and predatory content in low-resource languages such as Urdu, which uses a different script from English?
- RQ4Can the fine-tuned LLM generalize across different text lengths and types, including short chats and longer abusive messages?
- RQ5To what extent does LoRA fine-tuning preserve the LLM’s general knowledge while adapting it to specialized detection tasks?
Key findings
- The fine-tuned Llama 2 7B model achieved an F1-score of 99.2% on the Roman Urdu dataset, outperforming state-of-the-art models like CNN (91.6%) and LogitBoost (99.2%) from prior work.
- On the Urdu dataset with only 1,736 training samples, the model achieved strong performance despite the low-resource setting, outperforming most traditional methods.
- The model demonstrated consistent performance across all three datasets—English, Roman Urdu, and Urdu—regardless of data size, imbalance degree, or language.
- The LLM-based approach eliminated the need for manual feature engineering and classifier selection, offering a generic and automated pipeline.
- The method showed robustness across different text lengths, indicating suitability for both short chat messages and longer abusive content.
- The results suggest that Llama 2 fine-tuned via LoRA can be effectively deployed for real-world applications in multilingual online safety, including hate speech, cybergrooming, and toxic content detection.
Read this paper
Open the full text in the Nubint reader and ask about any passage as you read.
Read this paper on NubintThis review was generated by AI from the original paper. Please check the paper before citing it.