jason23322/high-accuracy-email-classifier
Viewer β’ Updated β’ 13.5k β’ 75 β’ 18
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.
| Parameter | Value |
|---|---|
| LoRA Rank | 32 |
| Learning Rate | 1e-4 |
| Batch Size | 4 |
| Epochs | 3 |
| Loss | Cross-entropy (prompt masked, completion weighted) |
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 laterfrom 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)
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.
Trained using Tinker Labs distributed training API. For full training pipeline, dataset preparation, and local inference setup, see the project repository.
@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
Base model
Qwen/Qwen3-4B-Instruct-2507