We built a fully local Gmail auto-labeler with n8n + a fine-tuned 0.6B model (no email content sent to cloud LLMs).
Most inboxes are a mix of useful and distracting. Labels help bring order to the chaos, but manually labeling everything takes time. We put together a setup that auto-labels Gmail entirely locally, so no email content ever hits external LLM APIs.
Full write-up: distillabs.ai/blog/building-a-local-agent-for-email-classification-using-n8n-distil-labs
Workflows: github.com/distil-labs/distil-n8n-gmail-automation
Model: huggingface.co/distil-labs/distil-email-classifier
How it works
n8n triggers when you receive an email Email text (subject + snippet) is sent to a fine-tuned model running locally via Ollama The predicted label is applied back in Gmail (we recommend prefixing with AI/)
Label set (10 categories): Billing, Newsletter, Work, Personal, Promotional, Security, Shipping, Travel, Spam, Other
Results
Model Accuracy
Teacher (GPT-OSS-120B) 93%
Base Qwen3-0.6B 38%
Fine-tuned Qwen3-0.6B 93%
The base model struggles with overlapping categories (Newsletter vs Promotional, etc.). After distillation + SFT, the 0.6B model matches the 120B teacher.
Training details
Student: Qwen3-0.6B (600M params) Teacher: GPT-OSS-120B Method: Knowledge distillation + supervised fine-tuning Seed data: 154 examples Training data: 10K synthetic emails across 10 categories
Quick setup
Install and start n8n
npm install -g n8n
n8n
Access at http://localhost:5678
Download and run the model
hf download distil-labs/distil-email-classifier --local-dir ./distil-email-classifier
ollama create email-classifier -f Modelfile
ollama run email-classifier "test"
To keep model loaded permanently:
OLLAMA_KEEP_ALIVE=-1 ollama run email-classifier "test"Then import our workflow JSONs from GitHub. Two options available:
Real-time: Triggers on each incoming email Batch: Classifies multiple existing emails at once
You’ll need to set up Gmail OAuth (steps in the GitHub readme) and create the 10 labels in Gmail with the AI/ prefix (AI/Billing, AI/Work, etc.).
Custom labels
Want different labels? You can distill a custom classifier on our platform. You get 2 free training credits when you sign up.
💬 Discussion r/LocalLLM (44 points, 9 commentaires) 🔗 Source