[Rspamd-Users] Issue with training additional Bayes classes

SolNet rspamd at solnet.ch
Tue Dec 23 09:15:07 UTC 2025


Hello everybody,

I am trying to extend the Bayes classifier with additional classes such as
newsletter, phishing, etc.

When I train SPAM, everything works as expected.

# cat spam.eml | rspamc learn_class:spam -v

The statfile changes from 0
to the number of learned spam messages:

Statfile: BAYES_SPAM type: redis; length: 0; free blocks: 0; total 
blocks: 0;
free: 0.00%; learned: 0; users: 0; languages: 0

-->

Statfile: BAYES_SPAM type: redis; length: 0; free blocks: 0; total 
blocks: 0;
free: 0.00%; learned: 77; users: 1; languages: 0

However, when I train other classes, for example BAYES_NEWSLETTER, using the
command:

# cat newsletter.eml | rspamc learn_class:newsletter -v

all other classes are affected as well.

Before training:

Statfile: BAYES_PHISHING       type: redis; learned: 0; users: 0
Statfile: BAYES_TRANSACTIONAL  type: redis; learned: 0; users: 0
Statfile: BAYES_NEWSLETTER     type: redis; learned: 0; users: 0
Statfile: BAYES_HAM            type: redis; learned: 0; users: 0
Statfile: BAYES_SPAM           type: redis; learned: 77; users: 1

After training:

Statfile: BAYES_PHISHING       type: redis; learned: 1; users: 1
Statfile: BAYES_TRANSACTIONAL  type: redis; learned: 1; users: 1
Statfile: BAYES_NEWSLETTER     type: redis; learned: 1; users: 1
Statfile: BAYES_HAM            type: redis; learned: 1; users: 1
Statfile: BAYES_SPAM           type: redis; learned: 77; users: 1

I do not understand why learning a single class updates all other non-spam
classes as well.

Below is my classifier configuration:

classifier "bayes" {
   tokenizer {
     name = "osb";
   }

   new_schema = true;
   store_tokens = false;
   signatures = false;
   min_tokens = 11;
   backend = "redis";
   min_learns = 200;

   enabled = true;
   autolearn = false;

   statfile "BAYES_SPAM" {
     class = "spam";
     symbol = "BAYES_SPAM";
   }
   statfile "BAYES_HAM" {
     class = "ham";
     symbol = "BAYES_HAM";
   }
   statfile "BAYES_NEWSLETTER" {
     class = "newsletter";
     symbol = "BAYES_NEWSLETTER";
   }
   statfile "BAYES_TRANSACTIONAL" {
     class = "transactional";
     symbol = "BAYES_TRANSACTIONAL";
   }
   statfile "BAYES_PHISHING" {
     class = "phishing";
     symbol = "BAYES_PHISHING";
   }

   learn_condition = "return require('lua_bayes_learn').can_learn";
}

Thank you very much for your help.

Best regards,
Alessio


More information about the Users mailing list