Email Triage SLM
LoRA fine-tuned small language model for email triage. Classifies incoming emails and generates structured triage outputs including classification, priority, suggested actions, and draft responses.
Model Details
- Base Model: Qwen/Qwen3-4B-Instruct-2507 (4B parameters)
- Fine-tuning Method: LoRA (Low-Rank Adaptation)
- Task: Email classification and structured triage
- License: MIT
Training Details
Hyperparameters
| Parameter | Value |
|---|---|
| LoRA Rank | 32 |
| Learning Rate | 1e-4 |
| Batch Size | 4 |
| Epochs | 3 |
| Loss | Cross-entropy (prompt masked, completion weighted) |
Training Data
- Dataset: jason23322/high-accuracy-email-classifier
- Categories: Spam, Promotions, Verify_code, Updates, Forum, Social_media
- Format: Structured prompt/completion pairs with EOS tokens for stopping behavior
Output Format
The model produces structured triage output in four steps:
Step 1: Classification β {category}
Step 2: Priority β {High|Medium|Low}
Step 3: Suggested actions β {action_items}
Step 4: Drafted response β {draft_response}
Category-to-Priority Mapping:
verify_codeβ High priority, urgent action requiredspam/promotionsβ Low priority, delete/mark as spamupdatesβ Medium priority, read and acknowledgeforum/social_mediaβ Medium priority, read later
Usage
With Transformers + PEFT
from transformers import AutoModelForCausalLM, AutoTokenizer
from peft import PeftModel
base_model = "Qwen/Qwen3-4B-Instruct-2507"
adapter_path = "path/to/adapters/email_triage_final"
model = AutoModelForCausalLM.from_pretrained(base_model)
model = PeftModel.from_pretrained(model, adapter_path)
tokenizer = AutoTokenizer.from_pretrained(base_model)
prompt = """You are an efficient admin assistant. Analyze this incoming email step-by-step and output in structured format:
Email:
Subject: Your order has shipped!
Hi [Customer Name], Your recent order #[ORDER NUMBER] has shipped and is on its way. You can track your package here: [Tracking Link]. Thanks for shopping with us!"""
inputs = tokenizer(prompt, return_tensors="pt")
outputs = model.generate(**inputs, max_new_tokens=256, temperature=0.7, do_sample=True)
response = tokenizer.decode(outputs[0], skip_special_tokens=True)
Inference API
When running the included FastAPI server:
curl -X POST http://localhost:8000/inference \
-H "Content-Type: application/json" \
-d '{
"prompt": "You are an efficient admin assistant. Analyze this incoming email step-by-step and output in structured format:\n\nEmail:\nSubject: Your order has shipped!\n...",
"max_tokens": 256,
"temperature": 0.7
}'
Important: Use the exact prompt format above for best results. The model was trained with this structure.
Intended Use
- Email inbox triage and prioritization
- Administrative assistant workflows
- Automated email classification and routing
- Draft response generation for common email types
Limitations
- Trained on a specific dataset (400 examples default); may not generalize to all email domains
- Structured output format is fixed; customization requires retraining
- Base model (Qwen3-4B) is hardcoded; adapter is not compatible with other base models
- May misclassify edge cases or emails in languages underrepresented in training data
Bias & Safety
- Inherits base model biases; evaluate outputs for your use case
- Training data reflects the distribution of the source dataset
- Not intended for high-stakes decisions without human review
Training Infrastructure
Trained using Tinker Labs distributed training API. For full training pipeline, dataset preparation, and local inference setup, see the project repository.
Citation
@misc{email-triage-slm,
title={Email Triage SLM: LoRA Fine-tuned Model for Email Classification},
author={Shanvit S Shetty},
year={2026},
url={https://huggingface.co/your-username/email-triage-slm}
howpublished={\url{https://github.com/Shanvit7/email-triage-slm}}
}
Repository: github.com/Shanvit7/email-triage-slm
Model tree for Shanvit/email-triage-slm
Base model
Qwen/Qwen3-4B-Instruct-2507