This model is fine-tuned from BERT to perform sentiment analysis on a custom dataset containing student reviews about campus events or amenities. The objective is to classify the sentiments (positive, negative, neutral) while maintaining high performance metrics like accuracy.
This is the model card of a 🤗 transformers model that has been pushed on the Hub. This model card has been automatically generated.
The model can be used directly for sentiment classification of student reviews about campus events or amenities.
The model can be fine-tuned further for other sentiment analysis tasks or integrated into larger applications for sentiment classification.
The model is not suitable for tasks outside sentiment analysis, such as language translation or text generation.
The model may inherit biases from the pre-trained BERT model and the custom dataset used for fine-tuning. It may not perform well on reviews that are significantly different from the training data.
Users should be aware of the potential biases and limitations of the model. It is recommended to evaluate the model on a diverse set of reviews to understand its performance and limitations.
1from transformers import AutoModelForSequenceClassification, AutoTokenizer
2
3model_id = "MESSItom/BERT-review-sentiment-analysis"
4
5model = AutoModelForSequenceClassification.from_pretrained(model_id)
6tokenizer = AutoTokenizer.from_pretrained(model_id)
7
8def predict_sentiment(text):
9 inputs = tokenizer(text, return_tensors='pt', padding=True, truncation=True, max_length=512)
10 with torch.no_grad():
11 outputs = model(**inputs)
12 logits = outputs.logits
13 predicted_class = torch.argmax(logits, dim=-1).item()
14 class_names = ['positive', 'neutral', 'negative']
15 sentiment = class_names[predicted_class]
16 return sentiment