File size: 7,923 Bytes
107ec63
e7b5e91
1efc533
e7b5e91
 
1efc533
 
 
 
 
 
e7b5e91
 
1efc533
e7b5e91
1efc533
 
e7b5e91
1efc533
 
 
 
 
 
 
 
 
 
 
 
 
107ec63
 
e7b5e91
107ec63
e7b5e91
107ec63
e7b5e91
 
 
 
107ec63
e7b5e91
107ec63
e7b5e91
107ec63
e7b5e91
 
 
107ec63
e7b5e91
 
 
 
107ec63
e7b5e91
 
107ec63
e7b5e91
107ec63
e7b5e91
107ec63
e7b5e91
 
 
 
 
 
 
 
107ec63
e7b5e91
107ec63
e7b5e91
107ec63
e7b5e91
 
107ec63
e7b5e91
 
 
 
 
107ec63
e7b5e91
 
 
 
 
107ec63
e7b5e91
107ec63
e7b5e91
107ec63
e7b5e91
 
107ec63
e7b5e91
 
107ec63
e7b5e91
 
 
 
 
 
 
107ec63
e7b5e91
 
 
 
 
107ec63
e7b5e91
 
 
 
107ec63
e7b5e91
 
107ec63
e7b5e91
 
107ec63
e7b5e91
 
107ec63
e7b5e91
 
 
107ec63
e7b5e91
107ec63
e7b5e91
107ec63
e7b5e91
 
 
107ec63
e7b5e91
 
107ec63
e7b5e91
 
107ec63
e7b5e91
 
107ec63
e7b5e91
 
 
107ec63
e7b5e91
 
 
107ec63
e7b5e91
107ec63
e7b5e91
107ec63
e7b5e91
 
 
 
 
 
 
 
 
 
 
107ec63
e7b5e91
107ec63
e7b5e91
107ec63
e7b5e91
 
 
107ec63
e7b5e91
107ec63
e7b5e91
 
 
 
 
107ec63
e7b5e91
 
107ec63
e7b5e91
107ec63
e7b5e91
107ec63
e7b5e91
 
 
 
 
107ec63
e7b5e91
107ec63
 
 
e7b5e91
107ec63
75ee46c
e7b5e91
107ec63
75ee46c
107ec63
e7b5e91
107ec63
e7b5e91
107ec63
e7b5e91
107ec63
e7b5e91
75ee46c
e7b5e91
 
75ee46c
e7b5e91
 
 
 
 
107ec63
e7b5e91
107ec63
e7b5e91
107ec63
e7b5e91
 
 
107ec63
e7b5e91
107ec63
ea5c0ab
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
---
language:
- en
license: apache-2.0
tags:
- text-classification
- sentiment-analysis
- bert
- nlp
- transformers
- pytorch
base_model: bert-base-uncased
datasets:
- abhiprd20/nlp-benchmark-suite
metrics:
- accuracy
- f1
model-index:
- name: nlp-sentiment-model
  results:
  - task:
      type: text-classification
      name: Sentiment Analysis
    dataset:
      name: NLP Benchmark Suite
      type: abhiprd20/nlp-benchmark-suite
    metrics:
    - type: accuracy
      value: 0.8458
    - type: f1
      value: 0.7928
---

# πŸ€– NLP Sentiment Model

### *BERT fine-tuned for 3-class sentiment analysis β€” positive, negative, neutral*

