Muddassar's picture
Update README.md
00b6946 verified
# Sentiment Analysis Longformer
This model is a fine-tuned version of the Longformer base model for sentiment analysis. It classifies text into 5 sentiment categories.
## Model Details
- Model Type: Longformer
- Task: Sentiment Analysis
- Training Data: 4000 customer support tickets (Approx 1000 for each class)
- Number of Parameters: 149M
## Performance
- Overall Accuracy: 74.84%
Classification Report:
```
precision recall f1-score support
0 0.75 1.00 0.86 98
1 0.67 0.55 0.60 87
2 0.84 0.75 0.79 108
3 0.83 0.43 0.57 79
4 0.70 0.91 0.79 105
accuracy 0.75 477
macro avg 0.76 0.73 0.72 477
weighted avg 0.76 0.75 0.73 477
```
## Usage
```python
from transformers import AutoTokenizer, AutoModelForSequenceClassification
import torch
hf_model_name= 'Muddassar/longformer-base-sentiment-5-classes'
model = AutoModelForSequenceClassification.from_pretrained(hf_model_name)
tokenizer = AutoTokenizer.from_pretrained(hf_model_name)
text = "Your text here"
inputs = tokenizer(text, return_tensors="pt", truncation=True, max_length=1500)
with torch.no_grad():
outputs = model(**inputs)
prediction = torch.argmax(outputs.logits, dim=1).item()
sentiment_map = {0: "Very Negative", 1: "Negative", 2: "Neutral", 3: "Positive", 4: "Very Positive"}
print(f"Predicted sentiment: {sentiment_map[prediction]}")
```
## License
MIT