Create README.md
Browse files
README.md
ADDED
|
@@ -0,0 +1,120 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
---
|
| 2 |
+
datasets:
|
| 3 |
+
- syedkhalid076/Sentiment-Analysis-Over-sampled
|
| 4 |
+
language:
|
| 5 |
+
- en
|
| 6 |
+
metrics:
|
| 7 |
+
- accuracy: 0.9019906657776932
|
| 8 |
+
- accuracy
|
| 9 |
+
model_name: RoBERTa Sentiment Analysis Model v2
|
| 10 |
+
base_model: roberta-base
|
| 11 |
+
library_name: transformers
|
| 12 |
+
tags:
|
| 13 |
+
- Text Classification
|
| 14 |
+
- Transformers
|
| 15 |
+
- Safetensors
|
| 16 |
+
- English
|
| 17 |
+
- roberta
|
| 18 |
+
- Inference Endpoints
|
| 19 |
+
pipeline_tag: text-classification
|
| 20 |
+
---
|
| 21 |
+
|
| 22 |
+
|
| 23 |
+
# RoBERTa Sentiment Analysis Model v2
|
| 24 |
+
|
| 25 |
+
This repository hosts a fine-tuned [RoBERTa](https://huggingface.co/roberta-base) model for sentiment analysis. The model classifies text into three categories: **Negative (0)**, **Neutral (1)**, and **Positive (2)**. It has been fine-tuned on the [syedkhalid076/Sentiment-Analysis-Over-sampled](https://huggingface.co/datasets/syedkhalid076/Sentiment-Analysis-Over-sampled) dataset and achieves high accuracy.
|
| 26 |
+
The Model is Trained specifically for Feedback Sentiment Analysis for UX Research, but it does perform well on other Sentiment Analysis tasks.
|
| 27 |
+
|
| 28 |
+
---
|
| 29 |
+
|
| 30 |
+
## Model Details
|
| 31 |
+
|
| 32 |
+
- **Base Model**: [RoBERTa-base](https://huggingface.co/roberta-base)
|
| 33 |
+
- **Number of Labels**: 3 (0:Negative, 1:Neutral, 2:Positive)
|
| 34 |
+
- **Model Size**: 125M parameters
|
| 35 |
+
- **Language**: English (`en`)
|
| 36 |
+
- **Metrics**: Accuracy: **90.20%**
|
| 37 |
+
- **Tensor Type**: FP32
|
| 38 |
+
- **Dataset**: [syedkhalid076/Sentiment-Analysis-Over-sampled](https://huggingface.co/datasets/syedkhalid076/Sentiment-Analysis-Over-sampled)
|
| 39 |
+
- **Library**: [Transformers](https://github.com/huggingface/transformers)
|
| 40 |
+
- **File Format**: [Safetensors](https://github.com/huggingface/safetensors)
|
| 41 |
+
|
| 42 |
+
---
|
| 43 |
+
|
| 44 |
+
## Features
|
| 45 |
+
|
| 46 |
+
- **Text Classification**: Identify the sentiment of input text as Negative, Neutral, or Positive.
|
| 47 |
+
- **High Accuracy**: Achieves 90.20% accuracy on the evaluation dataset.
|
| 48 |
+
- **Hosted on Hugging Face**: Ready-to-use inference endpoints for quick deployment.
|
| 49 |
+
- **Efficient Inference**: Lightweight and efficient, supporting FP32 tensors.
|
| 50 |
+
|
| 51 |
+
---
|
| 52 |
+
|
| 53 |
+
## Installation
|
| 54 |
+
|
| 55 |
+
To use this model, ensure you have the `transformers` library installed:
|
| 56 |
+
|
| 57 |
+
```bash
|
| 58 |
+
pip install transformers
|
| 59 |
+
```
|
| 60 |
+
|
| 61 |
+
---
|
| 62 |
+
|
| 63 |
+
## Usage
|
| 64 |
+
|
| 65 |
+
Here’s how you can load the model and tokenizer and perform inference:
|
| 66 |
+
|
| 67 |
+
```python
|
| 68 |
+
from transformers import AutoTokenizer, AutoModelForSequenceClassification
|
| 69 |
+
import torch
|
| 70 |
+
|
| 71 |
+
# Load tokenizer and model
|
| 72 |
+
tokenizer = AutoTokenizer.from_pretrained("syedkhalid076/RoBERTa-Sentimental-Analysis-Model")
|
| 73 |
+
model = AutoModelForSequenceClassification.from_pretrained("syedkhalid076/RoBERTa-Sentimental-Analysis-Model")
|
| 74 |
+
|
| 75 |
+
# Define input text
|
| 76 |
+
text = "I absolutely love this product! It's fantastic."
|
| 77 |
+
|
| 78 |
+
# Tokenize input
|
| 79 |
+
inputs = tokenizer(text, return_tensors="pt", truncation=True, padding=True)
|
| 80 |
+
|
| 81 |
+
# Perform inference
|
| 82 |
+
outputs = model(**inputs)
|
| 83 |
+
logits = outputs.logits
|
| 84 |
+
predicted_class = torch.argmax(logits, dim=-1).item()
|
| 85 |
+
|
| 86 |
+
# Print results
|
| 87 |
+
sentiment_labels = {0: "Negative", 1: "Neutral", 2: "Positive"}
|
| 88 |
+
print(f"Predicted sentiment: {sentiment_labels[predicted_class]}")
|
| 89 |
+
```
|
| 90 |
+
|
| 91 |
+
---
|
| 92 |
+
|
| 93 |
+
## Dataset
|
| 94 |
+
|
| 95 |
+
This model is fine-tuned on the [syedkhalid076/Sentiment-Analysis-Over-sampled](https://huggingface.co/datasets/syedkhalid076/Sentiment-Analysis-Over-sampled) dataset. The dataset has been carefully preprocessed and oversampled to ensure balanced label representation and improve model performance.
|
| 96 |
+
|
| 97 |
+
---
|
| 98 |
+
|
| 99 |
+
## Performance
|
| 100 |
+
|
| 101 |
+
The model was evaluated on a test set and achieved the following metrics:
|
| 102 |
+
|
| 103 |
+
- **Accuracy**: 90.20% (0.9019906657776932)
|
| 104 |
+
|
| 105 |
+
The evaluation strategy includes validation after each epoch and logging metrics for tracking training progress.
|
| 106 |
+
|
| 107 |
+
---
|
| 108 |
+
|
| 109 |
+
## Inference Endpoints
|
| 110 |
+
|
| 111 |
+
You can use the Hugging Face Inference API to deploy and test this model in production environments.
|
| 112 |
+
|
| 113 |
+
---
|
| 114 |
+
|
| 115 |
+
|
| 116 |
+
## Author
|
| 117 |
+
|
| 118 |
+
**Syed Khalid Hussain**
|
| 119 |
+
UX Designer & Developer
|
| 120 |
+
Specializing in crafting user-centric digital experiences.
|