Email sentiment (RoBERTa)

Reads a work email and labels its tone as negative, neutral or positive. It is the sentiment model in my final-year project, an email analyser that also tags each email's topic and urgency.

Training

  • Base: cardiffnlp/twitter-roberta-base-sentiment-latest, a RoBERTa model trained on tweets.
  • Data: 169 labelled work emails, 143 for training and 26 for validation.
  • Only the top 4 transformer layers and the classification head were trained (28.9M of 124.6M parameters). The lower layers stayed frozen, so the model keeps the English it already knows and trains on a laptop CPU in under a minute.
  • 6 epochs, batch size 8, learning rate 3e-5, max 128 tokens, seed 42. I kept the epoch with the best validation macro-F1 (epoch 3).

Results

Scored on 80 separate test emails (26 positive, 27 neutral, 27 negative) that training never saw.

Model Accuracy Macro-F1
Base model 78.8% 0.787
This model 88.8% 0.888

The biggest gain is on sarcasm: the base model got 1 of 6 sarcastic emails right and this model gets all 6. On subtle emails it goes from 16 to 18 of 25.

Use

from transformers import pipeline

classify = pipeline("text-classification", model="dfordebarati/email-sentiment-roberta")
classify("Thanks for turning this around so fast, the client loved it.")

Limitations

  • 169 training emails is a small dataset.
  • The training and test emails were written by the same person, so the test set shares their style. Expect lower accuracy on a real inbox.
  • English only. Anything past 128 tokens is cut off.
Downloads last month
-
Safetensors
Model size
0.1B params
Tensor type
F32
ยท
Inference Providers NEW
This model isn't deployed by any Inference Provider. ๐Ÿ™‹ Ask for provider support

Model tree for dfordebarati/email-sentiment-roberta

Finetuned
(244)
this model