sentiment / README.md
ktr008's picture
Update README.md
594a61d verified
metadata
language: en
license: apache-2.0
tags:
  - sentiment-analysis
  - text-classification
model_name: Your Model Name
datasets: dataset-used

Fine-Tuned Sentiment Analysis Model

Hugging Face Model
πŸ”— Model ID: ktr008/sentiment
πŸ“… Last Updated: 2025-02-25
πŸš€ Framework: PyTorch | Transformers

πŸ“Œ Model Description

This is a fine-tuned RoBERTa model for sentiment analysis based on the Twitter RoBERTa Base model. It classifies text into Positive, Neutral, or Negative sentiments.

πŸ› οΈ How to Use

Install Dependencies

pip install transformers torch scipy

Load Model & Tokenizer

from transformers import AutoModelForSequenceClassification, AutoTokenizer
import numpy as np
from scipy.special import softmax

model = AutoModelForSequenceClassification.from_pretrained("ktr008/sentiment")
tokenizer = AutoTokenizer.from_pretrained("ktr008/sentiment")

def predict_sentiment(text):
    encoded_input = tokenizer(text, return_tensors='pt')
    output = model(**encoded_input)
    scores = output[0][0].detach().numpy()
    scores = softmax(scores)
    
    labels = ["Negative", "Neutral", "Positive"]
    ranking = np.argsort(scores)[::-1]
    
    return {labels[i]: round(float(scores[i]), 4) for i in ranking}

# Example usage
print(predict_sentiment("I love this product!"))

πŸ’‘ Training Details

  • Base Model: cardiffnlp/twitter-roberta-base-sentiment-latest
  • Dataset: Custom dataset with labeled sentiment texts
  • Fine-Tuning: Performed on AWS EC2 with PyTorch
  • Batch Size: 16
  • Optimizer: AdamW
  • Learning Rate: 5e-5

πŸ“ Example Predictions

Text Prediction
"I love this product!" Positive (98.3%)
"It's an okay experience." Neutral (67.4%)
"I hate this! Never buying again." Negative (92.1%)

πŸ“ˆ Performance

  • Accuracy: 0.9344

πŸ“Œ Model Limitations

  • May struggle with sarcasm or ambiguous phrases.
  • Can be biased towards the training dataset.
  • Not suitable for long texts without truncation.

πŸ“ Citation

If you use this model, please cite:

@model{ktr008_sentiment_2025,
  author    = {ktr008},
  title     = {Fine-Tuned Sentiment Analysis Model},
  year      = {2025},
  publisher = {Hugging Face},
  version   = {1.0}
}

πŸ“¬ Contact

For issues or suggestions, reach out to me on Hugging Face πŸš€