Documentation

NAME

Mail::MIMEDefang::ML::Laya - Laya backend for Mail::MIMEDefang::ML.

SYNOPSIS

use Mail::MIMEDefang::ML;

$Mail::MIMEDefang::ML::Config{backend}          = 'laya';
$Mail::MIMEDefang::ML::Config{laya}{server_url} = 'http://127.0.0.1:8687';

my $verdict = ml_classify(ml_build_state(...));

DESCRIPTION

Laya (https://github.com/NandhaKishorM/laya) is a non-autoregressive encoder-based decision model: one forward pass returns typed, calibrated answers instead of generated text, which avoids both the latency and the parsing/hallucination risk of an autoregressive LLM for a simple ham/spam/ phishing verdict.

Because Laya is a Python library, this backend talks to a small resident Python inference server (see mimedefang-laya-server), POSTing the state with fixed noul (boolean) questions for spam and phishing.

This module is not used directly: select it with $Mail::MIMEDefang::ML::Config{backend} = 'laya'.

CONFIGURATION

$Mail::MIMEDefang::ML::Config{laya}: server_url (default http://127.0.0.1:8687), predict_path (default /predict), body_head_chars and body_tail_chars (default: the global ones, 1500 and 500, sized for Laya's 512-token context), send_signals (default 0: the signals computed by "ml_build_state" in Mail::MIMEDefang::ML are left out, because Laya picks its English or multilingual checkpoint by the language of the whole state, and the English signal lines make it route non-English mail, and even English newsletters, to the wrong one), question_texts (question wording for this backend, keep it short, see "CONFIGURATION" in Mail::MIMEDefang::ML).

Unless question_texts rewords them, Laya is asked the short questions in %Mail::MIMEDefang::ML::Laya::QUESTIONS ("Is this email spam?", "Is this email phishing?") rather than the long ones in %Mail::MIMEDefang::ML::QUESTIONS: those take about 500 tokens, which together with the body can overflow Laya's input and get the questions themselves truncated, and they make the multilingual checkpoint answer "yes" to ordinary mail far more often.

SEE ALSO

Mail::MIMEDefang::ML, mimedefang-laya-server.