BERT Sentiment Analysis πŸš€

This is a fine-tuned BERT model (bert-base-uncased) for sentiment analysis on the IMDb movie review dataset. The model classifies text into:

  • βœ… Positive
  • ❌ Negative

🧠 Model Details

  • Base Model: bert-base-uncased
  • Dataset: IMDb (via Hugging Face Datasets)
  • Classes: Binary classification (0: Positive, 1: Negative)
  • Framework: PyTorch
  • Training: Fine-tuned using Hugging Face Transformers and Datasets on GPU

πŸ“₯ How to Use

You can use this model directly with πŸ€— transformers:

from transformers import BertTokenizer, BertForSequenceClassification
import torch
import torch.nn.functional as F

model_name = "saubhagya122k4/bert-sentiment-analysis"

tokenizer = BertTokenizer.from_pretrained(model_name)
model = BertForSequenceClassification.from_pretrained(model_name)
model.eval()

text = "This movie was fantastic! I really enjoyed it."

inputs = tokenizer(text, return_tensors="pt", truncation=True, padding=True, max_length=70)

with torch.no_grad():
    outputs = model(**inputs)
    probs = F.softmax(outputs.logits, dim=1)
    predicted = torch.argmax(probs, dim=1).item()

labels = {0: "Positive", 1: "Negative"}
print(f"Sentiment: {labels[predicted]}")

πŸ“Š Performance

  • Accuracy: ~93% on test set
  • Tokenizer: bert-base-uncased
  • Sequence Length: 70 tokens

πŸ›  Training & Fine-tuning

  • Notebook: View on Kaggle
  • Framework: PyTorch + Hugging Face Transformers
  • Batch Size: 16
  • Epochs: 3
  • Optimizer: AdamW

πŸ“¦ Use Cases

  • Movie review classification
  • Customer feedback analysis
  • Product sentiment detection

🧾 License

This model is available for public use under the Apache 2.0.


πŸ™‹β€β™‚οΈ Author

Saubhagya Vishwakarma πŸ“§ saubhagya.v@simformsolutions.com πŸ”— GitHub

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

Model tree for saubhagya122k4/bert-sentiment-analysis

Finetuned
(5656)
this model

Dataset used to train saubhagya122k4/bert-sentiment-analysis