Text Classification
Transformers
Safetensors
English
roberta
email
topic-classification
text-embeddings-inference
Instructions to use dfordebarati/email-topic-roberta with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use dfordebarati/email-topic-roberta with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-classification", model="dfordebarati/email-topic-roberta")# pip install -U transformers accelerate # Load model directly from transformers import AutoTokenizer, AutoModelForSequenceClassification tokenizer = AutoTokenizer.from_pretrained("dfordebarati/email-topic-roberta") model = AutoModelForSequenceClassification.from_pretrained("dfordebarati/email-topic-roberta", device_map="auto") - Notebooks
- Google Colab
- Kaggle
Email topic (RoBERTa)
Sorts a work email into one of 9 topics: Project Update, Meeting & Scheduling, Request, Appreciation, Client & Business, Escalation & Complaint, Finance & Budget, Technical Issue, HR & Admin. It is the topic model in my final-year email analyser, next to the sentiment and urgency models.
Training
- Base: cardiffnlp/twitter-roberta-base-sentiment-latest with a new 9-way classification head.
- Data: 499 emails from the public Enron corpus, labelled for topic and urgency. 399 for training, 100 for validation.
- The top 4 transformer layers and the head were trained (28.9M of 124.7M parameters). 10 epochs, batch size 8, learning rate 5e-5, max 128 tokens. Rare topics count more in the loss. The best validation macro-F1 came at epoch 6.
- It beat logistic regression on MiniLM embeddings and a fully fine-tuned MiniLM. The winner was picked on the validation set only.
Results
Scored on 114 Enron emails kept out of training and validation.
| Method | Accuracy | Macro-F1 |
|---|---|---|
| Previous method (closest example sentence, MiniLM embeddings) | 33.3% | 0.327 |
| This model | 66.7% | 0.637 |
On a second test set of 90 emails written by the project team (10 per topic), accuracy goes from 56.7% to 61.1%.
Use
from transformers import pipeline
classify = pipeline("text-classification", model="dfordebarati/email-topic-roberta")
classify("Can we move tomorrow's review to 3pm? Two people are out in the morning.")
Limitations
- 499 training emails across 9 topics is small. Appreciation and Escalation & Complaint have only 4 test emails each, so their scores rest on very few examples.
- The Enron emails come from one energy-trading company in the early 2000s. Topics and wording in other workplaces differ.
- The labels were drafted with a language model and then reviewed by hand against a written labelling guide. Some may still be wrong.
- English only. Anything past 128 tokens is cut off.
- Downloads last month
- -