Documentation
¶
Overview ¶
Package learn holds what the daemon learns from its own decisions and the user's corrections: learned sender rules, and the few-shot examples the fallback model is shown. It also defines the example type the model adapters accept.
Index ¶
Constants ¶
const ( After = 3 AfterBulk = 1 Confidence = 0.9 )
A sender is learned after After model decisions in a row to the same rule, each at Confidence or above and none corrected. Bulk mail that passed DMARC (a newsletter-type sender, PRD R15) needs only AfterBulk, as long as every recent decision for the sender agrees with it.
const MaxExamples = 5
MaxExamples is how many corrections the fallback model is shown for one email.
Variables ¶
This section is empty.
Functions ¶
func Observe ¶
func Observe(ctx context.Context, st *store.Store, userID int64, sender string, bulk bool, now int64) (bool, error)
Observe runs after a model decided for mail from sender. When the sender's recent decisions qualify, it creates a learned sender rule that routes the address to that rule without a model call, and reports true. bulk says the email just decided was bulk mail that passed DMARC. Corrections delete the rule again (store.AddCorrection).
Types ¶
type Example ¶
type Example struct {
Email message.Summary // the corrected email; its body is at most the stored snippet
RightRuleID int64 // the rule the user said was right; 0 = keep in inbox
}
Example is one past correction shown to the fallback model as a few-shot example.
func Examples ¶
func Examples(ctx context.Context, st *store.Store, userID int64, email message.Summary, candidates []int64) ([]Example, error)
Examples retrieves the few-shot examples for an email from the user's corrections.
func Rank ¶
Rank picks the corrections to show for an email: at most MaxExamples, most similar first. Same sender address beats same sender domain, which beats same List-Id, which beats no likeness at all; within each, the most recent comes first. Only corrections the model can still answer with are kept: towards one of candidates, or towards "keep in the inbox" (rule 0).