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

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
Safetensors
Model size
67M params
Tensor type
F32
ยท
Inference Providers NEW
This model isn't deployed by any Inference Provider. ๐Ÿ™‹ Ask for provider support

Model tree for SagarFadatare00/distilbert-imdb-sentiment

Finetuned
(12785)
this model

Dataset used to train SagarFadatare00/distilbert-imdb-sentiment