| --- |
| language: en |
| license: mit |
| tags: |
| - sentiment-analysis |
| - text-classification |
| - modernbert |
| library_name: sentimentizer |
| task: text-classification |
| --- |
| # Sentimentizer MODERNBERT Sentiment Model |
| ## Description |
|
|
| A ModernBERT-base model fine-tuned for 3-class sentiment classification (negative, neutral, positive). The backbone uses mean pooling over non-padding tokens followed by a two-layer classifier head with GELU activation. Supports 8-bit AdamW optimization and layer-wise unfreezing. |
|
|
| ## Training Data |
|
|
| Trained on the [Yelp Open Dataset](https://www.yelp.com/dataset) reviews with 3-class labels (negative/neutral/positive). The ModernBERT tokenizer handles subword tokenization natively—no custom dictionary is needed. |
|
|
| ## Usage |
|
|
| ```python |
| from sentimentizer.hf import download_weights |
| from sentimentizer.config import weights_path_for |
| |
| # Download classifier head + backbone from Hugging Face Hub |
| weights_path = weights_path_for("modernbert") |
| download_weights( |
| "modernbert", |
| weights_path, |
| repo_id="ryeyoo/sentimentizer-modernbert", |
| ) |
| |
| # Load and run inference |
| from sentimentizer.models.modernbert import new_modernbert_model |
| from sentimentizer.predictor import SentimentPredictor |
| |
| model = new_modernbert_model() |
| predictor = SentimentPredictor(model) |
| |
| result = predictor.predict('amazing food great service') |
| print(result) |
| # e.g. {'label': 'positive', 'score': 0.83, ...} |
| ``` |
|
|
| ## Files |
|
|
| - `modernbert_weights.pth` — Classifier head weights and config metadata |
| - `backbone/` — Hugging Face transformer backbone (safetensors + config) |
| - `backbone/tokenizer.json` — Full tokenizer data |
| - `backbone/tokenizer_config.json` — Tokenizer configuration |
|
|