[![License](https://img.shields.io/badge/License-Apache%202.0-blue.svg)](https://opensource.org/licenses/Apache-2.0)
[![Accuracy](https://img.shields.io/badge/Accuracy-84.58%25-green)]()
[![F1 Score](https://img.shields.io/badge/F1%20Score-0.7928-orange)]()
[![Base Model](https://img.shields.io/badge/Base-BERT--base--uncased-yellow)]()

---

## πŸ“Œ Model Description

**NLP Sentiment Model** is a fine-tuned version of `bert-base-uncased` trained on the
[NLP Benchmark Suite](https://huggingface.co/datasets/abhiprd20/nlp-benchmark-suite)
dataset by Abhimanyu Prasad.

The model classifies input text into three sentiment categories:
- 😊 **Positive** β€” text expressing satisfaction, happiness, or praise
- 😞 **Negative** β€” text expressing dissatisfaction, anger, or criticism
- 😐 **Neutral** β€” text that is factual, balanced, or indifferent

It was trained on real-world data from Amazon product reviews, Twitter posts,
and IMDB movie reviews β€” covering a wide range of domains and writing styles.

---

## πŸ“Š Performance

| Metric | Score |
|--------|-------|
| **Accuracy** | **84.58%** |
| **Macro F1** | **0.7928** |
| Epochs | 3 |
| Training samples | ~4,796 |
| Test samples | ~1,199 |
| Base model | bert-base-uncased |

---

## ⚑ Quick Start

```python
from transformers import pipeline

# Load the model
classifier = pipeline(
    "sentiment-analysis",
    model="abhiprd20/nlp-sentiment-model"
)

# Predict sentiment
result = classifier("This product is absolutely amazing!")
print(result)
# β†’ [{'label': 'positive', 'score': 0.97}]
```

---

## πŸ” More Examples

```python
from transformers import pipeline

classifier = pipeline("sentiment-analysis",
                      model="abhiprd20/nlp-sentiment-model")

texts = [
    "I absolutely love this, best purchase ever!",
    "Terrible quality, complete waste of money.",
    "It arrived on time and works as described.",
    "The customer service was incredibly helpful.",
    "Not great, not terrible, just average.",
]

for text in texts:
    result = classifier(text)[0]
    print(f"Text  : {text}")
    print(f"Label : {result['label']} ({round(result['score']*100, 1)}% confident)\n")
```

**Expected output:**
```
Text  : I absolutely love this, best purchase ever!
Label : positive (97.3% confident)

Text  : Terrible quality, complete waste of money.
Label : negative (98.1% confident)

Text  : It arrived on time and works as described.
Label : neutral (95.4% confident)

Text  : The customer service was incredibly helpful.
Label : positive (96.8% confident)

Text  : Not great, not terrible, just average.
Label : neutral (91.2% confident)
```

---

## πŸ§ͺ Use With AutoTokenizer and AutoModel

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

tokenizer = AutoTokenizer.from_pretrained("abhiprd20/nlp-sentiment-model")
model     = AutoModelForSequenceClassification.from_pretrained("abhiprd20/nlp-sentiment-model")

text   = "This is the best thing I have ever bought!"
inputs = tokenizer(text, return_tensors="pt", truncation=True, max_length=128)

with torch.no_grad():
    outputs = model(**inputs)

probs      = torch.softmax(outputs.logits, dim=1)
label_id   = torch.argmax(probs).item()
id2label   = {0: "negative", 1: "neutral", 2: "positive"}

print(f"Label      : {id2label[label_id]}")
print(f"Confidence : {probs[0][label_id].item():.4f}")
```

---

## πŸ—‚οΈ Training Details

| Parameter | Value |
|-----------|-------|
| Base model | `bert-base-uncased` |
| Task | Sequence Classification |
| Number of labels | 3 (negative, neutral, positive) |
| Epochs | 3 |
| Batch size | 16 |
| Max sequence length | 128 |
| Optimizer | AdamW (default) |
| Hardware | NVIDIA T4 GPU (Google Colab) |
| Framework | Hugging Face Transformers |

---

## πŸ“¦ Training Dataset

This model was trained on the
[NLP Benchmark Suite](https://huggingface.co/datasets/abhiprd20/nlp-benchmark-suite)
dataset, specifically the sentiment analysis subset.

The training data covers three real-world sources:

| Source | Domain | Samples |
|--------|--------|---------|
| Amazon Polarity | E-commerce product reviews | ~2,000 |
| TweetEval | Social media posts | ~2,000 |
| IMDB | Movie reviews | ~2,000 |

**Total training samples:** ~4,796
**Total test samples:** ~1,199

---

## 🏷️ Label Mapping

| Label ID | Label | Meaning |
|----------|-------|---------|
| 0 | negative | Dissatisfaction, criticism, anger |
| 1 | neutral | Factual, balanced, indifferent |
| 2 | positive | Satisfaction, praise, happiness |

---



## βš–οΈ License

This model is released under the **Apache License 2.0** 
research and commercial use.

Copyright 2026 Abhimanyu Prasad

---

## πŸ“Ž Citation

If you use this model in your research or project, please cite:

```bibtex
@misc{prasad2026nlpsentiment,
  title        = {NLP Sentiment Model: BERT Fine-tuned for 3-Class Sentiment Analysis},
  author       = {Prasad, Abhimanyu},
  year         = {2026},
  publisher    = {Hugging Face},
  howpublished = {\url{https://huggingface.co/abhiprd20/nlp-sentiment-model}},
  note         = {Fine-tuned on NLP Benchmark Suite. Accuracy: 84.58\%, F1: 0.7928}
}
```

---

## πŸ‘€ Author

**Abhimanyu Prasad**
πŸ€— Hugging Face: [abhiprd20](https://huggingface.co/abhiprd20)
πŸ“¦ Dataset: [abhiprd20/nlp-benchmark-suite](https://huggingface.co/datasets/abhiprd20/nlp-benchmark-suite)

---

*If this model helped your project, consider giving it a ⭐ β€” it helps others find it too!*

---

## πŸ“Š Cross-Language Evaluation

Each model was evaluated on all 4 languages (300 sentences per language, 100 per class).
This shows how well models trained on one language transfer to others.

### Accuracy Matrix

| Model | English | Hindi | Maithili | Bhojpuri |
|---|---|---|---|---|
| ⭐ **English model** _(this model)_ | **79.5%** βœ“ | 34.0% | 33.3% | 33.0% |
| **Hindi model** | 60.0% | **68.0%** βœ“ | 63.3% | 61.7% |
| **Maithili model** | 63.0% | 59.0% | **90.3%** βœ“ | 75.0% |
| **Bhojpuri model** | 59.0% | 47.3% | 47.3% | **98.0%** βœ“ |

### F1 Matrix (macro)

| Model | English | Hindi | Maithili | Bhojpuri |
|---|---|---|---|---|
| ⭐ **English model** _(this model)_ | **0.5424** βœ“ | 0.1912 | 0.1667 | 0.1654 |
| **Hindi model** | 0.4362 | **0.6778** βœ“ | 0.6319 | 0.6042 |
| **Maithili model** | 0.4443 | 0.5757 | **0.9035** βœ“ | 0.7458 |
| **Bhojpuri model** | 0.4250 | 0.4166 | 0.4114 | **0.9801** βœ“ |

### Key Findings

- This model achieves **79.5%** on English sentiment but drops to **~33%** on Maithili and Bhojpuri β€” equivalent to random chance on a 3-class task.
- Demonstrates that monolingual English training does **not** transfer to low-resource Bihari languages.
- English also transfers poorly to Hindi (34%), confirming the language barrier extends beyond Bihari languages.

> **Full paper:** This cross-evaluation is part of a research study on cross-lingual transfer for low-resource Bihari languages. See the companion datasets and models: [Maithili](https://huggingface.co/abhiprd20/maithili-sentiment-model) | [Bhojpuri](https://huggingface.co/abhiprd20/bhojpuri-sentiment-model) | [Hindi](https://huggingface.co/abhiprd20/hindi-sentiment-model) | [English](https://huggingface.co/abhiprd20/nlp-sentiment-model)