1import json
2import torch
3from transformers import pipeline
4
5LABELS = ["automated_reply", "interested", "not_interested", "out_of_office", "unrelated"]
6SYSTEM_PROMPT = (
7 "You are an email-response classifier. "
8 f"Classify the email into exactly one of: {', '.join(LABELS)}. "
9 'Reply ONLY with a JSON object in the format: {"classification": "<label>"}. '
10 "Do not add any explanation."
11)
12
13gen = pipeline(
14 "text-generation",
15 model="OmarioVIC/customer-email-classifier",
16 device=0 if torch.cuda.is_available() else -1,
17 do_sample=False,
18)
19
20def classify(email_text: str) -> str:
21 messages = [{"role": "user", "content": f"{SYSTEM_PROMPT}\n\nEmail text:\n{email_text}"}]
22 prompt = gen.tokenizer.apply_chat_template(messages, tokenize=False, add_generation_prompt=True)
23 output = gen(prompt, max_new_tokens=20)
24 generated = output[0]["generated_text"].split("<start_of_turn>model")[-1].strip()
25 return json.loads(generated)["classification"]
26
27print(classify("Yeah, Monday works — book a 15-min call."))
28# → "interested"
1pip install vllm
2
3vllm serve OmarioVIC/customer-email-classifier \
4 --dtype bfloat16 \
5 --max-model-len 512
1curl http://localhost:8000/v1/chat/completions \
2 -H "Content-Type: application/json" \
3 -d '{
4 "model": "OmarioVIC/customer-email-classifier",
5 "messages": [{
6 "role": "user",
7 "content": "Classify into one of: automated_reply, interested, not_interested, out_of_office, unrelated. Reply with JSON only: {\"classification\": \"<label>\"}.\n\nEmail text:\nyeah 15 mins call? free monday"
8 }],
9 "max_tokens": 20,
10 "temperature": 0
11 }'
1{
2 "messages": [
3 {
4 "role": "user",
5 "content": "<system prompt>\n\nEmail text:\n<raw email body>"
6 },
7 {
8 "role": "assistant",
9 "content": "{\"classification\": \"interested\"}"
10 }
11 ]
12}
Only the assistant turn is used for loss computation (completion-only masking via train_on_responses_only).
Training was accelerated using
Unsloth, which provides:
This model is derived from
google/gemma-3-1b-it and is subject to the
Gemma Terms of Use.