Update README.md
Browse files
README.md
CHANGED
@@ -1,199 +1,150 @@
|
|
1 |
---
|
2 |
library_name: transformers
|
3 |
-
tags:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
4 |
---
|
5 |
|
6 |
-
# Model Card for
|
7 |
-
|
8 |
-
<!-- Provide a quick summary of what the model is/does. -->
|
9 |
-
|
10 |
-
|
11 |
|
12 |
## Model Details
|
13 |
|
14 |
### Model Description
|
15 |
|
16 |
-
|
17 |
-
|
18 |
-
This is the model card of a 🤗 transformers model that has been pushed on the Hub. This model card has been automatically generated.
|
19 |
-
|
20 |
-
- **Developed by:** [More Information Needed]
|
21 |
-
- **Funded by [optional]:** [More Information Needed]
|
22 |
-
- **Shared by [optional]:** [More Information Needed]
|
23 |
-
- **Model type:** [More Information Needed]
|
24 |
-
- **Language(s) (NLP):** [More Information Needed]
|
25 |
-
- **License:** [More Information Needed]
|
26 |
-
- **Finetuned from model [optional]:** [More Information Needed]
|
27 |
|
28 |
-
|
|
|
|
|
|
|
29 |
|
30 |
-
|
31 |
-
|
32 |
-
- **
|
33 |
-
- **Paper [optional]:** [More Information Needed]
|
34 |
-
- **Demo [optional]:** [More Information Needed]
|
35 |
|
36 |
## Uses
|
37 |
|
38 |
-
<!-- Address questions around how the model is intended to be used, including the foreseeable users of the model and those affected by the model. -->
|
39 |
-
|
40 |
### Direct Use
|
|
|
|
|
41 |
|
42 |
-
|
43 |
-
|
44 |
-
[More Information Needed]
|
45 |
-
|
46 |
-
### Downstream Use [optional]
|
47 |
-
|
48 |
-
<!-- This section is for the model use when fine-tuned for a task, or when plugged into a larger ecosystem/app -->
|
49 |
-
|
50 |
-
[More Information Needed]
|
51 |
|
52 |
### Out-of-Scope Use
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
[More Information Needed]
|
57 |
|
58 |
## Bias, Risks, and Limitations
|
59 |
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
|
64 |
### Recommendations
|
|
|
|
|
65 |
|
66 |
-
|
67 |
|
68 |
-
|
|
|
|
|
69 |
|
70 |
-
|
|
|
|
|
71 |
|
72 |
-
|
|
|
|
|
|
|
|
|
|
|
73 |
|
74 |
-
|
|
|
|
|
|
|
75 |
|
76 |
## Training Details
|
77 |
|
78 |
### Training Data
|
79 |
-
|
80 |
-
|
81 |
-
|
82 |
-
[More Information Needed]
|
83 |
|
84 |
### Training Procedure
|
85 |
-
|
86 |
-
|
87 |
-
|
88 |
-
#### Preprocessing [optional]
|
89 |
-
|
90 |
-
[More Information Needed]
|
91 |
-
|
92 |
|
93 |
#### Training Hyperparameters
|
|
|
|
|
|
|
|
|
|
|
94 |
|
95 |
-
|
96 |
-
|
97 |
-
|
98 |
-
|
99 |
-
<!-- This section provides information about throughput, start/end time, checkpoint size if relevant, etc. -->
|
100 |
-
|
101 |
-
[More Information Needed]
|
102 |
|
103 |
## Evaluation
|
104 |
|
105 |
-
<!-- This section describes the evaluation protocols and provides the results. -->
|
106 |
-
|
107 |
### Testing Data, Factors & Metrics
|
108 |
-
|
109 |
#### Testing Data
|
110 |
-
|
111 |
-
<!-- This should link to a Dataset Card if possible. -->
|
112 |
-
|
113 |
-
[More Information Needed]
|
114 |
-
|
115 |
-
#### Factors
|
116 |
-
|
117 |
-
<!-- These are the things the evaluation is disaggregating by, e.g., subpopulations or domains. -->
|
118 |
-
|
119 |
-
[More Information Needed]
|
120 |
|
121 |
#### Metrics
|
|
|
|
|
|
|
|
|
|
|
122 |
|
123 |
-
|
124 |
-
|
125 |
-
[More Information Needed]
|
126 |
-
|
127 |
-
### Results
|
128 |
-
|
129 |
-
[More Information Needed]
|
130 |
-
|
131 |
-
#### Summary
|
132 |
-
|
133 |
-
|
134 |
-
|
135 |
-
## Model Examination [optional]
|
136 |
-
|
137 |
-
<!-- Relevant interpretability work for the model goes here -->
|
138 |
-
|
139 |
-
[More Information Needed]
|
140 |
|
141 |
## Environmental Impact
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
142 |
|
143 |
-
|
144 |
-
|
145 |
-
Carbon emissions can be estimated using the [Machine Learning Impact calculator](https://mlco2.github.io/impact#compute) presented in [Lacoste et al. (2019)](https://arxiv.org/abs/1910.09700).
|
146 |
-
|
147 |
-
- **Hardware Type:** [More Information Needed]
|
148 |
-
- **Hours used:** [More Information Needed]
|
149 |
-
- **Cloud Provider:** [More Information Needed]
|
150 |
-
- **Compute Region:** [More Information Needed]
|
151 |
-
- **Carbon Emitted:** [More Information Needed]
|
152 |
-
|
153 |
-
## Technical Specifications [optional]
|
154 |
-
|
155 |
-
### Model Architecture and Objective
|
156 |
-
|
157 |
-
[More Information Needed]
|
158 |
-
|
159 |
-
### Compute Infrastructure
|
160 |
-
|
161 |
-
[More Information Needed]
|
162 |
-
|
163 |
-
#### Hardware
|
164 |
-
|
165 |
-
[More Information Needed]
|
166 |
-
|
167 |
-
#### Software
|
168 |
-
|
169 |
-
[More Information Needed]
|
170 |
-
|
171 |
-
## Citation [optional]
|
172 |
-
|
173 |
-
<!-- If there is a paper or blog post introducing the model, the APA and Bibtex information for that should go in this section. -->
|
174 |
-
|
175 |
-
**BibTeX:**
|
176 |
-
|
177 |
-
[More Information Needed]
|
178 |
-
|
179 |
-
**APA:**
|
180 |
-
|
181 |
-
[More Information Needed]
|
182 |
-
|
183 |
-
## Glossary [optional]
|
184 |
-
|
185 |
-
<!-- If relevant, include terms and calculations in this section that can help readers understand the model or model card. -->
|
186 |
-
|
187 |
-
[More Information Needed]
|
188 |
-
|
189 |
-
## More Information [optional]
|
190 |
-
|
191 |
-
[More Information Needed]
|
192 |
-
|
193 |
-
## Model Card Authors [optional]
|
194 |
-
|
195 |
-
[More Information Needed]
|
196 |
-
|
197 |
-
## Model Card Contact
|
198 |
|
199 |
-
|
|
|
1 |
---
|
2 |
library_name: transformers
|
3 |
+
tags:
|
4 |
+
- sentiment-analysis
|
5 |
+
- imdb
|
6 |
+
- text-classification
|
7 |
+
- distilbert
|
8 |
+
license: apache-2.0
|
9 |
+
datasets:
|
10 |
+
- stanfordnlp/imdb
|
11 |
+
language:
|
12 |
+
- en
|
13 |
+
metrics:
|
14 |
+
- accuracy
|
15 |
+
- precision
|
16 |
+
- recall
|
17 |
+
- f1
|
18 |
+
base_model:
|
19 |
+
- distilbert/distilbert-base-uncased
|
20 |
+
pipeline_tag: text-classification
|
21 |
---
|
22 |
|
23 |
+
# Model Card for DistilBERT Fine-Tuned on IMDB Sentiment Analysis
|
|
|
|
|
|
|
|
|
24 |
|
25 |
## Model Details
|
26 |
|
27 |
### Model Description
|
28 |
|
29 |
+
This model is a fine-tuned version of `distilbert-base-uncased` on the **IMDB movie reviews dataset** for **binary sentiment classification** (positive vs. negative). The model has been trained to classify movie reviews into either **positive (1)** or **negative (0)** sentiments.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
30 |
|
31 |
+
- **Developed by:** Nikke Salonen
|
32 |
+
- **Finetuned from model:** `distilbert-base-uncased`
|
33 |
+
- **Language(s):** English
|
34 |
+
- **License:** Apache 2.0
|
35 |
|
36 |
+
### Model Sources
|
37 |
+
- **Repository:** https://huggingface.co/NikkeS/imdb-distilbert/
|
38 |
+
- **Dataset:** [IMDB Dataset](https://ai.stanford.edu/~amaas/data/sentiment/)
|
|
|
|
|
39 |
|
40 |
## Uses
|
41 |
|
|
|
|
|
42 |
### Direct Use
|
43 |
+
- Sentiment analysis of **English text reviews**.
|
44 |
+
- Can be used for **opinion mining** on movie reviews and similar datasets.
|
45 |
|
46 |
+
### Downstream Use
|
47 |
+
- Can be **fine-tuned further** for sentiment classification in other domains (e.g., product reviews, social media sentiment analysis).
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
48 |
|
49 |
### Out-of-Scope Use
|
50 |
+
- Not suitable for **languages other than English**.
|
51 |
+
- Not recommended for **high-stakes decision-making** without human oversight.
|
|
|
|
|
52 |
|
53 |
## Bias, Risks, and Limitations
|
54 |
|
55 |
+
- The model is **trained on IMDB reviews**, so it may **not generalize well** to other types of sentiment analysis tasks.
|
56 |
+
- May exhibit **biases present in the training data**.
|
57 |
+
- Sentiment classification **depends heavily on context**, and the model may misinterpret sarcasm or complex sentences.
|
58 |
|
59 |
### Recommendations
|
60 |
+
- Users should **evaluate the model** on their specific datasets before deploying in production.
|
61 |
+
- If biases are detected, consider **fine-tuning on a more diverse dataset**.
|
62 |
|
63 |
+
## How to Use the Model
|
64 |
|
65 |
+
```python
|
66 |
+
from transformers import AutoModelForSequenceClassification, AutoTokenizer
|
67 |
+
import torch
|
68 |
|
69 |
+
# Load the fine-tuned model from Hugging Face Hub
|
70 |
+
model = AutoModelForSequenceClassification.from_pretrained("your-hf-username/imdb-distilbert")
|
71 |
+
tokenizer = AutoTokenizer.from_pretrained("your-hf-username/imdb-distilbert")
|
72 |
|
73 |
+
def predict_sentiment(review):
|
74 |
+
inputs = tokenizer(review, return_tensors="pt", truncation=True, padding=True, max_length=256)
|
75 |
+
with torch.no_grad():
|
76 |
+
logits = model(**inputs).logits
|
77 |
+
prediction = torch.argmax(logits, dim=1).item()
|
78 |
+
return "Positive" if prediction == 1 else "Negative"
|
79 |
|
80 |
+
# Example Usage
|
81 |
+
print(predict_sentiment("This movie was absolutely fantastic!"))
|
82 |
+
print(predict_sentiment("The acting was terrible, and the story made no sense."))
|
83 |
+
```
|
84 |
|
85 |
## Training Details
|
86 |
|
87 |
### Training Data
|
88 |
+
- The model was fine-tuned on the **IMDB dataset** (50,000 labeled movie reviews).
|
89 |
+
- The dataset is **balanced** (25,000 positive and 25,000 negative reviews).
|
|
|
|
|
90 |
|
91 |
### Training Procedure
|
92 |
+
#### Preprocessing
|
93 |
+
- Tokenized using `distilbert-base-uncased` tokenizer.
|
94 |
+
- Applied **dynamic padding, truncation, and a max sequence length of 256**.
|
|
|
|
|
|
|
|
|
95 |
|
96 |
#### Training Hyperparameters
|
97 |
+
- **Learning rate:** `5e-5`
|
98 |
+
- **Batch size:** `16`
|
99 |
+
- **Epochs:** `2`
|
100 |
+
- **Optimizer:** AdamW
|
101 |
+
- **Loss Function:** Cross-Entropy Loss
|
102 |
|
103 |
+
#### Compute Infrastructure
|
104 |
+
- **Hardware:** Google Colab T4 GPU
|
105 |
+
- **Precision:** Mixed precision (`fp16=True` for efficiency)
|
|
|
|
|
|
|
|
|
106 |
|
107 |
## Evaluation
|
108 |
|
|
|
|
|
109 |
### Testing Data, Factors & Metrics
|
|
|
110 |
#### Testing Data
|
111 |
+
- The model was evaluated on a **10,000-sample test set** from the IMDB dataset.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
112 |
|
113 |
#### Metrics
|
114 |
+
- **Accuracy:** 92,4%
|
115 |
+
- **Precision, Recall, F1-score:**
|
116 |
+
- **Precision:** 92,4%
|
117 |
+
- **Recall:** 92.3%
|
118 |
+
- **F1-score:** 92.3%
|
119 |
|
120 |
+
## Model Examination
|
121 |
+
- The model performs well on **general sentiment classification** but may struggle with **sarcasm, irony, or very short reviews**.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
122 |
|
123 |
## Environmental Impact
|
124 |
+
- **Hardware Type:** Google Colab T4 GPU
|
125 |
+
- **Training Time:** ~1 hour
|
126 |
+
- **CO2 Emission Estimate:** [Use ML Impact Calculator](https://mlco2.github.io/impact#compute)
|
127 |
+
|
128 |
+
## Citation
|
129 |
+
If you use this model, please cite:
|
130 |
+
```bibtex
|
131 |
+
@article{salonen2025imdb-distilbert,
|
132 |
+
title={Fine-tuned DistilBERT for Sentiment Analysis on IMDB Reviews},
|
133 |
+
author={Nikke Salonen},
|
134 |
+
year={2025}
|
135 |
+
}
|
136 |
+
```
|
137 |
+
|
138 |
+
## More Information
|
139 |
+
- **Hugging Face Model Page:** https://huggingface.co/NikkeS/imdb-distilbert/.
|
140 |
+
- **Dataset:** [IMDB Dataset](https://ai.stanford.edu/~amaas/data/sentiment/)
|
141 |
+
|
142 |
+
## Model Card Authors
|
143 |
+
- [Nikke Salonen]
|
144 |
+
|
145 |
+
## Contact
|
146 |
+
For questions or issues, contact **[email protected]**.
|
147 |
|
148 |
+
---
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
149 |
|
150 |
+
This model card provides all necessary details, including **training info, evaluation results, and usage instructions**. Let me know if you'd like any modifications before uploading to **Hugging Face Hub**!
|