CoolFace
Modelpublic

AventIQ-AI/sentiment_analysis_product_review_sentiment

sourceHugging Faceupdated 1y agoView on Hugging Face
1likes4downloads
Model Card

๐Ÿง  SentimentClassifier-BERT-TweetEval

A BERT-based sentiment analysis model fine-tuned on the TweetEval dataset. It predicts the sentiment of a text as Positive, Neutral, or Negative with confidence scores. This model is useful for classifying product feedback, user reviews, or social media posts.

โœจ Model Highlights

  • โ€”๐Ÿ“Œ Based on bert-base-uncased (by Google)
  • โ€”๐Ÿ” Fine-tuned on the Sentiment Subtask from TweetEval
  • โ€”โšก Supports prediction of 3 classes: Negative, Neutral, Positive
  • โ€”๐Ÿ’พ Available in both full and quantized versions for inference

๐Ÿง  Intended Uses

  • โ€”Product release analysis (e-commerce, apps)

๐Ÿšซ Limitations

  • โ€”Not optimized for other languages than English
  • โ€”May not generalize well to domains very different from Twitter/product reviews
  • โ€”Can confuse sarcasm or irony
  • โ€”Performance may degrade on long texts (>128 tokens, due to truncation)

๐Ÿ‹๏ธโ€โ™‚๏ธ Training Details

  • โ€”Base Model: bert-base-uncased
  • โ€”Dataset: TweetEval: Sentiment Subtask
  • โ€”Framework: PyTorch with ๐Ÿค— Transformers
  • โ€”Epochs: 5
  • โ€”Batch Size: 8
  • โ€”Max Length: 128 tokens
  • โ€”Optimizer: AdamW
  • โ€”Loss: CrossEntropyLoss with class balancing
  • โ€”Device: Trained on NVIDIA CUDA-enabled GPU

๐Ÿ“Š Evaluation Metrics

MetricScore
Accuracy0.99
F1-macro0.98

Replace the above with actual scores after evaluation.

๐Ÿ”Ž Label Mapping

Label IDSentiment
0Negative
1Neutral
2Positive

๐Ÿš€ Usage

Load the Model

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

model_name = "AventIQ-AI/sentiment_analysis_product_review_sentiment"
tokenizer = BertTokenizer.from_pretrained(model_name)
model = BertForSequenceClassification.from_pretrained(model_name)
model.eval()

def predict(text):
    inputs = tokenizer(text, return_tensors="pt", padding=True, truncation=True, max_length=128)
    with torch.no_grad():
        outputs = model(**inputs)
        probs = F.softmax(outputs.logits, dim=1)
        pred = torch.argmax(probs, dim=1).item()
        label_map = {0: "Negative", 1: "Neutral", 2: "Positive"}
        return f"Sentiment: {label_map[pred]} (Confidence: {probs[0][pred]:.2f})"

# Test predictions
print("\nTest Predictions:")
print(predict("We're thrilled to announce our latest update, packed with new features and performance improvements!"))

Quantization

Post-training quantization was applied using PyTorch's built-in quantization framework to reduce the model size and improve inference efficiency.

Repository Structure

.
โ”œโ”€โ”€ model/               # Contains the quantized model files
โ”œโ”€โ”€ tokenizer_config/    # Tokenizer configuration and vocabulary files
โ”œโ”€โ”€ model.safensors/     # Fine Tuned Model
โ”œโ”€โ”€ README.md            # Model documentation

Limitations

  • โ€”The model may not generalize well to domains outside the fine-tuning dataset.
  • โ€”Quantization may result in minor accuracy degradation compared to full-precision models.

Contributing

Contributions are welcome! Feel free to open an issue or submit a pull request if you have suggestions or improvements.