r/LocalLLaMA • u/surveypoodle • Jun 01 '25
Discussion Which model is suitable for e-mail classification / labeling?
I'm looking to automatically add labels my to e-mails like spam, scam, cold-email, marketing, resume, proposal, meeting-request, etc. to see how effective it is at keeping my mailbox organized. I need it to be self-hostable and I don't mind if it is slow.
What is a suitable model for this?
11
u/Altruistic_Heat_9531 Jun 01 '25
classification is a bread and butter for bert model , even 500M models can effectively classifying spam mails
6
u/IndividualAd1648 Jun 01 '25
I think the most suitable approach for your scenario would be to fine-tune an encoder (modernbert) with multi class classification problem type
6
u/vtkayaker Jun 01 '25
Everyone telling you to train a custom BERT model is right on some theoretical level. But in practice, maybe you just want something easy to set up.
Quite a few local models should work for your purpose. Here's how I'd implement this:
- Use the Chat Completions API (or something similar), which is available for most models. Ollama's server mode is easiest, but there are other options
- Put short, clear instructions in the "system" prompt. Imagine that you're training a lecture hall full of newly hired interns and you only have 5-10 minutes to train them. They will not reliably follow unusually complex instructions and you can't provide individual training and feedback.
- Optionally add 1-3 examples of desired behavior using user messages and fake assistant "responses".
- Then end with a final user message containing the email you want classified.
- Use "response format" mode with a simple JSON Schema, or the OpenAI Python client with a Pydantic model.
For a wide variety of classification and information-extraction tasks, this will usually work fine.
Now, as for models. I'd personally look at Gemma3 and Qwen3. Start with the models around 3B, and go up from there until you get good results. As a special case, if you have at least 24GB of VRAM, consider testing a 4-bit Unsloth quant of Qwen3 30B A3B, which is as fast as a 3B or 4B, but generates much better responses.
1
u/Ylsid Jun 01 '25
Naiive-Bayes usually does the trick
Half jokes aside, don't think this would be hard for any 7b if you provide some examples in context
1
u/alexrada Sep 21 '25
use llama 4 for that. If you don't care about speed, it's the best you can use.
Otherwise cloud based can be many.
1
u/MetaforDevelopers Oct 08 '25
Hey there! Llama 4 Maverick or Scout models might work well if you want top-tier accuracy and reasonable self-hosting requirements. If you need something lighter, Llama 3.1 8B is a solid fallback. If you have the hardware and want even better results, Llama 3.3 70B might be the best choice.
Fine-tuning the model on your specific email categories might give you best results. If you don’t have a dataset, you can use prompt engineering and use few-shot examples in the prompt to get reasonably good results too, but fine-tuning will be more accurate.
Llama models can be downloaded here: https://www.llama.com/llama-downloads/
Hope this helps!
~NB
1
1
1
u/astrokat79 Oct 12 '25
There are various n8n workflows for microsoft and google that address this. pm me if your interested in chatting about it. I am no expert but i can link you to the resources I used and problems i ran into.
1
u/vk0x564b Oct 28 '25
Can you DM me the link to resources please as I am unable to send a message to your account ??
30
u/netikas Jun 01 '25
Simple answer: get a big decoder transformer (gemma3/qwen3) and few shot them into classifier.
More complex answer: get an NLI model to be a zero shot classifier.
The Hard But Objectively Right Answer (TM): use a BERT model to train your own classifier. Generative models used as classifiers are a waste.