Saif-Siddique commited on
Commit
7423168
·
verified ·
1 Parent(s): b565555

Upload model - F1: 0.8502

Browse files
README.md ADDED
@@ -0,0 +1,114 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ language:
3
+ - bn
4
+ license: mit
5
+ tags:
6
+ - text-classification
7
+ - multi-label-classification
8
+ - bangla
9
+ - cyberbullying
10
+ - bert
11
+ - pytorch
12
+ datasets:
13
+ - custom
14
+ metrics:
15
+ - f1
16
+ - accuracy
17
+ pipeline_tag: text-classification
18
+ ---
19
+
20
+ # Bangla Cyberbullying Detection Model
21
+
22
+ This model is fine-tuned for multi-label classification to detect cyberbullying in Bangla text.
23
+
24
+ ## Model Details
25
+
26
+ - **Base Model:** sagorsarker/bangla-bert-base
27
+ - **Task:** Multi-label text classification
28
+ - **Labels:** bully, sexual, religious, threat, spam
29
+ - **Number of Labels:** 5
30
+ - **Classifier Hidden Size:** 256
31
+ - **Dropout:** 0.1
32
+
33
+ ## Usage
34
+
35
+ ### Installation
36
+
37
+ ```bash
38
+ pip install torch transformers
39
+ ```
40
+
41
+ ### Loading and Inference
42
+
43
+ ```python
44
+ from model import TransformerMultiLabelClassifier
45
+ from transformers import AutoTokenizer
46
+ import torch
47
+
48
+ # Load the model
49
+ model = TransformerMultiLabelClassifier.from_pretrained("path/to/saved/model")
50
+ tokenizer = AutoTokenizer.from_pretrained("path/to/saved/model")
51
+
52
+ # Prepare input
53
+ text = "আপনার বাংলা টেক্সট এখানে"
54
+ inputs = tokenizer(text, return_tensors="pt", truncation=True, padding=True, max_length=128)
55
+
56
+ # Get predictions
57
+ outputs = model.predict(inputs['input_ids'], inputs['attention_mask'])
58
+
59
+ probabilities = outputs['probabilities'][0]
60
+ predictions = outputs['predictions'][0]
61
+
62
+ labels = ['bully', 'sexual', 'religious', 'threat', 'spam']
63
+ for label, prob, pred in zip(labels, probabilities, predictions):
64
+ status = "✓ Detected" if pred else "✗ Not detected"
65
+ print(f"{label}: {prob:.4f} ({status})")
66
+ ```
67
+
68
+ ### Using with Pipeline (Alternative)
69
+
70
+ ```python
71
+ # For batch inference
72
+ texts = ["টেক্সট ১", "টেক্সট ২", "টেক্সট ৩"]
73
+ inputs = tokenizer(texts, return_tensors="pt", truncation=True, padding=True, max_length=128)
74
+ outputs = model.predict(inputs['input_ids'], inputs['attention_mask'])
75
+ ```
76
+
77
+ ## Labels
78
+
79
+ | Label | Description |
80
+ |-------|-------------|
81
+ | bully | General bullying content |
82
+ | sexual | Sexual harassment or inappropriate content |
83
+ | religious | Religious hate or discrimination |
84
+ | threat | Threatening content |
85
+ | spam | Spam or irrelevant content |
86
+
87
+ ## Training
88
+
89
+ This model was trained using:
90
+ - K-fold cross-validation with multi-label stratification
91
+ - AdamW optimizer with linear warmup
92
+ - Mixed precision training (AMP)
93
+ - Early stopping based on weighted F1 score
94
+
95
+ ## Citation
96
+
97
+ If you use this model, please cite:
98
+
99
+ ```bibtex
100
+ @misc{bangla-cyberbullying-detection,
101
+ author = {Your Name},
102
+ title = {Bangla Cyberbullying Detection Model},
103
+ year = {2024},
104
+ publisher = {HuggingFace},
105
+ url = {https://huggingface.co/your-username/your-model}
106
+ }
107
+ ```
108
+
109
+ ## Limitations
110
+
111
+ - Trained specifically on Bangla text
112
+ - Performance may vary on out-of-domain text
113
+ - Multi-label threshold of 0.5 used by default (can be adjusted)
114
+ - May not generalize well to code-mixed text (Bangla + English)
classifier_config.json ADDED
@@ -0,0 +1,17 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "base_model_name": "sagorsarker/bangla-bert-base",
3
+ "num_labels": 5,
4
+ "dropout": 0.1,
5
+ "classifier_hidden_size": 256,
6
+ "label_names": [
7
+ "bully",
8
+ "sexual",
9
+ "religious",
10
+ "threat",
11
+ "spam"
12
+ ],
13
+ "model_type": "transformer_multilabel_classifier",
14
+ "architectures": [
15
+ "TransformerMultiLabelClassifier"
16
+ ]
17
+ }
classifier_head.pt ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:05f087d49a597a4c142dd0cf37e899689272985359b8cce3bfcc3ece7a6afbef
3
+ size 794768
encoder/config.json ADDED
@@ -0,0 +1,24 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "architectures": [
3
+ "BertModel"
4
+ ],
5
+ "attention_probs_dropout_prob": 0.1,
6
+ "classifier_dropout": null,
7
+ "hidden_act": "gelu",
8
+ "hidden_dropout_prob": 0.1,
9
+ "hidden_size": 768,
10
+ "initializer_range": 0.02,
11
+ "intermediate_size": 3072,
12
+ "layer_norm_eps": 1e-12,
13
+ "max_position_embeddings": 512,
14
+ "model_type": "bert",
15
+ "num_attention_heads": 12,
16
+ "num_hidden_layers": 12,
17
+ "pad_token_id": 0,
18
+ "position_embedding_type": "absolute",
19
+ "torch_dtype": "float32",
20
+ "transformers_version": "4.53.3",
21
+ "type_vocab_size": 2,
22
+ "use_cache": true,
23
+ "vocab_size": 102025
24
+ }
encoder/model.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:7ad08faf84c223df62933df7a2275a1a17559388675b29079b2ea71a0b530856
3
+ size 657608552
pytorch_model.bin ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:1ff6ed3e1bed0f5ebe49a603408aba177a2ee6376d2053efba6687f9e121dc5c
3
+ size 658460790
special_tokens_map.json ADDED
@@ -0,0 +1,7 @@
 
 
 
 
 
 
 
 
1
+ {
2
+ "cls_token": "[CLS]",
3
+ "mask_token": "[MASK]",
4
+ "pad_token": "[PAD]",
5
+ "sep_token": "[SEP]",
6
+ "unk_token": "[UNK]"
7
+ }
tokenizer.json ADDED
The diff for this file is too large to render. See raw diff
 
