File size: 2,083 Bytes
eb4f052
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
a27260d
eb4f052
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
---
license: mit
datasets:
- yassiracharki/Amazon_Reviews_for_Sentiment_Analysis_fine_grained_5_classes
language:
- en
metrics:
- accuracy
tags:
- text-classification
- sentiment-classification
- BERT
- Roberta
- mini-roberta
---
# RoBERTa-mini: Sentiment Classifier

**Model Name**: `dilip025/RoBERTa-mini`  
**Task**: Sentiment Classification  
**Labels**: Very Negative, Negative, Neutral, Positive, Very Positive

A compact RoBERTa like model trained from scratch for sentiment classification.

## Example Usage

```python
from transformers import AutoTokenizer, AutoModelForSequenceClassification
import torch

tokenizer = AutoTokenizer.from_pretrained("dilip025/RoBERTa-mini")
model = AutoModelForSequenceClassification.from_pretrained("dilip025/RoBERTa-mini", trust_remote_code=True)

id2label = {
    0: "Very Negative",
    1: "Negative",
    2: "Neutral",
    3: "Positive",
    4: "Very Positive"
}

def predict_sentiment(text):
    inputs = tokenizer(text, return_tensors="pt", truncation=True, padding=True, max_length=128)
    with torch.no_grad():
        outputs = model(**inputs)
        probs = torch.softmax(outputs["logits"], dim=1)
        pred_class = torch.argmax(probs, dim=1).item()
    return {
        "text": text,
        "class_id": pred_class,
        "label": id2label[pred_class],
        "probabilities": probs.tolist()[0]
    }

# Example
result = predict_sentiment("I absolutely hate this product.")
print(result)
```

## Model Card

- **Architecture**: RoBERTa (custom small version)
- **Training Dataset**: [Amazon Reviews Dataset](https://huggingface.co/datasets/yassiracharki/Amazon_Reviews_for_Sentiment_Analysis_fine_grained_5_classes/viewer)
- **Use Case**: Sentiment classification for customer feedback, reviews, etc.
- **Input Format**: Plain text (string)
- **Output**: Dictionary with class ID, label, and class probabilities

## License

This model is licensed under the MIT License. You are free to use, modify, and distribute it with attribution.

## Author

Developed and Trained by [Dilip Pokhrel](https://huggingface.co/dilip025)