Create README.md
Browse files
README.md
ADDED
@@ -0,0 +1,72 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
---
|
2 |
+
language: en
|
3 |
+
tags:
|
4 |
+
- sentiment-analysis
|
5 |
+
- transformers
|
6 |
+
- pytorch
|
7 |
+
license: apache-2.0
|
8 |
+
datasets:
|
9 |
+
- custom-dataset
|
10 |
+
metrics:
|
11 |
+
- accuracy
|
12 |
+
model_name: distilbert-base-uncased-finetuned-sentiment
|
13 |
+
---
|
14 |
+
|
15 |
+
# DistilBERT Base Uncased Fine-tuned for Sentiment Analysis
|
16 |
+
|
17 |
+
## Model Description
|
18 |
+
|
19 |
+
This model is a fine-tuned version of `distilbert-base-uncased` on a sentiment analysis dataset. It is trained to classify text into positive and negative sentiment categories.
|
20 |
+
|
21 |
+
## Training Details
|
22 |
+
|
23 |
+
The model was fine-tuned on a sentiment analysis dataset using the Hugging Face `transformers` library. The training parameters are as follows:
|
24 |
+
|
25 |
+
- **Learning Rate**: 2e-5
|
26 |
+
- **Batch Size**: 32
|
27 |
+
- **Number of Epochs**: 4
|
28 |
+
- **Optimizer**: AdamW
|
29 |
+
- **Scheduler**: Linear with warmup
|
30 |
+
- **Device**: Nvidia T4 GPU
|
31 |
+
|
32 |
+
## Training and Validation Metrics
|
33 |
+
|
34 |
+
| Step | Training Loss | Validation Loss | Accuracy |
|
35 |
+
|------|---------------|-----------------|----------|
|
36 |
+
| 400 | 0.389300 | 0.181316 | 93.25% |
|
37 |
+
| 800 | 0.161900 | 0.166204 | 94.13% |
|
38 |
+
| 1200 | 0.114600 | 0.200135 | 94.30% |
|
39 |
+
| 1600 | 0.076300 | 0.211609 | 94.40% |
|
40 |
+
| 2000 | 0.041600 | 0.225439 | 94.45% |
|
41 |
+
|
42 |
+
Final training metrics:
|
43 |
+
|
44 |
+
- **Global Step**: 2000
|
45 |
+
- **Training Loss**: 0.156715
|
46 |
+
- **Training Runtime**: 1257.5696 seconds
|
47 |
+
- **Training Samples per Second**: 50.892
|
48 |
+
- **Training Steps per Second**: 1.59
|
49 |
+
- **Total FLOPS**: 8477913513984000.0
|
50 |
+
- **Epochs**: 4.0
|
51 |
+
|
52 |
+
## Model Performance
|
53 |
+
|
54 |
+
The model achieves an accuracy of approximately 94.45% on the validation set.
|
55 |
+
|
56 |
+
## Usage
|
57 |
+
|
58 |
+
To use this model for sentiment analysis, you can load it using the `transformers` library:
|
59 |
+
|
60 |
+
```python
|
61 |
+
from transformers import DistilBertTokenizerFast, DistilBertForSequenceClassification
|
62 |
+
|
63 |
+
model_name = 'luluw/distilbert-base-uncased-finetuned-sentiment'
|
64 |
+
tokenizer = DistilBertTokenizerFast.from_pretrained(model_name)
|
65 |
+
model = DistilBertForSequenceClassification.from_pretrained(model_name)
|
66 |
+
|
67 |
+
# Example usage
|
68 |
+
text = "I love this product!"
|
69 |
+
inputs = tokenizer(text, return_tensors='pt')
|
70 |
+
outputs = model(**inputs)
|
71 |
+
predictions = torch.argmax(outputs.logits, dim=-1)
|
72 |
+
```
|