roshana1s commited on
Commit
fb38522
Β·
verified Β·
1 Parent(s): d02eae4

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +34 -49
README.md CHANGED
@@ -23,7 +23,7 @@ library_name: transformers
23
 
24
  # Spam Message Classifier
25
 
26
- A state-of-the-art spam message classification model built on **RoBERTa-base** transformer architecture, achieving **99.94% accuracy** and **0.9982 F1-score** for spam detection with **perfect precision (100%)** for the test set. Developed as the core spam detection component for **Amy**, an intelligent Discord moderation bot.
27
 
28
  ## Model Description
29
 
@@ -39,7 +39,7 @@ This model is a fine-tuned version of FacebookAI/roberta-base for binary spam cl
39
  ## Key Features
40
 
41
  - **πŸ€– Transformer-based Architecture**: Built on RoBERTa-base for superior text understanding
42
- - **⚑ High Performance**: 0.9982 F1-score for spam detection, 99.94% overall accuracy
43
  - **πŸ”§ Hyperparameter Optimization**: Automated tuning using Optuna framework (25 trials)
44
  - **βš–οΈ Class Imbalance Handling**: Successfully addressed through weighted loss function
45
  - **πŸ”— URL Bias Mitigation**: Enhanced with real-world ham messages containing links
@@ -142,27 +142,14 @@ This spam classifier is ideal for:
142
  The model was trained on a combination of two comprehensive SMS spam datasets totaling **11,498 messages**:
143
 
