Update README.md
Browse files
README.md
CHANGED
|
@@ -1,3 +1,135 @@
|
|
| 1 |
-
---
|
| 2 |
-
license: mit
|
| 3 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
---
|
| 2 |
+
license: mit
|
| 3 |
+
license_link: https://huggingface.co/microsoft/Phi-3-mini-4k-instruct/resolve/main/LICENSE
|
| 4 |
+
language:
|
| 5 |
+
- en
|
| 6 |
+
pipeline_tag: text-classification
|
| 7 |
+
tags:
|
| 8 |
+
- email-classification
|
| 9 |
+
- mlx
|
| 10 |
+
- phi-3
|
| 11 |
+
- lora
|
| 12 |
+
- text-classification
|
| 13 |
+
library_name: mlx
|
| 14 |
+
base_model: microsoft/Phi-3-mini-4k-instruct
|
| 15 |
+
datasets:
|
| 16 |
+
- private
|
| 17 |
+
widget:
|
| 18 |
+
- text: "Classify this email:\n\nYour order #12345 has been shipped and will arrive in 3-5 business days.\n\nCategory:"
|
| 19 |
+
example_title: "Transactional Email"
|
| 20 |
+
- text: "Classify this email:\n\n🎉 Limited Time Offer! Get 50% off all products this weekend only!\n\nCategory:"
|
| 21 |
+
example_title: "Promotional Email"
|
| 22 |
+
- text: "Classify this email:\n\nYour password was changed on December 7, 2025. If you didn't make this change, please contact support immediately.\n\nCategory:"
|
| 23 |
+
example_title: "Security Alert"
|
| 24 |
+
---
|
| 25 |
+
|
| 26 |
+
# Email Classifier - Phi-3 Mini Fine-tuned
|
| 27 |
+
|
| 28 |
+
This model is a fine-tuned version of [microsoft/Phi-3-mini-4k-instruct](https://huggingface.co/microsoft/Phi-3-mini-4k-instruct) for email classification tasks. It uses LoRA (Low-Rank Adaptation) for efficient fine-tuning on Apple Silicon using the MLX framework.
|
| 29 |
+
|
| 30 |
+
## Model Description
|
| 31 |
+
|
| 32 |
+
- **Base Model**: microsoft/Phi-3-mini-4k-instruct
|
| 33 |
+
- **Fine-tuning Method**: LoRA (Low-Rank Adaptation)
|
| 34 |
+
- **Framework**: Apple MLX
|
| 35 |
+
- **Task**: Email Classification
|
| 36 |
+
- **Categories**: 20 email categories including promotional, transactional, notification, security, event, educational, newsletter, survey, business, personal, and more
|
| 37 |
+
|
| 38 |
+
## Intended Use
|
| 39 |
+
|
| 40 |
+
This model classifies emails into predefined categories to help with inbox organization, email filtering, and workflow automation.
|
| 41 |
+
|
| 42 |
+
### Direct Use
|
| 43 |
+
|
| 44 |
+
```python
|
| 45 |
+
from mlx_lm import load, generate
|
| 46 |
+
|
| 47 |
+
# Load the model
|
| 48 |
+
model, tokenizer = load("jake-watkins/email-classifier")
|
| 49 |
+
|
| 50 |
+
# Classify an email
|
| 51 |
+
email_content = """
|
| 52 |
+
Your subscription to Premium Service will renew on January 1st, 2026.
|
| 53 |
+
To cancel or modify your subscription, visit your account settings.
|
| 54 |
+
"""
|
| 55 |
+
|
| 56 |
+
prompt = f"Classify this email:\n\n{email_content}\n\nCategory:"
|
| 57 |
+
|
| 58 |
+
response = generate(model, tokenizer, prompt=prompt, max_tokens=50, verbose=False)
|
| 59 |
+
print(response)
|
| 60 |
+
```
|
| 61 |
+
|
| 62 |
+
## Training Data
|
| 63 |
+
|
| 64 |
+
The model was trained on a private dataset of email examples across 20 categories:
|
| 65 |
+
- promotional
|
| 66 |
+
- transactional
|
| 67 |
+
- notification
|
| 68 |
+
- security
|
| 69 |
+
- event
|
| 70 |
+
- educational
|
| 71 |
+
- newsletter
|
| 72 |
+
- survey
|
| 73 |
+
- business
|
| 74 |
+
- personal
|
| 75 |
+
- solicitation
|
| 76 |
+
- recruitment
|
| 77 |
+
- membership
|
| 78 |
+
- political
|
| 79 |
+
- informative
|
| 80 |
+
- account
|
| 81 |
+
- press
|
| 82 |
+
- memorial
|
| 83 |
+
- file
|
| 84 |
+
- admission
|
| 85 |
+
|
| 86 |
+
## Training Procedure
|
| 87 |
+
|
| 88 |
+
### Training Hyperparameters
|
| 89 |
+
|
| 90 |
+
- **Iterations**: 699
|
| 91 |
+
- **Learning Rate**: 1e-5
|
| 92 |
+
- **Batch Size**: 1
|
| 93 |
+
- **Max Sequence Length**: 512 tokens
|
| 94 |
+
- **LoRA Layers**: 16
|
| 95 |
+
- **Steps per Eval**: 100
|
| 96 |
+
- **Validation Batches**: 25
|
| 97 |
+
|
| 98 |
+
### Framework
|
| 99 |
+
|
| 100 |
+
Fine-tuned using MLX-LM on Apple Silicon with LoRA adapters for parameter-efficient training.
|
| 101 |
+
|
| 102 |
+
## Evaluation
|
| 103 |
+
|
| 104 |
+
The model was validated on a held-out test set with stratified sampling to maintain category distribution across training, validation, and test splits (80/10/10).
|
| 105 |
+
|
| 106 |
+
## Limitations
|
| 107 |
+
|
| 108 |
+
- **Language**: Primarily trained on English emails
|
| 109 |
+
- **Context Length**: Optimized for sequences up to 512 tokens; longer emails are truncated
|
| 110 |
+
- **Categories**: Limited to the 20 predefined categories; may not generalize to novel email types
|
| 111 |
+
- **Domain**: Performance may vary on highly specialized or domain-specific emails
|
| 112 |
+
|
| 113 |
+
## Ethical Considerations
|
| 114 |
+
|
| 115 |
+
This model is intended for email organization and automation purposes. Users should:
|
| 116 |
+
- Ensure compliance with privacy regulations when processing email content
|
| 117 |
+
- Not use for unauthorized email monitoring or surveillance
|
| 118 |
+
- Be aware that classification errors may occur
|
| 119 |
+
|
| 120 |
+
## Citation
|
| 121 |
+
|
| 122 |
+
If you use this model, please cite the base model:
|
| 123 |
+
|
| 124 |
+
```bibtex
|
| 125 |
+
@article{abdin2024phi,
|
| 126 |
+
title={Phi-3 Technical Report: A Highly Capable Language Model Locally on Your Phone},
|
| 127 |
+
author={Abdin, Marah and others},
|
| 128 |
+
journal={arXiv preprint arXiv:2404.14219},
|
| 129 |
+
year={2024}
|
| 130 |
+
}
|
| 131 |
+
```
|
| 132 |
+
|
| 133 |
+
## Model Card Contact
|
| 134 |
+
|
| 135 |
+
For questions or feedback about this model, please open an issue on the model repository.
|