new-model-test / README.md
jupadev's picture
Create README.md
a15db85 verified
|
Raw History Blame Contribute Delete
3.96 kB
---
license: apache-2.0
language:
- en
base_model: distilbert/distilbert-base-uncased
datasets:
- stanfordnlp/imdb
pipeline_tag: text-classification
library_name: transformers
tags:
- sentiment-analysis
- text-classification
- distilbert
- imdb
metrics:
- accuracy
- f1
- precision
- recall
model-index:
- name: new-model-test
results:
- task:
type: text-classification
name: Sentiment Analysis
dataset:
name: IMDB
type: stanfordnlp/imdb
split: test
metrics:
- type: accuracy
value: 0.9111
name: Accuracy
- type: f1
value: 0.9121
name: F1
- type: precision
value: 0.9017
name: Precision
- type: recall
value: 0.9228
name: Recall
---
# DistilBERT fine-tuned on IMDB (sentiment analysis)
Binary sentiment classifier for **English movie reviews**. It is
[`distilbert-base-uncased`](https://huggingface.co/distilbert/distilbert-base-uncased)
fine-tuned on the [IMDB](https://huggingface.co/datasets/stanfordnlp/imdb) dataset,
and labels each review as `POSITIVE` or `NEGATIVE`.
## Results
Evaluated **once** on the full IMDB test split (25,000 reviews, balanced 50/50).
The checkpoint was selected on a separate validation set, never on test.
| Metric | Value |
|-----------|--------|
| Accuracy | 0.9111 |
| F1 | 0.9121 |
| Precision | 0.9017 |
| Recall | 0.9228 |
| Loss | 0.3414 |
The model predicts `POSITIVE` for 51.2% of test reviews (true rate: 50%), a slight
positive bias that shows up as recall being a bit higher than precision.
## Usage
```python
from transformers import pipeline
clf = pipeline("text-classification", model="jupadev/new-model-test")
clf("This movie was absolutely amazing, I loved every minute of it.")
# [{'label': 'POSITIVE', 'score': 0.99...}]
```
Label mapping: `0 → NEGATIVE`, `1 → POSITIVE`.
## Training data
- **Source:** `stanfordnlp/imdb`, `train` split (25,000 reviews).
- The split is stored sorted by label (all negatives first), so it was shuffled
(`seed=42`) before any subsetting.
- **Train / validation:** 90% / 10% stratified split of the train set
(~22,500 / ~2,500 reviews).
- **Test:** the official `test` split (25,000 reviews), used only for the final
evaluation.
## Training procedure
| Hyperparameter | Value |
|-----------------------|----------------------------------------|
| Base model | `distilbert-base-uncased` |
| Max sequence length | 256 tokens (longer reviews truncated) |
| Learning rate | 2e-5 |
| LR scheduler | linear, 10% warmup |
| Weight decay | 0.01 |
| Train batch size | 16 |
| Epochs | up to 3, early stopping (patience 1) |
| Best model selection | highest validation F1 |
| Precision | fp16 mixed precision |
| Padding | dynamic (`DataCollatorWithPadding`) |
| Seed | 42 |
| Hardware | 1× NVIDIA T4 (Google Colab) |
Trained with the Hugging Face `Trainer` API.
## Limitations
- **English only.** Performance on other languages will be poor.
- **Domain:** trained on movie reviews; expect lower accuracy on product reviews,
social media, support tickets or other domains.
- **Truncation:** only the first 256 tokens are used. Long reviews whose verdict
comes at the end can be misclassified.
- **Binary output:** there is no neutral class; mixed or ambivalent reviews are
forced into positive or negative.
- Sarcasm and irony remain common failure cases.
- Scores are model probabilities, not calibrated confidence. On errors the model
is often confidently wrong.
- May reflect biases present in IMDB reviews and in DistilBERT's pretraining data.