Instructions to use Aanoush/distilbert-imdb with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use Aanoush/distilbert-imdb with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-classification", model="Aanoush/distilbert-imdb")# pip install -U transformers accelerate # Load model directly from transformers import AutoTokenizer, AutoModelForSequenceClassification tokenizer = AutoTokenizer.from_pretrained("Aanoush/distilbert-imdb") model = AutoModelForSequenceClassification.from_pretrained("Aanoush/distilbert-imdb", device_map="auto") - Notebooks
- Google Colab
- Kaggle
- Model Card for DistilBERT IMDb Sentiment Classification
Model Card for DistilBERT IMDb Sentiment Classification
A DistilBERT model fine-tuned to classify English movie reviews as positive or negative. On a held-out subset of 1,000 IMDb test reviews, the model achieved 88.80% accuracy and 0.8878 macro F1.
Model Details
Model Description
This model adapts a pretrained DistilBERT encoder to binary sentiment classification through supervised fine-tuning using the Hugging Face Trainer API.
- Developed by: Aanoush
- Shared by: Aanoush
- Model type: Encoder-only Transformer for sequence classification
- Language(s) (NLP): English
- License: Not specified; applicable upstream model and dataset terms should be reviewed before reuse.
- Finetuned from model: distilbert/distilbert-base-uncased
Model Sources
- Repository: Aanoush/distilbert-imdb
- Paper (base model): DistilBERT, a distilled version of BERT: smaller, faster, cheaper and lighter
Uses
Direct Use
Binary sentiment analysis of English movie reviews. The model returns NEGATIVE (0) or POSITIVE (1), with a corresponding classification score.
Downstream Use
The model may be used in movie-review analytics, educational NLP applications, or as a baseline for further domain-specific fine-tuning.
Out-of-Scope Use
The model is not designed for neutral or fine-grained sentiment, multilingual text, high-stakes decisions, or inferring a person's emotional or mental state. Performance on domains other than IMDb has not been established.
Bias, Risks, and Limitations
- Training uses only 4,000 labeled IMDb reviews.
- The model may inherit biases from its pretrained weights and training data; these have not been independently assessed.
- Sarcasm, mixed sentiment, ambiguous language and domain shifts may cause incorrect predictions.
- Reviews longer than 256 tokens are truncated in the documented preprocessing pipeline.
- Softmax scores have not been calibrated as measures of real-world reliability.
Recommendations
Evaluate the model on representative target-domain data before deployment. Use human review where incorrect classifications could have meaningful consequences. Do not interpret classification scores as guaranteed correctness.
How to Get Started with the Model
pip install transformers torch
from transformers import pipeline
classifier = pipeline(
"sentiment-analysis",
model="Aanoush/distilbert-imdb"
)
results = classifier(
["This movie was absolutely fantastic!",
"The plot was boring and predictable."],
truncation=True,
max_length=256
)
print(results)
Training Details
Training Data
The IMDb dataset contains labeled English movie reviews. A shuffled subset of 5,000 examples from its original training split was divided into training and validation sets. A separate subset of the original test split was retained for final evaluation.
| Split | Samples |
|---|---|
| Training | 4,000 |
| Validation | 1,000 |
| Testing | 1,000 |
Training Procedure
The pretrained encoder and newly initialized sequence-classification head were fine-tuned using supervised binary classification with cross-entropy loss and the Transformers Trainer API.
Preprocessing
- Pretrained DistilBERT tokenizer.
- Maximum sequence length of 256 tokens with truncation.
- Dynamic batch padding using
DataCollatorWithPadding. - Attention masks to distinguish real tokens from padding.
- Dataset shuffling and splitting with seed 42.
Training Hyperparameters
| Hyperparameter | Value |
|---|---|
| Learning rate | 2e-5 |
| Training batch size per device | 16 |
| Evaluation batch size per device | 16 |
| Epochs | 3 |
| Optimizer | AdamW |
| Weight decay | 0.01 |
| Evaluation and checkpoint strategy | Every epoch |
| Best checkpoint metric | Macro F1 |
| Training regime | FP16 mixed precision (configured) |
| Random seed | 42 |
The configuration above follows the guided training setup. The highest validation macro F1 was observed at epoch 2; the uploaded checkpoint identity has not been independently verified.
Speeds, Sizes, Times
- Training runtime: approximately 169.57 seconds (2.83 minutes).
- Reported training throughput: approximately 70.77 samples per second.
- Optimizer steps reported: 375.
Evaluation
Testing Data, Factors & Metrics
Testing Data
1,000 shuffled examples from the original held-out IMDb test split, separate from the training and validation examples.
Factors
Evaluation measures aggregate performance across positive and negative movie reviews. No subgroup, review-length, demographic or cross-domain evaluation has been reported.
Metrics
- Accuracy: Fraction of correctly classified reviews.
- Macro F1: Unweighted mean of the F1 scores for the two sentiment classes.
- Loss: Cross-entropy loss on the evaluation dataset.
Results
Validation Results
| Epoch | Training Loss | Validation Loss | Accuracy | Macro F1 |
|---|---|---|---|---|
| 1 | 0.675112 | 0.673571 | 84.50% | 0.844259 |
| 2 | 0.478004 | 0.583343 | 89.10% | 0.890881 |
| 3 | 0.299970 | 0.650757 | 87.80% | 0.877982 |
Test Results
| Metric | Value |
|---|---|
| Accuracy | 88.80% |
| Macro F1 | 0.887838 |
| Test loss | 0.560351 |
Summary
Epoch 2 achieved the strongest validation performance. At epoch 3, training loss continued to fall while validation loss increased and validation accuracy declined, suggesting the onset of overfitting. The reported test accuracy is 0.30 percentage points below the best validation accuracy. These results are limited to the sampled IMDb data and do not establish generalization to other domains.
Model Examination
No formal interpretability, calibration or subgroup error analysis has been conducted.
Environmental Impact
Carbon emissions can be estimated using the Machine Learning Impact calculator presented in Lacoste et al. (2019).
- Hardware Type: CUDA-enabled GPU; exact GPU model not recorded here.
- Hours used: Approximately 0.047 hours for the reported training run only; total session usage is unknown.
- Cloud Provider: Kaggle Notebooks
- Compute Region: Not recorded
- Carbon Emitted: Not measured
Technical Specifications
Model Architecture and Objective
| Component | Specification |
|---|---|
| Architecture | DistilBertForSequenceClassification |
| Transformer layers | 6 |
| Hidden size | 768 |
| Attention heads | 12 |
| Output classes | 2 |
| Fine-tuning objective | Supervised cross-entropy loss |
The pretrained encoder produces contextual token representations. The classification head uses the first token representation to produce two sentiment logits.
Compute Infrastructure
Hardware
GPU-accelerated Kaggle notebook environment. Exact GPU type and count have not been verified.
Software
Python, PyTorch, Hugging Face Transformers, Datasets, Evaluate and Accelerate. Exact package versions were not recorded in this card.
Citation
No separate paper has been published for this fine-tuned model. The original DistilBERT paper is cited below.
BibTeX:
@article{sanh2019distilbert,
title={DistilBERT, a distilled version of BERT: smaller, faster, cheaper and lighter},
author={Sanh, Victor and Debut, Lysandre and Chaumond, Julien and Wolf, Thomas},
journal={arXiv preprint arXiv:1910.01108},
year={2019}
}
APA: Sanh, V., Debut, L., Chaumond, J., & Wolf, T. (2019). DistilBERT, a distilled version of BERT: smaller, faster, cheaper and lighter. arXiv. https://arxiv.org/abs/1910.01108
Glossary
- Fine-tuning: Adapting pretrained model weights to a downstream task.
- Macro F1: Arithmetic mean of the per-class F1 scores.
- Dynamic padding: Padding examples to the longest sequence in each batch.
More Information
This model was developed as a hands-on educational project for learning the Hugging Face fine-tuning and model publishing workflow.
Model Card Authors
Aanoush
Model Card Contact
- Downloads last month
- 11
Model tree for Aanoush/distilbert-imdb
Base model
distilbert/distilbert-base-uncased