Instructions to use SagarFadatare00/distilbert-imdb-sentiment with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use SagarFadatare00/distilbert-imdb-sentiment with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-classification", model="SagarFadatare00/distilbert-imdb-sentiment")# pip install -U transformers accelerate # Load model directly from transformers import AutoTokenizer, AutoModelForSequenceClassification tokenizer = AutoTokenizer.from_pretrained("SagarFadatare00/distilbert-imdb-sentiment") model = AutoModelForSequenceClassification.from_pretrained("SagarFadatare00/distilbert-imdb-sentiment", device_map="auto") - Notebooks
- Google Colab
- Kaggle
DistilBERT IMDb Sentiment Analysis
A fine-tuned DistilBERT model for classifying movie reviews as positive or negative. This model was trained on the IMDb movie review dataset using Hugging Face Transformers and PyTorch.
Model Details
- Model architecture: DistilBERT
- Base model: distilbert/distilbert-base-uncased
- Task: Binary sentiment classification
- Dataset: IMDb Movie Reviews
- Framework: PyTorch
- Training approach: Fine-tuning a pretrained model
- Labels:
NEGATIVEandPOSITIVE
Example Predictions
| Input Text | Predicted Sentiment |
|---|---|
| This movie was absolutely fantastic! | POSITIVE |
| The acting was terrible and the story was boring. | NEGATIVE |
| I enjoyed every minute of this film. | POSITIVE |
Evaluation Results
The model was fine-tuned for one epoch using 5,000 training examples and evaluated on a selected subset of 1,000 IMDb test examples.
| Metric | Result |
|---|---|
| Accuracy | 86.8% |
| F1 Score | 87.0% |
| Evaluation Loss | 0.3307 |
These results reflect the selected evaluation subset and are not a benchmark for all sentiment-analysis tasks.
How to Use
Install the required libraries:
pip install torch transformers
Load the model directly from Hugging Face:
from transformers import pipeline
model_id = "SagarFadatare00/distilbert-imdb-sentiment"
classifier = pipeline(
"text-classification",
model=model_id,
)
texts = [
"This movie was absolutely fantastic!",
"The acting was terrible and the story was boring.",
]
for text in texts:
result = classifier(text)[0]
print("Text:", text)
print("Sentiment:", result["label"])
print("Confidence:", round(result["score"] * 100, 2), "%")
Training Configuration
- Learning rate:
2e-5 - Training batch size:
8 - Evaluation batch size:
8 - Number of epochs:
1 - Weight decay:
0.01 - Maximum token length:
256 - Training examples:
5,000 - Evaluation examples:
1,000
The training examples were selected from the IMDb training split, and the evaluation examples were selected from its test split using a fixed random seed.
Limitations
- The model was trained on movie reviews and may not perform equally well on social media posts, product reviews, or other domains.
- It predicts only positive or negative sentiment; it does not classify neutral sentiment as a separate category.
- Prediction confidence is not a guarantee of correctness.
- Performance may vary depending on the text, writing style, and domain.
Intended Use
This model is intended for educational purposes, experimentation, and sentiment-analysis applications. Evaluate it on your own data before using it in production.
Acknowledgments
Author
Sagar Fadatare
- Downloads last month
- 34
Model tree for SagarFadatare00/distilbert-imdb-sentiment
Base model
distilbert/distilbert-base-uncased