Fine-Tuned RoBERTa Model for Sentiment Analysis
Overview
This is a fine-tuned
RoBERTa model for sentiment analysis, trained on the
SST-2 dataset. It classifies text into two sentiment categories:
The model achieves an accuracy of 91.789% on the SST-2 test set, making it a robust choice for sentiment classification tasks.
Model Details
- Model architecture: RoBERTa
- Dataset:
stanfordnlp/sst2
- Language: English
- Model size: 125 million parameters
- Precision: FP32
- File format: SafeTensor
- Tags: Text Classification, Transformers, SafeTensors, SST-2, English, RoBERTa, Inference Endpoints
Usage
Installation
Ensure you have the necessary libraries installed:
pip install transformers torch safetensors
Loading the Model
The model can be loaded from Hugging Face's transformers library as follows:
1from transformers import AutoTokenizer, AutoModelForSequenceClassification
2
3# Load the tokenizer and model
4model_name = "syedkhalid076/RoBERTa-Sentimental-Analysis-v1"
5tokenizer = AutoTokenizer.from_pretrained(model_name)
6model = AutoModelForSequenceClassification.from_pretrained(model_name)
7
8# Example text
9text = "This is an amazing product!"
10
11# Tokenize input
12inputs = tokenizer(text, return_tensors="pt", truncation=True, padding=True)
13
14# Perform inference
15outputs = model(**inputs)
16logits = outputs.logits
17predicted_class = logits.argmax().item()
18
19# Map the prediction to sentiment
20sentiments = {0: "Negative", 1: "Positive"}
21print(f"Sentiment: {sentiments[predicted_class]}")
Performance
Dataset
The model was trained and evaluated on the SST-2 dataset, which is widely used for sentiment analysis tasks.
Metrics
| Metric | Value |
|---|
| Accuracy | 91.789% |
Deployment
The model is hosted on Hugging Face and can be used directly via their
Inference Endpoints.
Applications
This model can be used in a variety of applications, such as:
- Customer feedback analysis
- Social media sentiment monitoring
- Product review classification
- Opinion mining for research purposes
Limitations
While the model performs well on the SST-2 dataset, consider these limitations:
- It may not generalize well to domains with language or sentiment nuances different from the training data.
- It supports only binary sentiment classification (positive/negative).
For fine-tuning on custom datasets or additional labels, refer to the
Hugging Face documentation.
Model Card
| Feature | Details |
|---|
| Language | English |
| Model size | 125M parameters |
| File format | SafeTensor |
| Precision | FP32 |
| Dataset | stanfordnlp/sst2 |
| Accuracy | 91.789% |
Contributing
Contributions to improve the model or extend its capabilities are welcome. Fork this repository, make your changes, and submit a pull request.
Acknowledgments
- The Hugging Face Transformers library for model implementation and fine-tuning utilities.
- The Stanford Sentiment Treebank 2 (SST-2) dataset for providing high-quality sentiment analysis data.
Author: Syed Khalid Hussain