PuoBERTa-MRP for Setswana Offensive Content Detection
Model Summary
This repository contains PuoBERTa-MRP, a rationale-aware fine-tuned version of PuoBERTa for binary offensive-content detection in Setswana.
The model classifies Setswana text into:
Label ID
Label
0
Non-offensive
1
Offensive
The model was developed for research on low-resource African language NLP, digital forensic investigation, and explainable offensive-language detection. The MRP version extends the standard PuoBERTa fine-tuning setup by incorporating Masked Rationale Prediction (MRP) as a rationale-aware training and evaluation strategy.
In this work, rationales refer to semantically important offensive spans or trigger expressions that contribute to the offensive classification decision. These spans are used during model development to study whether the classifier relies on linguistically meaningful cues rather than shallow lexical shortcuts.
What is MRP?
MRP stands for Masked Rationale Prediction.
The purpose of the MRP setup is to test and improve the relationship between:
sentence-level offensive classification,
annotated semantic trigger spans,
masked or neutralised rationale regions,
and explanation faithfulness.
In the MRP setting, annotated offensive rationales are used to create controlled training or diagnostic variants in which key offensive spans may be masked, removed, or neutralised. This allows the researcher to examine whether the model:
depends only on explicit offensive tokens;
uses broader contextual patterns;
remains robust when rationale-bearing terms are masked;
produces explanations aligned with annotated semantic triggers.
This makes the model useful not only for classification, but also for forensic explainability analysis.
Research Motivation
Offensive-language detection in Setswana presents challenges that are not fully addressed by ordinary sentence-level classification. Offensive meaning may be expressed through:
culturally specific insults,
idiomatic expressions,
indirect accusations,
threats,
phishing-related cues,
sarcasm,
dehumanising metaphors,
and code-switched or non-standard orthography.
In small low-resource datasets, a model may overfit to obvious abusive terms while failing to capture broader discourse structures. MRP is introduced to investigate whether rationale masking can reveal or reduce such dependency.
The central research question is:
Can rationale-aware masking improve the interpretability and robustness of Setswana offensive-language detection while preserving useful classification performance?
Intended Use
This model is intended for:
Setswana offensive-language detection research;
cyberbullying and harassment detection experiments;
digital forensic triage support;
explainable AI experiments;
LIME and S-LIME attribution analysis;
masked rationale and counterfactual evaluation;
benchmarking rationale-aware transformer models for low-resource languages.
It may be useful in research workflows where the goal is to analyse both:
what the model predicts, and
why the model predicts it.
Out-of-Scope Use
This model should not be used for:
fully automated legal decision-making;
disciplinary action without human review;
automated criminal attribution;
autonomous social media moderation;
profiling individuals or communities;
deployment on non-Setswana text without validation.
The model is intended to support research and forensic triage, not replace human interpretation.
Dataset Description
The model is based on a manually curated Setswana offensive-language corpus containing offensive and non-offensive examples.
The dataset follows a simple CSV structure compatible with common offensive-language NLP datasets such as OLID and HateCheck:
TEXT,TARGET
Where:
Column
Description
TEXT
Setswana sentence or comment
TARGET
Class label: Offensive or Non-offensive
The broader corpus contains approximately:
Class
Count
Non-offensive
500
Offensive
477
Total
977
If using the public merged release, verify the exact row count in the dataset card and release notes, as sanitised or release-ready versions may differ slightly from the internal experimental corpus.
Rationale and Trigger Annotation
During dataset preparation, semantically important offensive spans were annotated as rationales or trigger regions.
These rationales may include:
direct insults;
vulgar expressions;
harassment phrases;
threat expressions;
phishing or scam cues;
dehumanising metaphors;
culturally grounded abusive expressions.
Example rationale-style annotation:
O tshwanetse go tlogela <TRIGGER>boaka</TRIGGER>
For MRP experiments, such spans can be converted into masked variants, for example:
O tshwanetse go tlogela <MASK>
or neutralised variants, depending on the experiment design.
Evaluation Setting
A key principle of this work is that the model should be assessed under realistic conditions.
Therefore, final evaluation should be performed on:
tag-free text,
unmasked ordinary inputs,
and a held-out test set not used during training or tuning.
This avoids giving the model artificial markup during deployment-like testing.
The evaluation protocol follows:
80/20 train-test split;
5-fold stratified cross-validation on the training partition;
final evaluation on the untouched holdout test set;
tag-free inference during final testing;
rationale-aware analysis through masking and counterfactual evaluation.
Model Architecture
Component
Details
Base model
PuoBERTa
Architecture family
RoBERTa
Task
Sequence classification
Language
Setswana
ISO language code
tn
Number of labels
2
Framework
Hugging Face Transformers
Backend
PyTorch
Training Configuration
The model was fine-tuned using a transformer sequence-classification setup.
Typical configuration:
Parameter
Value
Maximum sequence length
128
Optimizer
AdamW
Learning rate
1e-5
Weight decay
0.01
Training batch size
16
Evaluation batch size
64
Loss function
Class-weighted cross-entropy
Class weights
[1.0, 2.0]
Model selection focus
Offensive-class recall
The offensive class was assigned a higher loss weight to reduce the risk of missing harmful instances.
MRP-Specific Training / Analysis Workflow
The MRP workflow may include the following steps:
Train or fine-tune the classifier on labelled Setswana text.
Use annotated semantic rationales to identify offensive spans.
Create masked-rationale variants of selected samples.
Evaluate prediction changes after masking.
Compare original and masked predictions.
Use LIME or S-LIME to inspect whether top-attributed tokens align with annotated rationales.
Analyse flip and non-flip cases to determine whether the model depends on explicit offensive tokens or broader contextual templates.
This workflow supports both predictive evaluation and forensic interpretability.
Test Set Results
Insert the final MRP test-set metrics below once confirmed.
If this model is linked to a manuscript, cite the corresponding paper as well:
bibtex
1@article{kekgathetse2025setswanaoffensive,
2 title={Developing Monolingual Setswana Datasets for Offensive Content Detection},
3 author={Kekgathetse, Bernerdict},
4 journal={To be updated},
5 year={2025}
6}
License
Please refer to the license specified in this repository.
Recommended licensing structure:
Code: MIT or Apache-2.0
Documentation: CC-BY 4.0
Dataset access: governed separately due to ethical considerations
Contact
For academic queries, reproducibility questions, or collaboration requests, please refer to the associated GitHub repository or manuscript contact details.
Model Card Notes
This model card describes the MRP version of the PuoBERTa offensive-content classifier. It should be updated with the exact final test metrics and repository links before public release.