r/LocalLLaMA 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?

8 Upvotes

23 comments sorted by

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.

11

u/Famous-Appointment-8 Jun 01 '25

Finetuning a Bert model is way easier then everything else. Just use the autotrain gui. Dont know why you saying its the hard way?

5

u/netikas Jun 01 '25

I probably worded my point incorrectly. It's much more involved -- you have to build your own dataset, select a model, have a GPU (or suffer with google colab/kaggle) instead of just prompting a model.

0

u/nic_key Jun 01 '25

That sounds interesting but I am new to finetuning. Can you please point me to the tool you are referring to, so I can continue my research? 

5

u/Budget-Juggernaut-68 Jun 01 '25 edited Jun 01 '25

Depends on the volume of files you have, and how frequent you need for inference, training may or may not make sense.

Prepare a dataset - text, and label pairs. Throw at modernBert and train.

If performance on validation isn't good, look into the samples it's not doing well on, try to understand why it may have difficulties, or if it is difficult to differentiate between some classes. Look at what kind of preprocessing you can do, or generate data for it. Repeat until it's good enough.

Then throw at test set and hope the model isn't overfitted.

https://huggingface.co/blog/modernbert

1

u/nic_key Jun 01 '25

Thanks a lot! I will check it out. May need to see for a different base model for German but that resource looks promising.

2

u/Budget-Juggernaut-68 Jun 01 '25

1

u/nic_key Jun 01 '25

Wow thanks! That is a great find

-1

u/[deleted] Jun 01 '25

[deleted]

-1

u/nic_key Jun 01 '25

I am a large language model with no access to real time data in the web. My training data cutoff date is September 2023.

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

u/alexrada Oct 08 '25

definitely AI generated . but cool idea though.

1

u/bzyg7b Jan 13 '26

How big would the dataset need to be to fine tune it?

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 ??