Developer builds a local spam filter on ruBert-base-antispam, no VPN required

A Habr post describes how the local ruBert-base-antispam model catches spam that slips past the Yandex, Mail and SpamAssassin filters. The 177-million-parameter model uses about 550 MB of memory and responds in 100-200 milliseconds. It weeds out pseudo-spam such as conference invitations and loan mailings.

AI-processed from Habr AI; edited by Hamidun News
Developer builds a local spam filter on ruBert-base-antispam, no VPN required
Source: Habr AI. Collage: Hamidun News.
Listen to article
Article Fact Sheet & Key Figures
ParameterDetails
Primary sourceHabr AI ↗
Editor-in-Chief
ModelruBert-base-antispam from HuggingFace, a fine-tune of DeepPavlov/rubert-base-cased-conversational
Key metric #2177 million parameters, 12 transformer layers, hidden size 768
Input limit512 tokens

A developer has described on Habr how he built a multi-layer email spam filtering system that runs without a VPN. Its newest layer is ruBert-base-antispam from HuggingFace, a fine-tune of DeepPavlov/rubert-base-cased-conversational with 177 million parameters that needs only about 550 MB of RAM.

How the multi-layer filtering works

The author already blocks ads with his own DNS server and local CSS filters, but email spam required separate work. The setup runs in several sequential stages. First, the built-in Yandex and Mail filters check incoming messages and remove some of the spam before it is forwarded to another mailbox. Whatever gets through lands on the author's own server, where SpamAssassin catches another share of the junk.

Even after two layers, some messages still slip through and reach Gmail. Some end up automatically in the Spam folder; others hit the inbox with an annoying notification. The author wanted to stop junk from piling up in his folders over time and having to clean it out by hand. Spammers, he notes, aren't sitting idle either: they keep updating their techniques for getting past filters.

Why standard filters weren't enough

The biggest problem came from messages that don't technically break any rules: conference invitations, partnership offers, loan mailings. A Bayesian filter handles these poorly because they lack the obvious markers of classic spam — they are simply intrusive and of little value to the recipient. The three earlier filtering layers couldn't cover this gray zone between "definitely spam" and "definitely not spam." The author needed a separate tool that could judge what an email actually means, not just the formal traits of a mass 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 usage: about 550 MB; responses take 100-200 milliseconds
  • Binary classifier: outputs only 0 or 1, with no prompts and no reasoning

Which model the author chose

The local BERT model solved both problems at once: the buildup of semi-spam and the author's reluctance to depend on paid cloud APIs. ruBert-base-antispam is a binary classifier. It takes an email's text as input and returns 0 or 1 — no prompts and no reasoning, unlike large language models. That architectural simplicity is what delivers 100-200 millisecond responses with about 550 MB of memory, so the model can run continuously on an ordinary home server without putting extra load on the system.

The 512-token input limit isn't a problem for spam filtering. The model doesn't need to analyze the whole email; the first few paragraphs are enough to tell what kind of message it is. The base model behind the fine-tune, DeepPavlov/rubert-base-cased-conversational, was originally trained on conversational Russian, which should help it more accurately separate genuine correspondence from advertising and semi-advertising mailings.

What it means

The case shows that narrow, practical tasks like spam filtering don't require large cloud LLMs. A small local BERT model with 177 million parameters does the job faster and cheaper, running fully offline and without a VPN.

FAQ

Which model does the author use for spam filtering?

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

How many resources does this local model need?

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

Story

Key Questions Answered

Which model does the author use for spam filtering?

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

How many resources does this local model need?

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

How the multi-layer filtering works?

The author already blocks ads with his own DNS server and local CSS filters, but email spam required separate work. The setup runs in several sequential stages. First, the built-in Yandex and Mail filters check incoming messages and remove some of the spam before it is forwarded to another mailbox. Whatever gets through lands on the author's own server, where SpamAssassin catches another share of the junk. Even after two layers, some messages still slip through and reach Gmail. Some end up automatically in the Spam folder; others hit the inbox with an annoying notification.

ZK
Zhemal Khamidun — CPO at Alpina Digital, product manager of AlpinaGPT. Building AI products since 2019. Hamidun News is a pet project that grew into a production aggregator with 6,000+ readers.
✦ Unified AI Workspace · Nomad

Test Frontier LLMs & Autonomous Agents in One Workspace

Run Claude Opus 5.5, GPT-6, Gemini 3.1, and DeepSeek side-by-side in Nomad AI (nomadnet.ai) — unified model routing, deep research, and multimodal workflows under one subscription.

Try Nomad AI →Launch Nomad Agent
What do you think?
Loading comments…