stanfordnlp/imdb
Viewer • Updated • 100k • 271k • 380
This model is a fine-tuned version of bert-base-uncased on the IMDB movie reviews dataset for sentiment analysis (binary classification). It can predict whether a movie review is positive or negative.
The model was trained with the following parameters:
This model is designed for:
Here's how to use the model with PyTorch:
from transformers import AutoModelForSequenceClassification, AutoTokenizer
import torch
# Load model and tokenizer
model = AutoModelForSequenceClassification.from_pretrained("xanderIV/finetuned-bert-imdb")
tokenizer = AutoTokenizer.from_pretrained("xanderIV/finetuned-bert-imdb")
# Prepare your text
texts = [
"This movie was fantastic! Great acting and amazing plot.",
"Terrible waste of time. Poor acting and confusing story."
]
# Tokenize the input
inputs = tokenizer(texts, return_tensors="pt", padding=True, truncation=True)
# Get predictions
with torch.no_grad():
outputs = model(**inputs)
predictions = torch.softmax(outputs.logits, dim=1)
labels = torch.argmax(predictions, dim=1)
# Process results
for text, pred, probs in zip(texts, labels, predictions):
sentiment = "positive" if pred.item() == 1 else "negative"
confidence = probs[pred].item() * 100
print(f"\nText: {text}")
print(f"Sentiment: {sentiment} (confidence: {confidence:.1f}%)")
Text: This movie was fantastic! Great acting and amazing plot.
Sentiment: positive (confidence: 97.7%)
Text: Terrible waste of time. Poor acting and confusing story.
Sentiment: negative (confidence: 98.4%)
The model was fine-tuned on a subset of the IMDB dataset:
The model achieved the following results on the test set:
This model may exhibit biases inherent to the IMDB dataset:
If you use this model, please cite:
@misc{finetuned-bert-imdb,
author = {xanderIV},
title = {BERT Fine-tuned for IMDB Sentiment Analysis},
year = {2025},
publisher = {Hugging Face},
journal = {Hugging Face Model Hub},
howpublished = {\url{https://huggingface.co/xanderIV/finetuned-bert-imdb}}
}