Update README.md
Browse files
README.md
CHANGED
|
@@ -16,13 +16,11 @@ tags:
|
|
| 16 |
---
|
| 17 |
# **Toxic Comment Classification with Transformer Optimization**
|
| 18 |
This project demonstrates a high-performance pipeline for classifying toxic comments using a **binary classification** approach. The models were trained and evaluated using the **Jigsaw Toxic Comment Classification** dataset, specifically leveraging the domain-specific **Toxic-BERT** model as a primary architecture.
|
| 19 |
-
|
| 20 |
## **Project Overview**
|
| 21 |
* **Objective**: To build an efficient **binary toxicity classifier** using state-of-the-art NLP models.
|
| 22 |
* **Model Type**: Binary classification (Toxic vs. Non-Toxic).
|
| 23 |
* **Dataset**: Jigsaw Toxic Comment Classification Challenge.
|
| 24 |
* **Scope**: Includes data visualization, model benchmarking, and size reduction for deployment.
|
| 25 |
-
|
| 26 |
## **Technical Workflow**
|
| 27 |
### **1. Data Preprocessing & EDA**
|
| 28 |
* **Labeling**: Multi-label categories (toxic, severe_toxic, obscene, threat, insult, identity_hate) were condensed into a single **binary 'is_toxic' label**.
|
|
@@ -35,15 +33,11 @@ The project evaluated 15 different embedding sets across two categories:
|
|
| 35 |
* **Heavy Models**: Includes BERT, RoBERTa, DeBERTa, XLNet, and domain-specific models like **Toxic-BERT** and HateBERT.
|
| 36 |
### **3. Model Performance Results**
|
| 37 |
Models were evaluated using Logistic Regression (LR), Support Vector Machines (SVM), and Random Forest (RF)
|
| 38 |
-
|
| 39 |
-
---
|
| 40 |
| Embedding | LR_AUC | LinearSVM_ACC | RBF_AUC | RF_ACC |
|
| 41 |
| :--- | :--- | :--- | :--- | :--- |
|
| 42 |
| **Toxic-BERT_transformer_emb** | 0.997022 | 0.979531 | 0.991532 | 0.979375 |
|
| 43 |
| **HateBERT_transformer_emb** | 0.967701 | 0.901875 | 0.965530 | 0.852344 |
|
| 44 |
| **DistilBERT_transformer_emb** | 0.967614 | 0.898906 | 0.967362 | 0.878125 |
|
| 45 |
-
---
|
| 46 |
-
|
| 47 |
## **Optimization Techniques**
|
| 48 |
### **4. Dynamic Quantization**
|
| 49 |
To optimize the teacher model (Toxic-BERT) for CPU inference, dynamic quantization was applied to convert weights from FP32 to INT8.
|
|
@@ -54,7 +48,6 @@ A smaller student model (**DistilBERT**) was trained to mimic the behavior of th
|
|
| 54 |
* **Loss Function**: A custom **Binary Knowledge Distillation** loss was used, combining Kullback-Leibler (KL) divergence for soft teacher probabilities and Cross-Entropy for hard labels.
|
| 55 |
* **Student Performance**: Reached a **Validation AUC of 0.9866** after 5 training epochs.
|
| 56 |
* **Final Footprint**: The student model is **267.86 MB**, significantly more portable than the original **438.03 MB** teacher model.
|
| 57 |
-
|
| 58 |
## **Requirements**
|
| 59 |
* `torch`
|
| 60 |
* `transformers`
|
|
|
|
| 16 |
---
|
| 17 |
# **Toxic Comment Classification with Transformer Optimization**
|
| 18 |
This project demonstrates a high-performance pipeline for classifying toxic comments using a **binary classification** approach. The models were trained and evaluated using the **Jigsaw Toxic Comment Classification** dataset, specifically leveraging the domain-specific **Toxic-BERT** model as a primary architecture.
|
|
|
|
| 19 |
## **Project Overview**
|
| 20 |
* **Objective**: To build an efficient **binary toxicity classifier** using state-of-the-art NLP models.
|
| 21 |
* **Model Type**: Binary classification (Toxic vs. Non-Toxic).
|
| 22 |
* **Dataset**: Jigsaw Toxic Comment Classification Challenge.
|
| 23 |
* **Scope**: Includes data visualization, model benchmarking, and size reduction for deployment.
|
|
|
|
| 24 |
## **Technical Workflow**
|
| 25 |
### **1. Data Preprocessing & EDA**
|
| 26 |
* **Labeling**: Multi-label categories (toxic, severe_toxic, obscene, threat, insult, identity_hate) were condensed into a single **binary 'is_toxic' label**.
|
|
|
|
| 33 |
* **Heavy Models**: Includes BERT, RoBERTa, DeBERTa, XLNet, and domain-specific models like **Toxic-BERT** and HateBERT.
|
| 34 |
### **3. Model Performance Results**
|
| 35 |
Models were evaluated using Logistic Regression (LR), Support Vector Machines (SVM), and Random Forest (RF)
|
|
|
|
|
|
|
| 36 |
| Embedding | LR_AUC | LinearSVM_ACC | RBF_AUC | RF_ACC |
|
| 37 |
| :--- | :--- | :--- | :--- | :--- |
|
| 38 |
| **Toxic-BERT_transformer_emb** | 0.997022 | 0.979531 | 0.991532 | 0.979375 |
|
| 39 |
| **HateBERT_transformer_emb** | 0.967701 | 0.901875 | 0.965530 | 0.852344 |
|
| 40 |
| **DistilBERT_transformer_emb** | 0.967614 | 0.898906 | 0.967362 | 0.878125 |
|
|
|
|
|
|
|
| 41 |
## **Optimization Techniques**
|
| 42 |
### **4. Dynamic Quantization**
|
| 43 |
To optimize the teacher model (Toxic-BERT) for CPU inference, dynamic quantization was applied to convert weights from FP32 to INT8.
|
|
|
|
| 48 |
* **Loss Function**: A custom **Binary Knowledge Distillation** loss was used, combining Kullback-Leibler (KL) divergence for soft teacher probabilities and Cross-Entropy for hard labels.
|
| 49 |
* **Student Performance**: Reached a **Validation AUC of 0.9866** after 5 training epochs.
|
| 50 |
* **Final Footprint**: The student model is **267.86 MB**, significantly more portable than the original **438.03 MB** teacher model.
|
|
|
|
| 51 |
## **Requirements**
|
| 52 |
* `torch`
|
| 53 |
* `transformers`
|