Views
No views yet
cardiffnlp/twitter-roberta-base-sentiment-latest trained on a combined TweetEval corpus (sentiment + hate + offensive tasks) for 3-class tweet classification.| Label | Class | Description |
|---|---|---|
| 0 | Safe / Positive | Positive or safe content |
| 1 | Neutral | Neutral / non-problematic content |
| 2 | Hate / Offensive | Hateful or offensive content |
| Parameter | Value |
|---|---|
| Base model | cardiffnlp/twitter-roberta-base-sentiment-latest |
| Datasets | TweetEval sentiment + hate + offensive |
| Max sequence length | 128 tokens |
| Learning rate | 2e-5 |
| Batch size | 32 (train) / 64 (eval) |
| Epochs | Up to 5 (early stopping, patience=2) |
| Weight decay | 0.01 |
| FP16 | ✅ |
| Optimizer | AdamW |
| Best model metric | Weighted F1 |
1from transformers import AutoTokenizer, AutoModelForSequenceClassification
2import torch
3
4model_id = "ChristianAgyapong/tweet-eval-3class-classifier"
5tokenizer = AutoTokenizer.from_pretrained(model_id)
6model = AutoModelForSequenceClassification.from_pretrained(model_id)
7
8LABEL_MAP = {0: "Safe/Positive", 1: "Neutral", 2: "Hate/Offensive"}
9
10def classify(text: str) -> dict:
11 inputs = tokenizer(text, truncation=True, max_length=128, return_tensors="pt")
12 model.eval()
13 with torch.no_grad():
14 probs = torch.softmax(model(**inputs).logits, dim=-1)[0].tolist()
15 pred = int(torch.argmax(torch.tensor(probs)))
16 return {"label": LABEL_MAP[pred], "score": probs[pred], "all_probs": probs}
17
18print(classify("I love this so much!"))
19# → {'label': 'Safe/Positive', 'score': 0.92, 'all_probs': [...]}1@misc{tweet-eval-3class-2026,
2 author = {Christian Agyapong},
3 title = {Tweet Eval 3-Class Classifier},
4 year = {2026},
5 publisher = {Hugging Face},
6 howpublished = {\url{https://huggingface.co/ChristianAgyapong/tweet-eval-3class-classifier}}
7}