Text Classification
Transformers
Safetensors
English
modernbert
sentiment-analysis
sentiment
sst-2
sst2
reviews
english
positive-negative
distilbert-sst2-alternative
text-embeddings-inference
Instructions to use AnkitAI/Sensible-ModernBERT-Sentiment-Analysis with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use AnkitAI/Sensible-ModernBERT-Sentiment-Analysis with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-classification", model="AnkitAI/Sensible-ModernBERT-Sentiment-Analysis")# Load model directly from transformers import AutoTokenizer, AutoModelForSequenceClassification tokenizer = AutoTokenizer.from_pretrained("AnkitAI/Sensible-ModernBERT-Sentiment-Analysis") model = AutoModelForSequenceClassification.from_pretrained("AnkitAI/Sensible-ModernBERT-Sentiment-Analysis", device_map="auto") - Notebooks
- Google Colab
- Kaggle
card: ModernBERT SST-2 sentiment, 0.9461
Browse files
README.md
ADDED
|
@@ -0,0 +1,113 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
---
|
| 2 |
+
base_model: answerdotai/ModernBERT-base
|
| 3 |
+
base_model_relation: finetune
|
| 4 |
+
datasets:
|
| 5 |
+
- nyu-mll/glue
|
| 6 |
+
license: apache-2.0
|
| 7 |
+
language:
|
| 8 |
+
- en
|
| 9 |
+
pipeline_tag: text-classification
|
| 10 |
+
library_name: transformers
|
| 11 |
+
widget:
|
| 12 |
+
- text: This movie was absolutely wonderful, a joy from start to finish.
|
| 13 |
+
- text: The plot was a mess and the acting felt phoned in.
|
| 14 |
+
- text: Support resolved my issue in minutes — genuinely impressed.
|
| 15 |
+
tags:
|
| 16 |
+
- sentiment-analysis
|
| 17 |
+
- sentiment
|
| 18 |
+
- text-classification
|
| 19 |
+
- sst-2
|
| 20 |
+
- sst2
|
| 21 |
+
- modernbert
|
| 22 |
+
- reviews
|
| 23 |
+
- english
|
| 24 |
+
- positive-negative
|
| 25 |
+
- distilbert-sst2-alternative
|
| 26 |
+
---
|
| 27 |
+
|
| 28 |
+
# 💬 ModernBERT Sentiment Analysis
|
| 29 |
+
|
| 30 |
+
### The modern replacement for the classic SST-2 sentiment model — **0.946 vs 0.913** on the exact same benchmark, one `pipeline()` line.
|
| 31 |
+
|
| 32 |
+
```python
|
| 33 |
+
from transformers import pipeline
|
| 34 |
+
|
| 35 |
+
clf = pipeline("text-classification", model="AnkitAI/ModernBERT-Sentiment-Analysis")
|
| 36 |
+
clf("This movie was absolutely wonderful!")
|
| 37 |
+
# [{'label': 'positive', 'score': 0.99}]
|
| 38 |
+
```
|
| 39 |
+
|
| 40 |
+
**positive / negative** for reviews, comments, feedback, social text. Built on [ModernBERT-base](https://huggingface.co/answerdotai/ModernBERT-base) — Flash-Attention-fast, 149M params, CPU-friendly.
|
| 41 |
+
|
| 42 |
+
---
|
| 43 |
+
|
| 44 |
+
## 📊 Benchmarks
|
| 45 |
+
|
| 46 |
+
SST-2 official validation set (872 examples) — the same split every SST-2 model reports on:
|
| 47 |
+
|
| 48 |
+
| Model | Accuracy |
|
| 49 |
+
|---|---|
|
| 50 |
+
| 💬 **This model** | **0.9461** |
|
| 51 |
+
| distilbert-base-uncased-finetuned-sst-2-english (the 3.9M-downloads/month default) | 0.9130 |
|
| 52 |
+
|
| 53 |
+
**+3.3 points over the model most pipelines still default to** — from an encoder released five years later. Training script and raw eval outputs ship in this repo; the reported split was never used for training or checkpoint selection.
|
| 54 |
+
|
| 55 |
+
## 🏷 Labels
|
| 56 |
+
|
| 57 |
+
| id | label |
|
| 58 |
+
|---|---|
|
| 59 |
+
| 0 | negative |
|
| 60 |
+
| 1 | positive |
|
| 61 |
+
|
| 62 |
+
**Batch scoring:**
|
| 63 |
+
|
| 64 |
+
```python
|
| 65 |
+
texts = ["Best purchase I've made all year.",
|
| 66 |
+
"Waited 40 minutes and the order was still wrong."]
|
| 67 |
+
for t, r in zip(texts, clf(texts, batch_size=64)):
|
| 68 |
+
print(f"{r['label']:<9} {r['score']:.2f} {t}")
|
| 69 |
+
```
|
| 70 |
+
|
| 71 |
+
## 💼 Built for
|
| 72 |
+
|
| 73 |
+
- **Product & review analytics** — score feedback streams at scale
|
| 74 |
+
- **Social/comment moderation dashboards** — fast, CPU-deployable
|
| 75 |
+
- **Drop-in upgrade** — same task and label semantics as the distilbert-sst2 default your stack probably uses
|
| 76 |
+
|
| 77 |
+
## ⚠️ Good to know
|
| 78 |
+
|
| 79 |
+
- Two classes only (no neutral) — SST-2 convention; genuinely neutral text gets forced to a side
|
| 80 |
+
- English, sentence/short-paragraph level
|
| 81 |
+
- Trained on movie-review sentences (SST-2); transfers well to general reviews/comments, less so to domain jargon — for financial text use [FinSense](https://huggingface.co/AnkitAI/FinSense-ModernBERT-Financial-News-Sentiment-Analysis)
|
| 82 |
+
|
| 83 |
+
## 🔧 Training details
|
| 84 |
+
|
| 85 |
+
Full fine-tune of ModernBERT-base on SST-2 (GLUE, 67k sentences): 2 epochs, lr 2e-5, batch 32, fp32, best checkpoint by held-back 5% of train — the official validation set stayed untouched until final reporting.
|
| 86 |
+
|
| 87 |
+
## 📖 Citation
|
| 88 |
+
|
| 89 |
+
```bibtex
|
| 90 |
+
@misc{modernbertsentiment2026,
|
| 91 |
+
author = {Aglawe, Ankit},
|
| 92 |
+
title = {ModernBERT Sentiment Analysis},
|
| 93 |
+
year = {2026},
|
| 94 |
+
publisher = {Hugging Face},
|
| 95 |
+
url = {https://huggingface.co/AnkitAI/ModernBERT-Sentiment-Analysis}
|
| 96 |
+
}
|
| 97 |
+
```
|
| 98 |
+
|
| 99 |
+
## 📚 Base & license
|
| 100 |
+
|
| 101 |
+
**Apache-2.0** ([ModernBERT-base](https://huggingface.co/answerdotai/ModernBERT-base), Answer.AI). Trained on [SST-2](https://huggingface.co/datasets/nyu-mll/glue) (Socher et al., 2013 / GLUE).
|
| 102 |
+
|
| 103 |
+
## 🧭 More from AnkitAI
|
| 104 |
+
|
| 105 |
+
| Model | Task | Score |
|
| 106 |
+
|---|---|---|
|
| 107 |
+
| [FinSense ModernBERT](https://huggingface.co/AnkitAI/FinSense-ModernBERT-Financial-News-Sentiment-Analysis) | financial news sentiment (3-class) | 0.8675 |
|
| 108 |
+
| [FinSense distilbert v2](https://huggingface.co/AnkitAI/distilbert-base-uncased-financial-news-sentiment-analysis) | financial news sentiment, tiny | 0.8447 |
|
| 109 |
+
| [Parable](https://huggingface.co/collections/AnkitAI/parable-6a4fac60f4b35afca3019621) | local agent LLMs (GGUF) | — |
|
| 110 |
+
|
| 111 |
+
## 🗂 Version history
|
| 112 |
+
|
| 113 |
+
- **v1** (2026-07-20) — initial release: ModernBERT-base, SST-2, seed 42.
|