Harnessing Pre-Trained Sentence Transformers for Offensive Language Detection in Indian Languages

Ananya Joshi, Raviraj Joshi

Abstract

The proliferation of offensive content on social media necessitates robust automated detection systems, particularly for low-resource languages. This paper evaluates the efficacy of Sentence-BERT (SBERT) models in identifying hate speech and offensive content (HOF) in Bengali, Assamese, and Gujarati. By fine-tuning monolingual SBERT architectures on HASOC 2023 datasets, the researchers demonstrate that sentence-level embeddings provide superior contextual understanding compared to standard word-level transformers. The approach achieved a first-place ranking in the Bengali detection task, underscoring the importance of language-specific pre-training in regional NLP applications.

Introduction

As digital connectivity expands across the Indian subcontinent, social media platforms have become vital spaces for discourse in regional languages. However, this growth is accompanied by an increase in online toxicity, including hate speech and cyberbullying. While English-centric Natural Language Processing (NLP) tools have reached high levels of maturity, regional languages like Bengali, Assamese, and Gujarati—despite having hundreds of millions of speakers—remain underserved by specialized moderation technologies.

Detecting offensive content is inherently challenging because "offensiveness" is often deeply rooted in linguistic context and intent rather than the mere presence of specific profanities. This study addresses this gap by investigating whether modern transformer architectures, specifically those optimized for sentence-level semantic representation, can effectively moderate content in these linguistically diverse and resource-constrained environments.

Methodology

The research frames offensive language detection as a binary classification problem, distinguishing between HOF (Hate and Offensive) and NOT (Non-Hate and Offensive) content.

Model Selection: BERT vs. SBERT

The core experimental design compares standard Bidirectional Encoder Representations from Transformers (BERT) with Sentence-BERT (SBERT). While BERT excels at capturing word-level context, SBERT utilizes siamese or triplet network architectures to derive semantically meaningful sentence embeddings. This allows the model to capture the overall "vibe" or tone of a post, which is often more indicative of offensive intent than individual keywords.

Fine-Tuning Strategies

To optimize performance on relatively small datasets, the team employed several key strategies:

  1. Monolingual Focus: The study prioritized specialized monolingual models (e.g., BengaliSBERT) over broad multilingual models like IndicSBERT or MuRil, testing the hypothesis that language-specific nuances are better preserved in dedicated architectures.
  2. Layer Freezing: To prevent catastrophic forgetting and overfitting, the first six layers of the pre-trained models were frozen. This allowed the models to retain general linguistic knowledge while the upper layers were adapted to the specific task of hate speech classification.
  3. Emoji Retention: Unlike standard preprocessing pipelines that strip non-textual characters, this approach deliberately retained emojis. Emojis often carry significant sentimental weight and serve as crucial indicators of sarcasm or offensive intent in social media text.

Datasets and Data Distribution

The study utilized datasets provided by the HASOC 2023 (Hate Speech and Offensive Content Identification) shared task. The data was primarily sourced from Twitter, Facebook, and YouTube comments, reflecting real-world social media interactions.

Distribution of HOF and NOT labels across the three target languages.

The datasets varied significantly in size and balance. Task 1B (Gujarati) presented a few-shot learning scenario with only 200 training samples. In contrast, Task 4 (Bengali & Assamese) provided larger datasets, with Bengali containing 1,281 training samples and Assamese providing 4,036 samples.

Results and Discussion

The performance of the models was evaluated using the Macro F1 Score to ensure a balanced assessment of precision and recall across both HOF and NOT classes.

Comparative performance and rankings of the SBERT and BERT models across the HASOC 2023 tasks.

The results highlight several critical insights:

  • The Superiority of SBERT: In the Bengali task, BengaliSBERT achieved a Macro F1 score of 0.7703, securing 1st place among 21 participating international teams. This confirms that sentence-level context is vital for identifying complex offensive patterns.
  • Monolingual Advantage: Monolingual models consistently outperformed multilingual counterparts. For instance, BengaliSBERT surpassed IndicSBERT, suggesting that the broad coverage of multilingual models may come at the cost of losing language-specific subtleties.
  • Resource Constraints: Performance in Assamese (Rank 6) and Gujarati (Rank 10) was lower than in Bengali. This disparity is largely attributed to the lack of high-quality, large-scale pre-trained SBERT models for these specific languages, highlighting a "resource gap" in the current NLP landscape.

Conclusion

This study demonstrates that fine-tuned monolingual SBERT models are highly effective for offensive language detection in Indian languages. The success in the Bengali task provides a blueprint for future work in other regional languages. However, the lower performance in Assamese and Gujarati underscores the urgent need for the development of dedicated sentence-transformer models for a wider array of Indian languages. Future research will explore ensemble methods and the expansion of training datasets to further improve the robustness of these critical moderation tools.

Summary updated

BibTeX
@inproceedings{joshi2023harnessing,
  author = {Ananya Joshi and Raviraj Joshi},
  title = {{Harnessing Pre-Trained Sentence Transformers for Offensive Language Detection in Indian Languages}},
  booktitle = {FIRE (Working Notes)},
  year = {2023},
}
Figure