YAML Metadata Warning:empty or missing yaml metadata in repo card

Check out the documentation for more information.

BERT Fine-Tuned for IMDB Sentiment Classification

Model Description

This model is fine-tuned from bert-base-uncased to classify movie reviews as Positive or Negative.

It uses the IMDB movie review dataset and is designed to predict the sentiment expressed in a review.

Model Details:

  • Base Model: bert-base-uncased

  • Task: Text Classification / Sentiment Analysis

  • Dataset: Stanford IMDB Dataset

  • Number of Classes: 2

  • Labels: Negative (0), Positive (1)

  • Framework: PyTorch, Hugging Face Transformers

This model can be used for:

  • Classifying movie reviews by sentiment.

  • Practicing transfer learning and BERT fine-tuning.

  • Exploring NLP text classification tasks.

How to Use:

Try My BERT Sentiment Analysis Model πŸ€—

Step 1: Install the required libraries

from transformers import pipeline

classifier = pipeline( "text-classification", model="krupaj/my-bert-imdb2" )

review = input("Enter a movie review: ") result = classifier(review)[0]

Convert model labels into readable sentiment names

label_mapping = { "LABEL_0": "NEGATIVE", "LABEL_1": "POSITIVE" }

sentiment = label_mapping.get(result["label"], result["label"])

print("\nMovie Review:", review) print("Predicted Sentiment:", sentiment) print("Confidence Score:", round(result["score"] * 100, 2), "%")

Step 3: Enter your own movie review

# Try any movie review you like!

review = "This movie was absolutely fantastic!"

# Predict the sentiment
result = classifier(review)

# Display the result
print("Movie Review:", review)
print("Prediction:", result[0]["label"])
print("Confidence Score:", round(result[0]["score"] * 100, 2), "%")

Example output

Movie Review: This movie was absolutely fantastic!
Prediction: LABEL_1 (LABEL_0 β†’ NEGATIVE / LABEL_1 β†’ POSITIVE)
Confidence Score: 98.00%

Training Details

The model was fine-tuned using the IMDB dataset with the Hugging Face Transformers library.

Training configuration:

Epochs: 3

Learning Rate: 2e-5

Training Batch Size: 8

Maximum Sequence Length: 256 tokens

Optimizer: Hugging Face Trainer default for the installed configuration

The training setup used a training dataset, a validation dataset, and a separate test dataset.

Limitations:

  • Performance may vary on reviews that differ from the IMDB training data.

  • Sarcasm, mixed sentiment, and complex language may be challenging.

  • Prediction scores are model confidence scores, not guaranteed probabilities of correctness.

  • This model is intended for experimentation and educational use.

Downloads last month
26
Safetensors
Model size
0.1B params
Tensor type
F32
Β·
Inference Providers NEW
This model isn't deployed by any Inference Provider. πŸ™‹ Ask for provider support