144
  1. **[SMS Spam Collection Dataset](https://www.kaggle.com/datasets/uciml/sms-spam-collection-dataset)** - UCI Machine Learning Repository
145
- 2. **[SMS Phishing Dataset](https://data.mendeley.com/datasets/f45bkkt8pr/1)** - Sandhya Mishra & Devpriya Soni (2022)
146
-
147
- **Dataset Statistics**:
148
- - Total Messages: 11,498
149
- - Ham Messages: 9,669 (84.1%)
150
- - Spam Messages: 1,829 (15.9%)
151
- - Average Message Length: ~80 characters
152
- - Language: English
153
-
154
- **Dataset Split**:
155
- - Training Set: 70% (~8,048 messages)
156
- - Validation Set: 15% (~1,725 messages) - for hyperparameter tuning
157
- - Test Set: 15% (~1,725 messages) - completely unseen data for final evaluation
158
-
159
- **Preprocessing**:
160
- 1. Label encoding (ham β†’ 0, spam/smishing β†’ 1)
161
  2. Text cleaning and normalization with Discord-specific preprocessing
162
- 3. Dataset merging and deduplication
163
- 4. Train/validation/test split (70/15/15)
164
- 5. Tokenization with RoBERTa tokenizer
165
- 6. Dynamic padding and truncation (max length = 128)
166
 
167
  ## Training Procedure
168
 
@@ -179,15 +166,15 @@ Automated hyperparameter search using **Optuna framework** (25 trials):
179
  - Training epochs: 2 to 5 epochs
180
  - Warmup ratio: 0.05 to 0.1 for learning rate scheduling
181
 
182
- **Best Parameters Found (Trial 17/25)**:
183
- - hidden_dropout: 0.161
184
- - attention_dropout: 0.116
185
- - learning_rate: 1.67e-05
186
- - weight_decay: 0.0235
187
- - batch_size: 16
188
- - gradient_accumulation_steps: 3
189
- - epochs: 4
190
- - warmup_ratio: 0.0502
191
 
192
  ### Training Strategy
193
 
@@ -210,33 +197,31 @@ Automated hyperparameter search using **Optuna framework** (25 trials):
210
 
211
  | Metric | Score |
212
  |--------|-------|
213
- | **Overall Accuracy** | **99.94%** |
214
- | **Weighted F1-Score** | **0.9994** |
215
- | **Spam F1-Score** | **0.9982** βœ… |
216
- | **Spam Precision** | **100.00%** (Perfect) |
217
- | **Spam Recall** | **99.64%** |
218
- | **Ham Precision** | **99.93%** |
219
- | **Ham Recall** | **100.00%** |
220
 
221
  ### Confusion Matrix
222
 
223
  | | Predicted Ham | Predicted Spam |
224
  |---------------|---------------|----------------|
225
- | **Actual Ham** | 1,456 | 0 |
226
- | **Actual Spam** | 1 | 274 |
227
 
228
  ### Performance Analysis
229
 
230
- - **True Positives**: 274 spam messages correctly identified
231
- - **True Negatives**: 1,456 ham messages correctly identified
232
- - **False Positives**: 0 (Perfect - no legitimate messages flagged)
233
- - **False Negatives**: 1 (Only 1 spam message missed)
234
- - **False Positive Rate**: 0.00%
235
- - **Miss Rate**: 0.36%
236
 
237
  ### Generalizability
238
 
239
- > πŸ“Š **Strong Generalization**: All performance metrics are evaluated on a **completely unseen test set** (15% of data, ~1,725 messages) that was never used during training or hyperparameter tuning, ensuring robust real-world performance and preventing overfitting.
240
 
241
  ## Challenges Addressed & Solutions
242
 
@@ -248,7 +233,7 @@ Automated hyperparameter search using **Optuna framework** (25 trials):
248
 
249
  ### βœ… Class Imbalance Handling (SUCCESSFULLY ADDRESSED)
250
 
251
- **Challenge**: The combined dataset exhibits natural imbalance (84.1% ham, 15.9% spam).
252
 
253
  **Solution**: Implemented weighted loss function during training to handle the imbalanced dataset effectively, resulting in exceptional performance for both classes.
254
 
@@ -256,7 +241,7 @@ Automated hyperparameter search using **Optuna framework** (25 trials):
256
 
257
  **Challenge**: Ensuring model generalizes well to unseen data.
258
 
259
- **Solution**: Comprehensive evaluation on completely held-out test set (15% of data) never used during training or hyperparameter tuning, with demonstrated strong generalization (99.94% accuracy on unseen data).
260
 
261
  ## Limitations
262
 
 
23
 
24
  # Spam Message Classifier
25
 
26
+ A state-of-the-art spam message classification model built on **RoBERTa-base** transformer architecture, achieving **99.42% accuracy** and **0.9782 F1-score for spam class** for the test set. Developed as the core spam detection component for **Amy**, an intelligent Discord moderation bot.
27
 
28
  ## Model Description
29
 
 
39
  ## Key Features
40
 
41
  - **πŸ€– Transformer-based Architecture**: Built on RoBERTa-base for superior text understanding
42
+ - **⚑ High Performance**: 0.9782 F1-score for spam detection, 99.42% overall accuracy
43
  - **πŸ”§ Hyperparameter Optimization**: Automated tuning using Optuna framework (25 trials)
44
  - **βš–οΈ Class Imbalance Handling**: Successfully addressed through weighted loss function
45
  - **πŸ”— URL Bias Mitigation**: Enhanced with real-world ham messages containing links
 
142
  The model was trained on a combination of two comprehensive SMS spam datasets totaling **11,498 messages**:
143
 
144
  1. **[SMS Spam Collection Dataset](https://www.kaggle.com/datasets/uciml/sms-spam-collection-dataset)** - UCI Machine Learning Repository
145
+ 2. **Discord Text Messages** β€” a manually collected dataset of real Discord messages containing both ham and spam samples. (This dataset was created to mitigate `<URL>` bias.)
146
+
147
+ **Preprocessing Steps**:
148
+ 1. Label encoding (ham β†’ 0, spam β†’ 1)
 
 
 
 
 
 
 
 
 
 
 
 
149
  2. Text cleaning and normalization with Discord-specific preprocessing
150
+ 3. Train/validation/test split (70/15/15)
151
+ 4. Tokenization with RoBERTa tokenizer
152
+ 5. Dynamic padding and truncation
 
153
 
154
  ## Training Procedure
155
 
 
166
  - Training epochs: 2 to 5 epochs
167
  - Warmup ratio: 0.05 to 0.1 for learning rate scheduling
168
 
169
+ **Best Parameters Found (Trial 6/25)**:
170
+ - Hidden dropout: 0.10069482002001506
171
+ - Attention dropout: 0.12460257350587067
172
+ - Learning rate: 4.976184540342024e-05
173
+ - Weight decay: 0.04490021845024478
174
+ - Batch size: 16
175
+ - Gradient accumulation steps: 4
176
+ - Epochs: 4
177
+ - Warmup ratio: 0.07622459860163384
178
 
179
  ### Training Strategy
180
 
 
197
 
198
  | Metric | Score |
199
  |--------|-------|
200
+ | **Overall Accuracy** | **99.41%** |
201
+ | **Weighted F1-Score** | **0.9941** |
202
+ | **Spam F1-Score** | **0.9782** |
203
+ | **Spam Precision** | **96.55%** |
204
+ | **Spam Recall** | **99.12%** |
205
+ | **Ham Precision** | **99.86%** |
206
+ | **Ham Recall** | **99.45%** |
207
 
208
  ### Confusion Matrix
209
 
210
  | | Predicted Ham | Predicted Spam |
211
  |---------------|---------------|----------------|
212
+ | **Actual Ham** | 725 | 4 |
213
+ | **Actual Spam** | 1 | 112 |
214
 
215
  ### Performance Analysis
216
 
217
+ - **True Positives**: 112 spam messages correctly identified
218
+ - **True Negatives**: 725 ham messages correctly identified
219
+ - **False Positives**: 4
220
+ - **False Negatives**: 1
 
 
221
 
222
  ### Generalizability
223
 
224
+ > πŸ“Š **Strong Generalization**: All performance metrics are evaluated on a **completely unseen test set** (15% of data) that was never used during training or hyperparameter tuning, ensuring robust real-world performance and preventing overfitting.
225
 
226
  ## Challenges Addressed & Solutions
227
 
 
233
 
234
  ### βœ… Class Imbalance Handling (SUCCESSFULLY ADDRESSED)
235
 
236
+ **Challenge**: The combined dataset exhibits natural imbalance.
237
 
238
  **Solution**: Implemented weighted loss function during training to handle the imbalanced dataset effectively, resulting in exceptional performance for both classes.
239
 
 
241
 
242
  **Challenge**: Ensuring model generalizes well to unseen data.
243
 
244
+ **Solution**: Comprehensive evaluation on completely held-out test set (15% of data) never used during training or hyperparameter tuning, with demonstrated strong generalization (99.42% accuracy on unseen data).
245
 
246
  ## Limitations
247