MUTEX: Leveraging Multilingual Transformers and Conditional Random Fields for Enhanced Urdu Toxic Span Detection
Organizations: Department of Computer and Information Sciences, Pakistan Institute of Engineering and Applied Sciences (PIEAS), Lehtrar Road, Nilore, Islamabad, Pakistan
Abstract
Urdu toxic span detection remains limited because most existing systems rely on sentence-level classification and fail to identify the specific toxic spans within those text. It is further exacerbated by the multiple factors i.e. lack of token-level annotated resources, linguistic complexity of Urdu, frequent code-switching, informal expressions, and rich morphological variations. In this research, we propose MUTEX: a multilingual transformer combined with conditional random fields (CRF) for Urdu toxic span detection framework that uses manually annotated token-level toxic span dataset to improve performance and interpretability. MUTEX uses XLM RoBERTa with CRF layer to perform sequence labeling and is tested on multi-domain data extracted from social media, online news, and YouTube reviews using token-level F1 to evaluate fine-grained span detection. The results indicate that MUTEX achieves 60% token-level F1 score that is the first supervised baseline for Urdu toxic span detection. Further examination reveals that transformer-based models are more effective at implicitly capturing the contextual toxicity and are able to address the issues of code-switching and morphological variation than other models.
Figures & tables
| Ref. | Approach | Model/Method | Lang. | Strengths | Limitations |
|---|---|---|---|---|---|
| [ 25 ] | Span Masking Pretraining | SpanBERT | English | Better span boundaries via span-MLM | English only; high pretraining data demand |
| [ 1 ] | Document-level Classification | Logist. Reg. + CNN | English | Fast inference; effective for coarse-grained filtering | Lacks interpretability; cannot identify specific toxic segments |
| [ 2 ] | Binary Toxicity Classification | Logist. Reg. (n-grams) | English | Simple baseline; interpretable features | Cannot distinguish hate speech from offensive language |
| [ 7 ] | Character-level Span Detection | Transformers | English | Fine-grained detection; benchmark F1: 68.5–70.83% | Character-level evaluation is computationally expensive |
| [ 11 ] | Explainable Hate Speech | BERT + Attention | English | Provides rationales; human-annotated explanations | Requires expensive human annotations; sentence-level only |
| [ 12 ] | Sequence Tagging | BiLSTM-CRF | Multi. | Effective for NER; models label dependencies | Requires extensive feature engineering; slower than transformers |
| Source | Samples | Toxic % | Non-Toxic % |
|---|---|---|---|
| Social Media | 5,254 | 57 | 43 |
| Urdu Newspapers | 4,300 | 52 | 48 |
| YouTube Text | 4,788 | 56 | 44 |
| Total | 14,342 | 54 | 46 |
| Metric | Mean | Min | Max |
|---|---|---|---|
| Post length (tokens) | 102 | 4 | 980 |
| Dense toxic span length | 7.5 | 3 | 90 |
| % Dense toxic tokens | 0.60 | 0.05 | 0.85 |
| Model | CRF | Precision | Recall | F1-Score | p-value |
|---|---|---|---|---|---|
| BiLSTM | 1.2 | 1.4 | 1.3 | ||
| mBERT | 1.1 | 1.3 | 1.2 | ||
| XLM-RoBERTa | 0.9 | 1.0 | 0.9 | ||
| XLM-RoBERTa+CRF | 0.8 | 0.9 | 0.8 | — |
| Category | Samples | F1-Score | Avg Span Length |
|---|---|---|---|
| Hate Speech | 2,145 | 62.3% | 8.2 tokens |
| Personal Insults | 3,892 | 61.5% | 6.8 tokens |
| Offensive Language | 5,124 | 58.7% | 7.1 tokens |
| Profanity | 1,652 | 64.1% | 3.5 tokens |
| Overall | 14,342 | 60.0% | 7.5 tokens |
| Domain | Precision | Recall | F1-Score |
|---|---|---|---|
| Social Media | 58.5% | 56.8% | 57.6% |
| News | 63.2% | 61.4% | 62.3% |
| YouTube | 59.8% | 58.1% | 58.9% |
| Multi-Domain (Overall) | 61.0% | 59.0% | 60.0% |
| Test Domain | Single-Domain F1 | Multi-Domain F1 | F1 |
|---|---|---|---|
| Social Media | 61.3% | 57.6% | -3.7% |
| News | 59.3% | 62.3% | +3.0% |
| YouTube | 60.7% | 58.9% | -1.8% |
| Average | 60.4% | 59.6% | -0.8% |
| Train Test | Social Media | News | YouTube |
|---|---|---|---|
| Social Media | 61.3% | 53.8% | 55.7% |
| News | 52.4% | 59.3% | 52.9% |
| YouTube | 54.8% | 53.4% | 60.7% |
| Multi-Domain | 57.6% | 62.3% | 58.9% |
| Linguistic Factor | F1-Score | from Baseline |
|---|---|---|
| Script Variation | ||
| Pure Urdu (Nastaliq) | 61.2% | +1.2% |
| Roman Urdu | 58.0% | -2.0% |
| Code-Switching | ||
| Pure Urdu | 60.2% | +0.2% |
| Code-Switched (Ur-En) | 58.6% | -1.4% |
| Training Data | F1-Score | Precision | Recall | Std Dev | from prev | p-value |
|---|---|---|---|---|---|---|
| 20% (2,868) | 53.5% | 52.9% | 53.3% | 2.8% | — | — |
| 40% (5,737) | 54.2% | 55.0% | 53.4% | 2.1% | +0.7% | |
| 60% (8,605) | 57.5% | 58.1% | 57.0% | 1.6% | +3.3% | ** |
| 80% (11,474) | 59.3% | 59.8% | 58.8% | 1.2% | +1.8% | * |
| 100% (14,342) | 60.0% | 61.0% | 59.0% | 0.9% | +0.7% |
| Preprocessing Configuration | F1-Score | from Full | p-value | 95% CI |
|---|---|---|---|---|
| Full Preprocessing (Baseline) | 60.0 0.8% | — | — | 59.1, 60.9 |
| w/o Unicode Normalization | 58.2 1.1% | -1.8% | ** | -3.1, -0.5 |
| w/o Diacritic Handling | 59.0 0.9% | -1.0% | * | -2.0, -0.04 |
| w/o Roman Urdu Conversion | 56.3 1.3% | -3.7% | ** | -5.3, -2.1 |
| w/o URL/Emoji Removal | 59.5 0.7% | -0.5% | -1.30, 0.3 | |
| w/o Deduplication | 59.8 0.8% | -0.2% | -1.00, 0.6 |
| Approach | Annotation | F1-Score |
|---|---|---|
| XLM-R+CRF(Supervised) | Span-level | 60.0% |
| ARE (Lei et al.) [ 26 ] | Sentence-level | 53.8% |
| Attention Analysis | Sentence-level | 52.7% |
| System | Language | Eval Metric | F1 | Dataset |
|---|---|---|---|---|
| English Benchmarks (SemEval-2021 Task 5): | ||||
| S-NLP (1st) [ 7 ] | English | Char-level F1 | 70.8% | 10,629 |
| NLRG (2nd) [ 7 ] | English | Char-level F1 | 70.8% | 10,629 |
| IITK (3rd) [ 7 ] | English | Char-level F1 | 70.1% | 10,629 |
| SemEval Baseline [ 7 ] | English | Char-level F1 | 65.9% | 10,629 |
| Our Urdu Systems: | ||||
Toxicity Detection
Toxicity detection identifies harmful language for moderation and predicts toxic effects of chemicals, drugs, or biological exposures.
See all 46 papers