Instructions to use distil-labs/distil-email-classifier with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use distil-labs/distil-email-classifier with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="distil-labs/distil-email-classifier") messages = [ {"role": "user", "content": "Who are you?"}, ] pipe(messages)# Load model directly from transformers import AutoTokenizer, AutoModelForCausalLM tokenizer = AutoTokenizer.from_pretrained("distil-labs/distil-email-classifier") model = AutoModelForCausalLM.from_pretrained("distil-labs/distil-email-classifier") messages = [ {"role": "user", "content": "Who are you?"}, ] inputs = tokenizer.apply_chat_template( messages, add_generation_prompt=True, tokenize=True, return_dict=True, return_tensors="pt", ).to(model.device) outputs = model.generate(**inputs, max_new_tokens=40) print(tokenizer.decode(outputs[0][inputs["input_ids"].shape[-1]:])) - llama-cpp-python
How to use distil-labs/distil-email-classifier with llama-cpp-python:
# !pip install llama-cpp-python from llama_cpp import Llama llm = Llama.from_pretrained( repo_id="distil-labs/distil-email-classifier", filename="model.gguf", )
llm.create_chat_completion( messages = [ { "role": "user", "content": "What is the capital of France?" } ] ) - Inference
- Notebooks
- Google Colab
- Kaggle
- Local Apps
- llama.cpp
How to use distil-labs/distil-email-classifier with llama.cpp:
Install from brew
brew install llama.cpp # Start a local OpenAI-compatible server with a web UI: llama-server -hf distil-labs/distil-email-classifier # Run inference directly in the terminal: llama-cli -hf distil-labs/distil-email-classifier
Install from WinGet (Windows)
winget install llama.cpp # Start a local OpenAI-compatible server with a web UI: llama-server -hf distil-labs/distil-email-classifier # Run inference directly in the terminal: llama-cli -hf distil-labs/distil-email-classifier
Use pre-built binary
# Download pre-built binary from: # https://github.com/ggerganov/llama.cpp/releases # Start a local OpenAI-compatible server with a web UI: ./llama-server -hf distil-labs/distil-email-classifier # Run inference directly in the terminal: ./llama-cli -hf distil-labs/distil-email-classifier
Build from source code
git clone https://github.com/ggerganov/llama.cpp.git cd llama.cpp cmake -B build cmake --build build -j --target llama-server llama-cli # Start a local OpenAI-compatible server with a web UI: ./build/bin/llama-server -hf distil-labs/distil-email-classifier # Run inference directly in the terminal: ./build/bin/llama-cli -hf distil-labs/distil-email-classifier
Use Docker
docker model run hf.co/distil-labs/distil-email-classifier
- LM Studio
- Jan
- vLLM
How to use distil-labs/distil-email-classifier with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "distil-labs/distil-email-classifier" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "distil-labs/distil-email-classifier", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker
docker model run hf.co/distil-labs/distil-email-classifier
- SGLang
How to use distil-labs/distil-email-classifier with SGLang:
Install from pip and serve model
# Install SGLang from pip: pip install sglang # Start the SGLang server: python3 -m sglang.launch_server \ --model-path "distil-labs/distil-email-classifier" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "distil-labs/distil-email-classifier", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker images
docker run --gpus all \ --shm-size 32g \ -p 30000:30000 \ -v ~/.cache/huggingface:/root/.cache/huggingface \ --env "HF_TOKEN=<secret>" \ --ipc=host \ lmsysorg/sglang:latest \ python3 -m sglang.launch_server \ --model-path "distil-labs/distil-email-classifier" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "distil-labs/distil-email-classifier", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }' - Ollama
How to use distil-labs/distil-email-classifier with Ollama:
ollama run hf.co/distil-labs/distil-email-classifier
- Unsloth Studio new
How to use distil-labs/distil-email-classifier with Unsloth Studio:
Install Unsloth Studio (macOS, Linux, WSL)
curl -fsSL https://unsloth.ai/install.sh | sh # Run unsloth studio unsloth studio -H 0.0.0.0 -p 8888 # Then open http://localhost:8888 in your browser # Search for distil-labs/distil-email-classifier to start chatting
Install Unsloth Studio (Windows)
irm https://unsloth.ai/install.ps1 | iex # Run unsloth studio unsloth studio -H 0.0.0.0 -p 8888 # Then open http://localhost:8888 in your browser # Search for distil-labs/distil-email-classifier to start chatting
Using HuggingFace Spaces for Unsloth
# No setup required # Open https://huggingface.co/spaces/unsloth/studio in your browser # Search for distil-labs/distil-email-classifier to start chatting
- Pi new
How to use distil-labs/distil-email-classifier with Pi:
Start the llama.cpp server
# Install llama.cpp: brew install llama.cpp # Start a local OpenAI-compatible server: llama-server -hf distil-labs/distil-email-classifier
Configure the model in Pi
# Install Pi: npm install -g @mariozechner/pi-coding-agent # Add to ~/.pi/agent/models.json: { "providers": { "llama-cpp": { "baseUrl": "http://localhost:8080/v1", "api": "openai-completions", "apiKey": "none", "models": [ { "id": "distil-labs/distil-email-classifier" } ] } } }Run Pi
# Start Pi in your project directory: pi
- Hermes Agent new
How to use distil-labs/distil-email-classifier with Hermes Agent:
Start the llama.cpp server
# Install llama.cpp: brew install llama.cpp # Start a local OpenAI-compatible server: llama-server -hf distil-labs/distil-email-classifier
Configure Hermes
# Install Hermes: curl -fsSL https://hermes-agent.nousresearch.com/install.sh | bash hermes setup # Point Hermes at the local server: hermes config set model.provider custom hermes config set model.base_url http://127.0.0.1:8080/v1 hermes config set model.default distil-labs/distil-email-classifier
Run Hermes
hermes
- Docker Model Runner
How to use distil-labs/distil-email-classifier with Docker Model Runner:
docker model run hf.co/distil-labs/distil-email-classifier
- Lemonade
How to use distil-labs/distil-email-classifier with Lemonade:
Pull the model
# Download Lemonade from https://lemonade-server.ai/ lemonade pull distil-labs/distil-email-classifier
Run and chat with the model
lemonade run user.distil-email-classifier-{{QUANT_TAG}}List all available models
lemonade list
We fine-tuned an email classification model so you can auto-label your emails locally with n8n.
We built a fully local Gmail auto-labeler with n8n + a fine-tuned 0.6B model (no email content sent to cloud LLMs)
Most of our inboxes are a mix of useful and distracting. Labels can help making order from the chaos - but labelling all emails manually takes time too.
We put together a setup that auto-labels Gmail locally, so email content does not go to external LLM APIs.
What it does (end-to-end local):
- n8n trigger when you receive an email
- It sends the email text (subject + snippet/body) to a fine-tuned model running on localhost via Ollama
- It applies the predicted label back in Gmail (we recommend prefixing labels with AI/)
Label set (10-way closed set):
Billing, Newsletter, Work, Personal, Promotional, Security, Shipping, Travel, Spam, Other
Results:
| Model | Accuracy |
|---|---|
| Teacher (GPT-OSS-120B) | 93% |
| Base student (Qwen3-0.6B) | 38% |
| Fine-tuned student (Qwen3-0.6B) | 93% |
Traning setup
| Student model | Qwen3-0.6B (600M parameters) |
|---|---|
| Teacher model | GPT-OSS-120B |
| Training method | Knowledge distillation + supervised fine-tuning (SFT) |
| Seed data | 154 examples |
| Training data | 10,000 synthetic email examples across 10 categories generated using our data synthesis pipeline |
System Setup
Installation Steps:
- Install n8n locally
# Install Node.js (if not installed)
brew install node
# Install n8n globally
npm install -g n8n
# Start n8n
n8n
Access n8n at: http://localhost:5678
- Download the model
#install huggingface CLI if not instlalled
python3 -m pip install -U huggingface_hub
#download the model
hf download distil-labs/distil-email-classifier --local-dir ./distil-email-classifier
- Run the model
#install Ollama or you can download from https://ollama.com/download
brew install ollama
#start Ollama
ollama serve
#navigate to your model folder
cd ./distil-email-classifier
#create model in ollama
ollama create email-classifier -f Modelfile
#verify the model is created or not
ollama list
#run the model
ollama run email-classifier "test"
#check the model is running or not
ollama ps
Expected output:
NAME ID SIZE PROCESSOR CONTEXT UNTIL
email-classifier:latest 695190b0f07f 3.5 GB 100% GPU 4096 4 minutes from now
#to keep model running forver run the below commands
OLLAMA_KEEP_ALIVE=-1 ollama run email-classifier "test"
Now shows Forever instead of 4 minutes from now.
Once you finish the setup, open n8n in your browser (http://localhost:5678), sign up with your email, and you get an access code from n8n for your email, you can update the access code.
Import n8n workflows
Download the workflow JSON files from our GitHub repository: https://github.com/distil-labs/distil-n8n-gmail-automation
Two workflows are available:
- Real-time Classification: Triggers automatically on each incoming email
- Batch Processing: Classifies multiple existing emails at once
To connect your Gmail you need to setup Gmail OAuth (Google cloud console) you can find detailed steps on this on github readme.
Before running the workflow, create all 10 labels manually in your Gmail account. Use the "AI/" prefix to match the model output (AI/Billing, AI/Work, AI/Travel, and so on).
Once this is running, New messages get labeled automatically.
If you want different labels, you can distill a custom version of this classifier on the distil labs platform. When you sign up, you get two free training credits to train the model.
Full Write up: https://www.distillabs.ai/blog/building-a-local-agent-for-email-classification-using-n8n-distil-labs
workflows: https://github.com/distil-labs/distil-n8n-gmail-automation
Model: https://huggingface.co/distil-labs/distil-email-classifier
- Downloads last month
- 494