Add model card
Browse files
README.md
ADDED
|
@@ -0,0 +1,101 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
---
|
| 2 |
+
language:
|
| 3 |
+
- en
|
| 4 |
+
- hi
|
| 5 |
+
- ta
|
| 6 |
+
license: apache-2.0
|
| 7 |
+
tags:
|
| 8 |
+
- toxicity-detection
|
| 9 |
+
- multilingual
|
| 10 |
+
- indicbert
|
| 11 |
+
- text-classification
|
| 12 |
+
- content-moderation
|
| 13 |
+
datasets:
|
| 14 |
+
- custom
|
| 15 |
+
metrics:
|
| 16 |
+
- accuracy
|
| 17 |
+
- f1
|
| 18 |
+
widget:
|
| 19 |
+
- text: "You are kind and helpful"
|
| 20 |
+
- text: "Fuck you"
|
| 21 |
+
- text: "Bahut accha kiya yaar"
|
| 22 |
+
- text: "Bhenchod"
|
| 23 |
+
---
|
| 24 |
+
|
| 25 |
+
# IndicBERT Multilingual Toxicity Detector
|
| 26 |
+
|
| 27 |
+
Fine-tuned version of [ai4bharat/IndicBERTv2-MLM-only](https://huggingface.co/ai4bharat/IndicBERTv2-MLM-only) for toxicity detection in multilingual text (English, Hinglish, Hindi, Tamil).
|
| 28 |
+
|
| 29 |
+
## Model Description
|
| 30 |
+
|
| 31 |
+
This model classifies text as either **toxic** or **non-toxic**. It was trained on a balanced dataset with class weights to handle imbalanced data.
|
| 32 |
+
|
| 33 |
+
**Languages Supported:**
|
| 34 |
+
- English
|
| 35 |
+
- Hinglish (Hindi-English code-mixed)
|
| 36 |
+
- Hindi
|
| 37 |
+
- Tamil
|
| 38 |
+
|
| 39 |
+
## Training Details
|
| 40 |
+
|
| 41 |
+
- **Base Model:** ai4bharat/IndicBERTv2-MLM-only (278M parameters)
|
| 42 |
+
- **Training Data:** 569 samples (balanced: 53% non-toxic, 47% toxic)
|
| 43 |
+
- **Training Split:** 80/20 train/validation
|
| 44 |
+
- **Epochs:** 3
|
| 45 |
+
- **Batch Size:** 16
|
| 46 |
+
- **Learning Rate:** 2e-5
|
| 47 |
+
- **Class Weighting:** Applied to handle imbalance
|
| 48 |
+
|
| 49 |
+
## Usage
|
| 50 |
+
|
| 51 |
+
```python
|
| 52 |
+
from transformers import AutoTokenizer, AutoModelForSequenceClassification
|
| 53 |
+
import torch
|
| 54 |
+
|
| 55 |
+
# Load model and tokenizer
|
| 56 |
+
model = AutoModelForSequenceClassification.from_pretrained("indic-toxicity-detector")
|
| 57 |
+
tokenizer = AutoTokenizer.from_pretrained("indic-toxicity-detector")
|
| 58 |
+
|
| 59 |
+
# Predict
|
| 60 |
+
def predict_toxicity(text):
|
| 61 |
+
inputs = tokenizer(text, return_tensors="pt", truncation=True, max_length=128)
|
| 62 |
+
outputs = model(**inputs)
|
| 63 |
+
probabilities = torch.softmax(outputs.logits, dim=-1)
|
| 64 |
+
predicted_class = torch.argmax(probabilities, dim=-1).item()
|
| 65 |
+
confidence = probabilities[0][predicted_class].item()
|
| 66 |
+
|
| 67 |
+
label = model.config.id2label[predicted_class]
|
| 68 |
+
return {"label": label, "confidence": confidence}
|
| 69 |
+
|
| 70 |
+
# Example
|
| 71 |
+
result = predict_toxicity("You are amazing!")
|
| 72 |
+
print(result) # {'label': 'non-toxic', 'confidence': 0.95}
|
| 73 |
+
```
|
| 74 |
+
|
| 75 |
+
## Performance
|
| 76 |
+
|
| 77 |
+
- **Validation Accuracy:** See training_metrics.csv
|
| 78 |
+
- **F1 Score:** See training_metrics.csv
|
| 79 |
+
|
| 80 |
+
## Limitations
|
| 81 |
+
|
| 82 |
+
- Trained on limited dataset (569 samples)
|
| 83 |
+
- May not generalize well to all types of toxic content
|
| 84 |
+
- Performance varies across languages
|
| 85 |
+
- Code-mixed text performance depends on training data representation
|
| 86 |
+
|
| 87 |
+
## Citation
|
| 88 |
+
|
| 89 |
+
```bibtex
|
| 90 |
+
@misc{indic-toxicity-detector,
|
| 91 |
+
author = {Your Name},
|
| 92 |
+
title = {IndicBERT Multilingual Toxicity Detector},
|
| 93 |
+
year = {2025},
|
| 94 |
+
publisher = {Hugging Face},
|
| 95 |
+
url = {https://huggingface.co/indic-toxicity-detector}
|
| 96 |
+
}
|
| 97 |
+
```
|
| 98 |
+
|
| 99 |
+
## License
|
| 100 |
+
|
| 101 |
+
Apache 2.0
|