tokenizer_config.json ADDED
@@ -0,0 +1,58 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "added_tokens_decoder": {
3
+ "0": {
4
+ "content": "[PAD]",
5
+ "lstrip": false,
6
+ "normalized": false,
7
+ "rstrip": false,
8
+ "single_word": false,
9
+ "special": true
10
+ },
11
+ "100": {
12
+ "content": "[UNK]",
13
+ "lstrip": false,
14
+ "normalized": false,
15
+ "rstrip": false,
16
+ "single_word": false,
17
+ "special": true
18
+ },
19
+ "101": {
20
+ "content": "[CLS]",
21
+ "lstrip": false,
22
+ "normalized": false,
23
+ "rstrip": false,
24
+ "single_word": false,
25
+ "special": true
26
+ },
27
+ "102": {
28
+ "content": "[SEP]",
29
+ "lstrip": false,
30
+ "normalized": false,
31
+ "rstrip": false,
32
+ "single_word": false,
33
+ "special": true
34
+ },
35
+ "103": {
36
+ "content": "[MASK]",
37
+ "lstrip": false,
38
+ "normalized": false,
39
+ "rstrip": false,
40
+ "single_word": false,
41
+ "special": true
42
+ }
43
+ },
44
+ "clean_up_tokenization_spaces": true,
45
+ "cls_token": "[CLS]",
46
+ "do_basic_tokenize": true,
47
+ "do_lower_case": true,
48
+ "extra_special_tokens": {},
49
+ "mask_token": "[MASK]",
50
+ "model_max_length": 1000000000000000019884624838656,
51
+ "never_split": null,
52
+ "pad_token": "[PAD]",
53
+ "sep_token": "[SEP]",
54
+ "strip_accents": null,
55
+ "tokenize_chinese_chars": true,
56
+ "tokenizer_class": "BertTokenizer",
57
+ "unk_token": "[UNK]"
58
+ }
training_config.json ADDED
@@ -0,0 +1,28 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "batch": 32,
3
+ "lr": 2e-05,
4
+ "epochs": 20,
5
+ "dataset_path": "/kaggle/working/finetuning_framework_for_cyberbullying/data/1_Multilablel_Cyberbully_Data.csv",
6
+ "model_path": "sagorsarker/bangla-bert-base",
7
+ "max_length": 128,
8
+ "num_folds": 5,
9
+ "freeze_base": false,
10
+ "seed": 42,
11
+ "stratification_type": "multilabel",
12
+ "author_name": "saif_siddique",
13
+ "mlflow_experiment_name": "Bangla-Cyberbullying-Detection",
14
+ "dropout": 0.1,
15
+ "weight_decay": 0.01,
16
+ "warmup_ratio": 0.1,
17
+ "gradient_clip_norm": 1.0,
18
+ "early_stopping_patience": 5,
19
+ "no_amp": false,
20
+ "no_cache": false,
21
+ "save_model_dir": "./saved_models",
22
+ "no_save_model": false,
23
+ "push_to_hub": true,
24
+ "hub_repo_name": "Saif-Siddique/bangla-cyberbully-sagor-bangla-bert-base",
25
+ "hub_private": false,
26
+ "output_dir": "./outputs",
27
+ "cache_dir": "./cache"
28
+ }
training_metrics.json ADDED
@@ -0,0 +1,23 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "accuracy": 0.7134316460741331,
3
+ "per_label_accuracy": 0.9321642088481467,
4
+ "hamming_loss": 0.06783579115185333,
5
+ "precision_weighted": 0.8444694079506561,
6
+ "recall_weighted": 0.8576449912126538,
7
+ "f1_weighted": 0.8501896616089782,
8
+ "precision_macro": 0.8203965353566014,
9
+ "recall_macro": 0.8277283024881914,
10
+ "f1_macro": 0.8226322889088447,
11
+ "loss": 0.25361040277005753,
12
+ "train_accuracy": 0.8971804324001196,
13
+ "train_per_label_accuracy": 0.9784198465676995,
14
+ "train_hamming_loss": 0.02158015343230049,
15
+ "train_precision_weighted": 0.9500541236360307,
16
+ "train_recall_weighted": 0.95634223471539,
17
+ "train_f1_weighted": 0.9526477489757674,
18
+ "train_precision_macro": 0.9379394400632052,
19
+ "train_recall_macro": 0.9760201529990115,
20
+ "train_f1_macro": 0.9561884089351944,
21
+ "train_loss": 0.07912977215400926,
22
+ "best_epoch": 11
23
+ }
vocab.txt ADDED
The diff for this file is too large to render. See raw diff