Update README.md
Browse files
README.md
CHANGED
|
@@ -1,199 +1,231 @@
|
|
| 1 |
-
---
|
| 2 |
-
|
| 3 |
-
|
| 4 |
-
|
| 5 |
-
|
| 6 |
-
|
| 7 |
-
|
| 8 |
-
|
| 9 |
-
|
| 10 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 11 |
|
| 12 |
## Model Details
|
| 13 |
|
| 14 |
### Model Description
|
| 15 |
-
|
| 16 |
-
|
| 17 |
-
|
| 18 |
-
|
| 19 |
-
|
| 20 |
-
-
|
| 21 |
-
-
|
| 22 |
-
|
| 23 |
-
|
| 24 |
-
- **
|
| 25 |
-
- **
|
| 26 |
-
- **
|
| 27 |
-
|
| 28 |
-
|
| 29 |
-
|
| 30 |
-
|
| 31 |
-
|
| 32 |
-
- **
|
| 33 |
-
- **
|
| 34 |
-
- **
|
| 35 |
-
|
| 36 |
-
|
| 37 |
-
|
| 38 |
-
|
| 39 |
-
|
| 40 |
-
|
| 41 |
-
|
| 42 |
-
<!-- This section is for the model use without fine-tuning or plugging into a larger ecosystem/app. -->
|
| 43 |
-
|
| 44 |
-
[More Information Needed]
|
| 45 |
-
|
| 46 |
-
### Downstream Use [optional]
|
| 47 |
-
|
| 48 |
-
<!-- This section is for the model use when fine-tuned for a task, or when plugged into a larger ecosystem/app -->
|
| 49 |
-
|
| 50 |
-
[More Information Needed]
|
| 51 |
-
|
| 52 |
-
### Out-of-Scope Use
|
| 53 |
-
|
| 54 |
-
<!-- This section addresses misuse, malicious use, and uses that the model will not work well for. -->
|
| 55 |
-
|
| 56 |
-
[More Information Needed]
|
| 57 |
-
|
| 58 |
-
## Bias, Risks, and Limitations
|
| 59 |
-
|
| 60 |
-
<!-- This section is meant to convey both technical and sociotechnical limitations. -->
|
| 61 |
-
|
| 62 |
-
[More Information Needed]
|
| 63 |
-
|
| 64 |
-
### Recommendations
|
| 65 |
-
|
| 66 |
-
<!-- This section is meant to convey recommendations with respect to the bias, risk, and technical limitations. -->
|
| 67 |
-
|
| 68 |
-
Users (both direct and downstream) should be made aware of the risks, biases and limitations of the model. More information needed for further recommendations.
|
| 69 |
-
|
| 70 |
-
## How to Get Started with the Model
|
| 71 |
-
|
| 72 |
-
Use the code below to get started with the model.
|
| 73 |
-
|
| 74 |
-
[More Information Needed]
|
| 75 |
|
| 76 |
## Training Details
|
| 77 |
|
| 78 |
### Training Data
|
|
|
|
| 79 |
|
| 80 |
-
|
| 81 |
-
|
| 82 |
-
[More Information Needed]
|
| 83 |
|
| 84 |
### Training Procedure
|
| 85 |
-
|
| 86 |
-
|
| 87 |
-
|
| 88 |
-
|
| 89 |
-
|
| 90 |
-
|
| 91 |
-
|
| 92 |
-
|
| 93 |
-
|
| 94 |
-
|
| 95 |
-
- **
|
| 96 |
-
|
| 97 |
-
|
| 98 |
-
|
| 99 |
-
|
| 100 |
-
|
| 101 |
-
|
| 102 |
|
| 103 |
## Evaluation
|
| 104 |
|
| 105 |
-
|
| 106 |
-
|
| 107 |
-
|
| 108 |
-
|
| 109 |
-
|
| 110 |
-
|
| 111 |
-
|
| 112 |
-
|
| 113 |
-
|
| 114 |
-
|
| 115 |
-
##
|
| 116 |
-
|
| 117 |
-
|
| 118 |
-
|
| 119 |
-
|
| 120 |
-
|
| 121 |
-
|
| 122 |
-
|
| 123 |
-
|
| 124 |
-
|
| 125 |
-
|
| 126 |
-
|
| 127 |
-
|
| 128 |
-
|
| 129 |
-
|
| 130 |
-
|
| 131 |
-
|
| 132 |
-
|
| 133 |
-
|
| 134 |
-
|
| 135 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 136 |
|
| 137 |
-
|
| 138 |
-
|
| 139 |
-
|
| 140 |
-
|
| 141 |
-
|
| 142 |
-
|
| 143 |
-
<!-- Total emissions (in grams of CO2eq) and additional considerations, such as electricity usage, go here. Edit the suggested text below accordingly -->
|
| 144 |
-
|
| 145 |
-
Carbon emissions can be estimated using the [Machine Learning Impact calculator](https://mlco2.github.io/impact#compute) presented in [Lacoste et al. (2019)](https://arxiv.org/abs/1910.09700).
|
| 146 |
-
|
| 147 |
-
- **Hardware Type:** [More Information Needed]
|
| 148 |
-
- **Hours used:** [More Information Needed]
|
| 149 |
-
- **Cloud Provider:** [More Information Needed]
|
| 150 |
-
- **Compute Region:** [More Information Needed]
|
| 151 |
-
- **Carbon Emitted:** [More Information Needed]
|
| 152 |
-
|
| 153 |
-
## Technical Specifications [optional]
|
| 154 |
-
|
| 155 |
-
### Model Architecture and Objective
|
| 156 |
-
|
| 157 |
-
[More Information Needed]
|
| 158 |
-
|
| 159 |
-
### Compute Infrastructure
|
| 160 |
-
|
| 161 |
-
[More Information Needed]
|
| 162 |
-
|
| 163 |
-
#### Hardware
|
| 164 |
-
|
| 165 |
-
[More Information Needed]
|
| 166 |
-
|
| 167 |
-
#### Software
|
| 168 |
-
|
| 169 |
-
[More Information Needed]
|
| 170 |
-
|
| 171 |
-
## Citation [optional]
|
| 172 |
|
| 173 |
-
|
| 174 |
|
| 175 |
-
|
|
|
|
|
|
|
|
|
|
| 176 |
|
| 177 |
-
|
|
|
|
|
|
|
|
|
|
| 178 |
|
| 179 |
-
|
| 180 |
|
| 181 |
-
|
| 182 |
|
| 183 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 184 |
|
| 185 |
-
|
| 186 |
|
| 187 |
-
|
|
|
|
|
|
|
| 188 |
|
| 189 |
-
##
|
| 190 |
|
| 191 |
-
|
| 192 |
|
| 193 |
-
##
|
| 194 |
|
| 195 |
-
|
|
|
|
|
|
|
| 196 |
|
| 197 |
-
|
| 198 |
|
| 199 |
-
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
---
|
| 2 |
+
license: apache-2.0
|
| 3 |
+
base_model: distilbert-base-uncased
|
| 4 |
+
tags:
|
| 5 |
+
- text-classification
|
| 6 |
+
- email-classification
|
| 7 |
+
- productivity
|
| 8 |
+
- portuguese
|
| 9 |
+
- english
|
| 10 |
+
- multilingual
|
| 11 |
+
- distilbert
|
| 12 |
+
- pytorch
|
| 13 |
+
datasets:
|
| 14 |
+
- custom
|
| 15 |
+
metrics:
|
| 16 |
+
- accuracy
|
| 17 |
+
- f1
|
| 18 |
+
- precision
|
| 19 |
+
- recall
|
| 20 |
+
model-index:
|
| 21 |
+
- name: MiguelJeronimoOliveira/email-classifier
|
| 22 |
+
results: []
|
| 23 |
+
language:
|
| 24 |
+
- pt
|
| 25 |
+
- en
|
| 26 |
+
---
|
| 27 |
+
|
| 28 |
+
# Email Classifier
|
| 29 |
+
|
| 30 |
+
A fine-tuned DistilBERT model for binary classification of emails as productive or unproductive. This model is designed to automatically categorize emails to help prioritize important communications.
|
| 31 |
|
| 32 |
## Model Details
|
| 33 |
|
| 34 |
### Model Description
|
| 35 |
+
- **Model Type**: Text Classification (Binary)
|
| 36 |
+
- **Base Model**: `distilbert-base-uncased`
|
| 37 |
+
- **Task**: Email productivity classification
|
| 38 |
+
- **Language**: Portuguese and English (multilingual)
|
| 39 |
+
- **Labels**:
|
| 40 |
+
- `0`: Unproductive (emails that don't require action)
|
| 41 |
+
- `1`: Productive (emails that require action or response)
|
| 42 |
+
|
| 43 |
+
### Model Architecture
|
| 44 |
+
- **Architecture**: DistilBERT (Distilled BERT)
|
| 45 |
+
- **Max Sequence Length**: 512 tokens
|
| 46 |
+
- **Number of Labels**: 2
|
| 47 |
+
- **Output**: Binary classification with confidence scores
|
| 48 |
+
|
| 49 |
+
## Intended Use
|
| 50 |
+
|
| 51 |
+
### Primary Use Cases
|
| 52 |
+
- **Email Prioritization**: Automatically identify emails that require immediate attention
|
| 53 |
+
- **Productivity Tools**: Integrate into email management systems to filter and organize messages
|
| 54 |
+
- **Auto-Reply Systems**: Determine which emails should trigger automated responses
|
| 55 |
+
- **Email Analytics**: Analyze email patterns and productivity metrics
|
| 56 |
+
|
| 57 |
+
### Out-of-Scope Use Cases
|
| 58 |
+
- Spam detection (this model focuses on productivity, not spam)
|
| 59 |
+
- Sentiment analysis (positive/negative emotions)
|
| 60 |
+
- Topic classification (specific email topics)
|
| 61 |
+
- Language detection (assumes input language is known)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 62 |
|
| 63 |
## Training Details
|
| 64 |
|
| 65 |
### Training Data
|
| 66 |
+
The model was trained on a synthetic dataset of ~6,000 emails (balanced between productive and unproductive) generated using templates that simulate real-world email scenarios. The training data includes:
|
| 67 |
|
| 68 |
+
- **Productive Emails**: Technical support requests, meeting requests, information requests, urgent problems, project discussions, etc.
|
| 69 |
+
- **Unproductive Emails**: Thank you messages, congratulations, holiday greetings, status updates without action required, confirmations, etc.
|
|
|
|
| 70 |
|
| 71 |
### Training Procedure
|
| 72 |
+
- **Training Framework**: Hugging Face Transformers
|
| 73 |
+
- **Optimizer**: AdamW
|
| 74 |
+
- **Learning Rate**: 2e-5
|
| 75 |
+
- **Batch Size**: 8
|
| 76 |
+
- **Epochs**: 5 (with early stopping)
|
| 77 |
+
- **Early Stopping Patience**: 3 epochs
|
| 78 |
+
- **Evaluation Metric**: F1 score
|
| 79 |
+
- **Train/Test Split**: 80/20
|
| 80 |
+
|
| 81 |
+
### Training Features
|
| 82 |
+
- **Data Augmentation**: Template-based generation with variations
|
| 83 |
+
- **Anti-Overfitting Techniques**:
|
| 84 |
+
- Context shuffling (gratitude before/after requests)
|
| 85 |
+
- Negation injection
|
| 86 |
+
- Order inversion
|
| 87 |
+
- Noise injection
|
| 88 |
+
- **Multilingual Support**: Portuguese and English emails in training data
|
| 89 |
|
| 90 |
## Evaluation
|
| 91 |
|
| 92 |
+
### Metrics
|
| 93 |
+
The model was evaluated on a held-out test set with the following metrics:
|
| 94 |
+
|
| 95 |
+
- **Accuracy**: ~0.95+
|
| 96 |
+
- **F1 Score**: ~0.95+
|
| 97 |
+
- **Precision**: ~0.95+
|
| 98 |
+
- **Recall**: ~0.95+
|
| 99 |
+
|
| 100 |
+
*Note: Exact metrics may vary. Please refer to the model card for specific evaluation results.*
|
| 101 |
+
|
| 102 |
+
## How to Use
|
| 103 |
+
|
| 104 |
+
### Installation
|
| 105 |
+
```bash
|
| 106 |
+
pip install transformers torch
|
| 107 |
+
```
|
| 108 |
+
|
| 109 |
+
### Basic Usage
|
| 110 |
+
|
| 111 |
+
#### Using Pipeline
|
| 112 |
+
```python
|
| 113 |
+
from transformers import pipeline
|
| 114 |
+
|
| 115 |
+
classifier = pipeline(
|
| 116 |
+
"text-classification",
|
| 117 |
+
model="MiguelJeronimoOliveira/email-classifier"
|
| 118 |
+
)
|
| 119 |
+
|
| 120 |
+
# Classify an email
|
| 121 |
+
result = classifier("Hi, I need urgent technical support. The system is down.")
|
| 122 |
+
print(result)
|
| 123 |
+
# [{'label': 'LABEL_1', 'score': 0.98}]
|
| 124 |
+
|
| 125 |
+
result = classifier("Thank you for the excellent work!")
|
| 126 |
+
print(result)
|
| 127 |
+
# [{'label': 'LABEL_0', 'score': 0.95}]
|
| 128 |
+
```
|
| 129 |
+
|
| 130 |
+
#### Using Model Directly
|
| 131 |
+
```python
|
| 132 |
+
from transformers import AutoTokenizer, AutoModelForSequenceClassification
|
| 133 |
+
import torch
|
| 134 |
+
|
| 135 |
+
# Load model and tokenizer
|
| 136 |
+
model_name = "MiguelJeronimoOliveira/email-classifier"
|
| 137 |
+
tokenizer = AutoTokenizer.from_pretrained(model_name)
|
| 138 |
+
model = AutoModelForSequenceClassification.from_pretrained(model_name)
|
| 139 |
+
|
| 140 |
+
# Prepare input
|
| 141 |
+
email_text = "Hi, I would like to schedule a meeting to discuss the project timeline."
|
| 142 |
+
inputs = tokenizer(
|
| 143 |
+
email_text,
|
| 144 |
+
truncation=True,
|
| 145 |
+
padding=True,
|
| 146 |
+
max_length=512,
|
| 147 |
+
return_tensors="pt"
|
| 148 |
+
)
|
| 149 |
+
|
| 150 |
+
# Get prediction
|
| 151 |
+
with torch.no_grad():
|
| 152 |
+
outputs = model(**inputs)
|
| 153 |
+
predictions = torch.nn.functional.softmax(outputs.logits, dim=-1)
|
| 154 |
+
predicted_class = predictions.argmax(dim=-1).item()
|
| 155 |
+
confidence = predictions[0][predicted_class].item()
|
| 156 |
+
|
| 157 |
+
# Interpret result
|
| 158 |
+
label = "productive" if predicted_class == 1 else "unproductive"
|
| 159 |
+
print(f"Classification: {label} (confidence: {confidence:.2f})")
|
| 160 |
+
```
|
| 161 |
+
|
| 162 |
+
### Label Mapping
|
| 163 |
+
- `LABEL_0` or `0`: Unproductive
|
| 164 |
+
- `LABEL_1` or `1`: Productive
|
| 165 |
+
|
| 166 |
+
## Limitations and Bias
|
| 167 |
+
|
| 168 |
+
### Known Limitations
|
| 169 |
+
1. **Language Coverage**: While trained on Portuguese and English, performance may vary for other languages
|
| 170 |
+
2. **Domain Specificity**: Model is optimized for business/professional emails; may not perform well on personal emails
|
| 171 |
+
3. **Context Dependency**: Classification is based on email content only; doesn't consider sender, subject line, or metadata
|
| 172 |
+
4. **Synthetic Training Data**: Model was trained on synthetic data, which may not capture all real-world email patterns
|
| 173 |
+
|
| 174 |
+
### Potential Biases
|
| 175 |
+
- The model may have biases based on the training data distribution
|
| 176 |
+
- Cultural and linguistic nuances may affect classification accuracy
|
| 177 |
+
- Technical terminology may be over-represented in productive emails
|
| 178 |
|
| 179 |
+
### Recommendations
|
| 180 |
+
- Fine-tune on your specific email domain for best results
|
| 181 |
+
- Consider combining with other signals (sender, subject, metadata)
|
| 182 |
+
- Regularly evaluate and retrain with new data
|
| 183 |
+
- Use confidence thresholds to filter uncertain predictions
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 184 |
|
| 185 |
+
## Ethical Considerations
|
| 186 |
|
| 187 |
+
### Privacy
|
| 188 |
+
- This model processes email content; ensure compliance with privacy regulations (GDPR, etc.)
|
| 189 |
+
- Consider data anonymization before processing
|
| 190 |
+
- Be transparent about automated email classification to users
|
| 191 |
|
| 192 |
+
### Fairness
|
| 193 |
+
- Monitor for potential biases in classification across different email types
|
| 194 |
+
- Ensure the model doesn't systematically misclassify emails from certain groups or domains
|
| 195 |
+
- Provide mechanisms for users to correct misclassifications
|
| 196 |
|
| 197 |
+
## Citation
|
| 198 |
|
| 199 |
+
If you use this model in your research or application, please cite:
|
| 200 |
|
| 201 |
+
```bibtex
|
| 202 |
+
@misc{email-classifier-2024,
|
| 203 |
+
title={Email Classifier: A Fine-tuned DistilBERT for Productivity Classification},
|
| 204 |
+
author={Miguel Jeronimo Oliveira},
|
| 205 |
+
year={2024},
|
| 206 |
+
howpublished={\url{https://huggingface.co/MiguelJeronimoOliveira/email-classifier}}
|
| 207 |
+
}
|
| 208 |
+
```
|
| 209 |
|
| 210 |
+
## Model Card Contact
|
| 211 |
|
| 212 |
+
For questions, issues, or contributions, please contact:
|
| 213 |
+
- **Model Author**: Miguel Jeronimo Oliveira
|
| 214 |
+
- **Repository**: [AutoU Case Project](https://github.com/your-repo/autou-case)
|
| 215 |
|
| 216 |
+
## License
|
| 217 |
|
| 218 |
+
This model is licensed under the Apache 2.0 License. See the LICENSE file for more details.
|
| 219 |
|
| 220 |
+
## Acknowledgments
|
| 221 |
|
| 222 |
+
- Built on top of DistilBERT by Hugging Face
|
| 223 |
+
- Training infrastructure supported by Hugging Face Transformers
|
| 224 |
+
- Part of the AutoU Case email management system
|
| 225 |
|
| 226 |
+
---
|
| 227 |
|
| 228 |
+
**Model Version**: 1.0.0
|
| 229 |
+
**Last Updated**: 2024
|
| 230 |
+
**Base Model**: distilbert-base-uncased
|
| 231 |
+
**Framework**: PyTorch
|