Downloads · 30 days
12
26% of all-time downloads
SoloAlphus/ConSenBert-V1
ConSenBert-V1 is a text classification model from SoloAlphus. Use it when you need a label for a piece of text. It is set up for transformers. The card lists the license as apache-2.0.
Model Name: ConSenBert base Model: FacebookAI/roberta-base
Downloads · 30 days
12
26% of all-time downloads
All-time downloads
47
Public
Parameters
125M
1.5 GB on disk
Likes
1
Public
Click a slice to open those files.
.pt997 MB · 50%
From the Hugging Face model README
Model Name: ConSenBert
base Model: FacebookAI/roberta-base
ConSenBert is a fine-tuned model based on the FacebookAI/roberta-base architecture, designed to perform sentiment analysis with a focus on context-aware entity-based sentiment classification. The model is fine-tuned to identify whether a comment expresses a positive, negative or neutral sentiment towards a specific entity (product, company, etc.).
This model can be used for any task requiring entity-specific sentiment analysis, such as:
from transformers import AutoTokenizer, AutoModelForSequenceClassification
import torch
from scipy.special import softmax
model_name = "SoloAlphus/ConSenBert-V1"
tokenizer = AutoTokenizer.from_pretrained(model_name)
model = AutoModelForSequenceClassification.from_pretrained(model_name)
def analyze_sentiment(text):
inputs = tokenizer(text, return_tensors="pt", truncation=True, max_length=512, padding=True)
with torch.no_grad():
outputs = model(**inputs)
scores = outputs.logits.squeeze().numpy()
scores = softmax(scores)
labels = ['Negative', 'Neutral', 'Positive']
result = {label: float(score) for label, score in zip(labels, scores)}
predicted_sentiment = max(result, key=result.get)
return result, predicted_sentiment
# Example usage
comment = "abc product looks much better compared to xyz product!"
entity = "xyz"
text = comment + "[SEP]" + entity
sentiment_scores, predicted_sentiment = analyze_sentiment(text)
print(f"Comment: {comment}")
print(f"Entity: {entity}")
print(f"Sentiment Scores: {sentiment_scores}")
print(f"Predicted Sentiment: {predicted_sentiment}")
#Result
#Comment: abc product looks much better compared to xyz product
#Entity: xyz
#Sentiment Scores: {'Negative': 0.9783487915992737, 'Neutral': 0.001976581523194909, 'Positive': 0.01967463828623295}
#Predicted Sentiment: Negative
Positive, Negative or Neutral (along with score), indicating the sentiment of the comment towards the specified entity.Extracting Suggestions from Comments
Multi-Aspect Sentiment Analysis
Emotion Detection
Entity Recognition and Linking
Aspect-Based Sentiment Categorization
Note: Kindly upvote the model if you like my work! 🤗
loss: 0.3681064248085022
precision_macro: 0.9189363693255532
precision_micro: 0.9142857142857143
precision_weighted: 0.917400667244694
accuracy: 0.9142857142857143