mervp/SentimentBERT
168
1---2language: en3license: apache-2.04tags:5 - sentiment analysis6 - text classification7 - bert8 - transformers9 - news10 - reviews11---12 13# SentimentBERT — Fine-tuned BERT for Sentiment Classification (Positive, Neutral, Negative)14 15**SentimentBERT** is a Finetuned BERT-based model specifically for **sentiment classification of sentences** into three categories: **Positive**, **Negative**, and **Neutral**.16 17This model has been trained on a ** 130K large and diverse dataset of news articles** across a wide range of categories. It achieves **over 86% accuracy** and demonstrates a strong understanding of sentence-level sentiment, even in nuanced or mixed-context cases.18 19---20 21## Model Highlights22 23- **Base model**: `bert-base-uncased`24- **Fine tuned for**: Sentiment classification (3-class)25- **Accuracy**: > 86%26- **Classes**: Positive, Neutral, Negative27- **Language**: English28- **Format**: `safetensors`29- **Tokenizer**: Compatible with `bert-base-uncased`30 31---32 33## Applications34 35This model is well-suited for:36 37- **News article sentiment analysis**38- **Amazon product review analysis**39- **Customer support or service feedback systems**40- **General-purpose opinion mining**41 42 43 44Thanks for visiting and downloading this model!45If this model helped you, please consider leaving a like. Your support helps this model reach more developers and encourages further improvements if any.46---47 48## How to use the model49 50```python51from transformers import AutoTokenizer, AutoModelForSequenceClassification52import torch53 54model = AutoModelForSequenceClassification.from_pretrained("mervp/SentimentBERT")55tokenizer = AutoTokenizer.from_pretrained("mervp/SentimentBERT")56 57def predict_sentiment(text):58 model.eval()59 inputs = tokenizer(text, return_tensors="pt", truncation=True, padding=True)60 with torch.no_grad():61 outputs = model(**inputs)62 logits = outputs.logits63 prediction = torch.argmax(logits, dim=-1).item()64 label = model.config.id2label[prediction]65 return label66 67print(predict_sentiment("What a beautiful day.")) # positive68print(predict_sentiment("The service was excellent.")) # positive69print(predict_sentiment("He did a fantastic job.")) # positive70print(predict_sentiment("The experience was terrible.")) # negative71print(predict_sentiment("Everything went wrong.")) # negative72print(predict_sentiment("He opened the door and walked in.")) # neutral73print(predict_sentiment("They are meeting at 5 PM.")) # neutral74print(predict_sentiment("She has a cat.")) # neutral75 