Upload DistilBERT IMDB sentiment model and results
Browse files- .gitattributes +3 -0
- MODEL_CARD.md +34 -0
- README.md +73 -0
- best_model.pt +3 -0
- checkpoint_epoch_1.pt +3 -0
- checkpoint_epoch_2.pt +3 -0
- checkpoint_epoch_3.pt +3 -0
- config.json +1 -0
- confusion_matrix.png +0 -0
- final_results.json +14 -0
- model.safetensors +3 -0
- special_tokens_map.json +7 -0
- test_data.csv +3 -0
- tokenizer.json +0 -0
- tokenizer_config.json +56 -0
- train_data.csv +3 -0
- training_history.csv +4 -0
- training_history.png +3 -0
- vocab.txt +0 -0
.gitattributes
CHANGED
|
@@ -33,3 +33,6 @@ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
|
|
| 33 |
*.zip filter=lfs diff=lfs merge=lfs -text
|
| 34 |
*.zst filter=lfs diff=lfs merge=lfs -text
|
| 35 |
*tfevents* filter=lfs diff=lfs merge=lfs -text
|
|
|
|
|
|
|
|
|
|
|
|
| 33 |
*.zip filter=lfs diff=lfs merge=lfs -text
|
| 34 |
*.zst filter=lfs diff=lfs merge=lfs -text
|
| 35 |
*tfevents* filter=lfs diff=lfs merge=lfs -text
|
| 36 |
+
test_data.csv filter=lfs diff=lfs merge=lfs -text
|
| 37 |
+
train_data.csv filter=lfs diff=lfs merge=lfs -text
|
| 38 |
+
training_history.png filter=lfs diff=lfs merge=lfs -text
|
MODEL_CARD.md
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
|
| 2 |
+
# Sentiment Analysis Model Card
|
| 3 |
+
|
| 4 |
+
## Model Description
|
| 5 |
+
- **Base Model**: distilbert-base-uncased
|
| 6 |
+
- **Task**: Binary Sentiment Classification (Positive/Negative)
|
| 7 |
+
- **Dataset**: IMDB Movie Reviews
|
| 8 |
+
- **Training Samples**: 16,000
|
| 9 |
+
- **Validation Samples**: 4,000
|
| 10 |
+
- **Test Samples**: 5,000
|
| 11 |
+
|
| 12 |
+
## Performance
|
| 13 |
+
- **Test Accuracy**: 0.9460
|
| 14 |
+
- **Test F1 Score**: 0.9723
|
| 15 |
+
- **Best Validation Accuracy**: 0.9300
|
| 16 |
+
|
| 17 |
+
## Training Details
|
| 18 |
+
- **Epochs**: 3
|
| 19 |
+
- **Batch Size**: 16
|
| 20 |
+
- **Learning Rate**: 2e-05
|
| 21 |
+
- **Max Sequence Length**: 512
|
| 22 |
+
- **Optimizer**: AdamW with weight decay
|
| 23 |
+
- **Scheduler**: Linear with warmup
|
| 24 |
+
|
| 25 |
+
## Model Size
|
| 26 |
+
- **Total Parameters**: 66,955,010
|
| 27 |
+
- **Trainable Parameters**: 66,955,010
|
| 28 |
+
- **Frozen Parameters**: 0
|
| 29 |
+
|
| 30 |
+
## Explainability Features
|
| 31 |
+
- ✅ Attention weights available
|
| 32 |
+
- ✅ Hidden states available
|
| 33 |
+
- ✅ Compatible with LIME
|
| 34 |
+
- ✅ Compatible with Integrated Gradients
|
README.md
ADDED
|
@@ -0,0 +1,73 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
---
|
| 2 |
+
language: en
|
| 3 |
+
tags:
|
| 4 |
+
- sentiment-analysis
|
| 5 |
+
- imdb
|
| 6 |
+
- distilbert
|
| 7 |
+
- transformers
|
| 8 |
+
license: apache-2.0
|
| 9 |
+
datasets:
|
| 10 |
+
- imdb
|
| 11 |
+
---
|
| 12 |
+
|
| 13 |
+
# DistilBERT Sentiment Analysis Model
|
| 14 |
+
|
| 15 |
+
This model is a fine-tuned version of `distilbert-base-uncased` for binary sentiment classification on the IMDB movie reviews dataset.
|
| 16 |
+
|
| 17 |
+
## Model Details
|
| 18 |
+
|
| 19 |
+
### Model Description
|
| 20 |
+
- **Model type**: DistilBERT (transformer-based)
|
| 21 |
+
- **Task**: Binary sentiment classification (positive/negative)
|
| 22 |
+
- **Base Model**: `distilbert-base-uncased`
|
| 23 |
+
- **Language**: English
|
| 24 |
+
|
| 25 |
+
### Training Details
|
| 26 |
+
|
| 27 |
+
#### Training Data
|
| 28 |
+
- **Dataset**: IMDB Movie Reviews
|
| 29 |
+
- **Training Samples**: 16,000
|
| 30 |
+
- **Validation Samples**: 4,000
|
| 31 |
+
- **Test Samples**: 5,000
|
| 32 |
+
- **Class Distribution**: 50% positive, 50% negative
|
| 33 |
+
|
| 34 |
+
#### Training Procedure
|
| 35 |
+
- **Epochs**: 3
|
| 36 |
+
- **Batch Size**: 16
|
| 37 |
+
- **Learning Rate**: 2e-05
|
| 38 |
+
- **Max Sequence Length**: 512
|
| 39 |
+
- **Optimizer**: AdamW with weight decay (0.01)
|
| 40 |
+
- **Scheduler**: Linear with 10% warmup
|
| 41 |
+
|
| 42 |
+
#### Evaluation Results
|
| 43 |
+
- **Test Accuracy**: 0.9460
|
| 44 |
+
- **Test F1 Score**: 0.9723
|
| 45 |
+
- **Best Validation Accuracy**: 0.9300
|
| 46 |
+
- **Training Time**: ~6 minutes on Google Colab T4 GPU
|
| 47 |
+
|
| 48 |
+
## How to Use
|
| 49 |
+
|
| 50 |
+
### Direct Inference
|
| 51 |
+
```python
|
| 52 |
+
from transformers import AutoTokenizer, AutoModelForSequenceClassification
|
| 53 |
+
import torch
|
| 54 |
+
|
| 55 |
+
# Load model and tokenizer
|
| 56 |
+
model_name = "Hums003/distilbert-imdb-sentiment"
|
| 57 |
+
tokenizer = AutoTokenizer.from_pretrained(model_name)
|
| 58 |
+
model = AutoModelForSequenceClassification.from_pretrained(model_name)
|
| 59 |
+
|
| 60 |
+
# Prepare text
|
| 61 |
+
text = "This movie was absolutely fantastic! I loved every minute of it."
|
| 62 |
+
inputs = tokenizer(text, return_tensors="pt", truncation=True, max_length=512)
|
| 63 |
+
|
| 64 |
+
# Get predictions
|
| 65 |
+
with torch.no_grad():
|
| 66 |
+
outputs = model(**inputs)
|
| 67 |
+
predictions = torch.nn.functional.softmax(outputs.logits, dim=-1)
|
| 68 |
+
|
| 69 |
+
# Interpret results
|
| 70 |
+
sentiment = "positive" if predictions[0][1] > 0.5 else "negative"
|
| 71 |
+
confidence = predictions[0][1].item() if predictions[0][1] > 0.5 else predictions[0][0].item()
|
| 72 |
+
print(f"Sentiment: {sentiment} (confidence: {confidence:.2%})")
|
| 73 |
+
```
|
best_model.pt
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:4135587a3b2cced4cf24cb7bdfce6550319454e29e04b614d19f8d325a089c2b
|
| 3 |
+
size 267863289
|
checkpoint_epoch_1.pt
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:76c882db6516246e9cd39459a08ad8daa156ffa5a4de9f802fd48adce97aefe9
|
| 3 |
+
size 803596065
|
checkpoint_epoch_2.pt
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:0dae9ddc31cb82d31e98c08ff0e72e6c10391aef7b33dd2aa79f4bc9773e1700
|
| 3 |
+
size 803596065
|
checkpoint_epoch_3.pt
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:5199ce79842d687a18597bc7032834b14e12e2ce2d7972c85d14b5a7c43f9c55
|
| 3 |
+
size 803596065
|
config.json
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
{}
|
confusion_matrix.png
ADDED
|
final_results.json
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"test_accuracy": 0.946,
|
| 3 |
+
"test_f1": 0.9722507708119219,
|
| 4 |
+
"best_val_accuracy": 0.93,
|
| 5 |
+
"best_epoch": 3,
|
| 6 |
+
"total_parameters": 66955010,
|
| 7 |
+
"trainable_parameters": 66955010,
|
| 8 |
+
"training_samples": 16000,
|
| 9 |
+
"test_samples": 5000,
|
| 10 |
+
"epochs_trained": 3,
|
| 11 |
+
"batch_size": 16,
|
| 12 |
+
"learning_rate": 2e-05,
|
| 13 |
+
"max_length": 512
|
| 14 |
+
}
|
model.safetensors
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:bea2b246f5d9f7b9a685301de1e7c67118d91662dc5f5bb7b02f3f3075cbba86
|
| 3 |
+
size 267832560
|
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 |
+
}
|
test_data.csv
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:c184d0f5f855a6637056dbff925779497b31363bc2b63e05c98228b94db91cb6
|
| 3 |
+
size 32308848
|
tokenizer.json
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|
tokenizer_config.json
ADDED
|
@@ -0,0 +1,56 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 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": false,
|
| 45 |
+
"cls_token": "[CLS]",
|
| 46 |
+
"do_lower_case": true,
|
| 47 |
+
"extra_special_tokens": {},
|
| 48 |
+
"mask_token": "[MASK]",
|
| 49 |
+
"model_max_length": 512,
|
| 50 |
+
"pad_token": "[PAD]",
|
| 51 |
+
"sep_token": "[SEP]",
|
| 52 |
+
"strip_accents": null,
|
| 53 |
+
"tokenize_chinese_chars": true,
|
| 54 |
+
"tokenizer_class": "DistilBertTokenizer",
|
| 55 |
+
"unk_token": "[UNK]"
|
| 56 |
+
}
|
train_data.csv
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:0ba8ebadc77f655877928edf3fcd58f4c69b0f7ffe54ac3a377322d5c44e6927
|
| 3 |
+
size 33226811
|
training_history.csv
ADDED
|
@@ -0,0 +1,4 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
epoch,train_loss,val_loss,val_accuracy,val_f1
|
| 2 |
+
1,0.3066180157214403,0.21175865678861738,0.92525,0.9249337617530204
|
| 3 |
+
2,0.15920162493363021,0.2598572481777519,0.91825,0.9188085103584
|
| 4 |
+
3,0.08946884938236326,0.2924477435983717,0.93,0.9299135622176197
|
training_history.png
ADDED
|
Git LFS Details
|
vocab.txt
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|