Habr AI→ original

Developer Built a Local Spam Filter with ruBert-base-antispam Model Without VPN

On Habr, developers described how a local ruBert-base-antispam model catches spam that slips through Yandex, Mail, and SpamAssassin filters. The 177-million-parameter model uses around 550 MB of memory and responds in 100-200 milliseconds, filtering out pseudo-spam like conference invitations and credit-offer mailings.

AI-processed from Habr AI; edited by Hamidun News
Developer Built a Local Spam Filter with ruBert-base-antispam Model Without VPN
Source: Habr AI. Collage: Hamidun News.
◐ Listen to article

A developer described on Habr how he built a multi-level email spam filtering system without VPN, adding to it a local ruBert-base-antispam model from HuggingFace — a fine-tune of DeepPavlov/rubert-base-cased-conversational with 177 million parameters, which requires about 550 MB of RAM.

How multi-level filtering is organized

Ads on the author's system are blocked through a custom DNS server and local CSS filters, but email spam required separate handling. The scheme is built in several sequential stages: first emails are checked by built-in Yandex and Mail filters — they filter out some spam before it's forwarded to another mailbox. What passes through them reaches the author's own server, where SpamAssassin sits and catches more garbage.

After two levels, some emails still seep through and reach Gmail: some automatically end up in the "Spam" folder, while others arrive in the inbox with an annoying notification. The author wanted to prevent spam from piling up in folders over time, which has to be cleaned up manually — and spammers, according to him, don't sit idle and constantly update their evasion techniques.

Why standard filters weren't enough

A particular problem was caused by emails that are not formally a violation: conference invitations, partnership offers, credit card mailings. Bayesian filters catch such messages poorly because they lack obvious signs of classic spam — only annoyingness and low value to the recipient. It was this gray zone between "definitely spam" and "definitely not spam" that the previous three levels of filtering couldn't cover, and a separate tool was needed, capable of evaluating the meaning of an email, not just formal signs of a mailing.

  • Model — ruBert-base-antispam from HuggingFace, a fine-tune of DeepPavlov/rubert-base-cased-conversational
  • 177 million parameters, 12 transformer layers, hidden size 768
  • Input limit — 512 tokens
  • Memory consumption — about 550 MB, response takes 100-200 milliseconds
  • Binary classifier: output is only 0 or 1, no prompts or reasoning

What model the author chose

A local BERT model solved both problems at once — both spam accumulation and unwillingness to depend on paid cloud APIs. ruBert-base-antispam is a binary classifier: text of an email goes in, 0 or 1 comes out, no prompts or reasoning like in large language models. This simplicity of architecture gives response speed of 100-200 milliseconds at about 550 MB of memory — the model can be kept constantly running on an ordinary home server without worrying about extra load.

The 512-token input limit is not critical for spam filtering: you don't need to analyze the entire email, the first paragraphs are enough to understand its character. At the same time, the base DeepPavlov/rubert-base-cased-conversational model, on which the fine-tune is built, was originally trained on conversational Russian — this should help more accurately distinguish live correspondence from advertising and semi-advertising mailings.

What this means

The case shows that for narrow applied tasks like spam filtering, large cloud LLMs are not necessary: a small local BERT model with 177 million parameters handles faster and cheaper, working completely offline and without VPN.

Frequently asked questions

What model does the author use for spam filtering?

It's ruBert-base-antispam from HuggingFace — a fine-tune of DeepPavlov/rubert-base-cased-conversational, 177 million parameters, 12 transformer layers and hidden size 768.

How many resources does such a local model require?

The model needs about 550 MB of RAM, and response to one text takes 100-200 milliseconds; maximum input length is limited to 512 tokens.

ZK
Hamidun News
AI news without noise. Daily editorial selection from 50+ sources. A product by Zhemal Khamidun, Head of AI at Alpina Digital.

Need AI working inside your business — not just in your newsfeed?

I build production AI for companies — custom CRM, internal tools, autonomous agents, workflow automation. Owned by you, shaped to your process, no per-seat tax. Built by Zhemal Khamidun, CPO of AlpinaGPT (AI platform, 6,000+ users).

What do you think?
Loading comments…