{"id":486159,"date":"2026-07-04T11:55:37","date_gmt":"2026-07-04T11:55:37","guid":{"rendered":"https:\/\/savepearlharbor.com\/?p=486159"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=486159","title":{"rendered":"\u0411\u0435\u0441\u043f\u043b\u0430\u0442\u043d\u0430\u044f \u0437\u0430\u0449\u0438\u0442\u0430 \u043e\u0442 \u0441\u043f\u0430\u043c\u0430 \u043d\u0430 \u043f\u043e\u0447\u0442\u0435 \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u0418\u0418 \u0444\u0438\u043b\u044c\u0442\u0440\u0430\u0446\u0438\u0438 \u0431\u0435\u0437 VPN: \u043c\u043d\u043e\u0433\u043e\u0443\u0440\u043e\u0432\u043d\u0435\u0432\u044b\u0439 \u043c\u0435\u0442\u043e\u0434 \u0441 BERT \u0438 550 \u041c\u0411 RAM"},"content":{"rendered":"<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\">\n<p><strong>\u0412\u0430\u0441 \u0442\u043e\u0436\u0435 \u0434\u043e\u0441\u0442\u0430\u0451\u0442 \u0441\u043f\u0430\u043c \u0438 \u0440\u0435\u043a\u043b\u0430\u043c\u0430?<\/strong> \u0420\u0435\u043a\u043b\u0430\u043c\u0443 \u044f \u0431\u043b\u043e\u043a\u0438\u0440\u0443\u044e \u0447\u0435\u0440\u0435\u0437 \u0441\u0432\u043e\u0439 DNS \u0441\u0435\u0440\u0432\u0435\u0440 \u0438 \u043b\u043e\u043a\u0430\u043b\u044c\u043d\u044b\u043c\u0438 CSS \u0444\u0438\u043b\u044c\u0442\u0440\u0430\u043c\u0438, \u0430 \u0432\u043e\u0442 \u0434\u043b\u044f \u043f\u043e\u0447\u0442\u044b \u043f\u0440\u0438\u0448\u043b\u043e\u0441\u044c \u043f\u0440\u0438\u0434\u0443\u043c\u0430\u0442\u044c \u0447\u0442\u043e-\u0442\u043e \u0434\u0440\u0443\u0433\u043e\u0435.<\/p>\n<figure class=\"\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/498\/6c2\/d43\/4986c2d432d1cc48834af35cee8c22f0.png\" alt=\"\u0411\u0435\u0441\u043f\u043b\u0430\u0442\u043d\u0430\u044f \u0437\u0430\u0449\u0438\u0442\u0430 \u043e\u0442 \u0441\u043f\u0430\u043c\u0430 \u043d\u0430 \u043f\u043e\u0447\u0442\u0435 \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u0418\u0418 \u0444\u0438\u043b\u044c\u0442\u0440\u0430\u0446\u0438\u0438\" title=\"\u0411\u0435\u0441\u043f\u043b\u0430\u0442\u043d\u0430\u044f \u0437\u0430\u0449\u0438\u0442\u0430 \u043e\u0442 \u0441\u043f\u0430\u043c\u0430 \u043d\u0430 \u043f\u043e\u0447\u0442\u0435 \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u0418\u0418 \u0444\u0438\u043b\u044c\u0442\u0440\u0430\u0446\u0438\u0438\" sizes=\"(max-width: 780px) 100vw, 50vw\" srcset=\"https:\/\/habrastorage.org\/r\/w780\/getpro\/habr\/upload_files\/498\/6c2\/d43\/4986c2d432d1cc48834af35cee8c22f0.png 780w,&#10;       https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/498\/6c2\/d43\/4986c2d432d1cc48834af35cee8c22f0.png 781w\" loading=\"lazy\" decode=\"async\"\/><\/p>\n<div><figcaption>\u0411\u0435\u0441\u043f\u043b\u0430\u0442\u043d\u0430\u044f \u0437\u0430\u0449\u0438\u0442\u0430 \u043e\u0442 \u0441\u043f\u0430\u043c\u0430 \u043d\u0430 \u043f\u043e\u0447\u0442\u0435 \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u0418\u0418 \u0444\u0438\u043b\u044c\u0442\u0440\u0430\u0446\u0438\u0438<\/figcaption><\/div>\n<\/figure>\n<p>\u041f\u043e\u0447\u0442\u0430 \u0443 \u043c\u0435\u043d\u044f \u0443\u0441\u0442\u0440\u043e\u0435\u043d\u0430 \u043d\u0435\u043c\u043d\u043e\u0433\u043e \u043d\u0435\u043e\u0431\u044b\u0447\u043d\u043e (\u044f \u0442\u0430\u043a \u0434\u0443\u043c\u0430\u044e). \u0412\u0441\u0435 \u043c\u043e\u0438 \u044f\u0449\u0438\u043a\u0438 \u2014 \u042f\u043d\u0434\u0435\u043a\u0441, Mail, \u0441\u0442\u0430\u0440\u044b\u0435 \u0430\u0434\u0440\u0435\u0441\u0430 \u2014 \u043d\u0430\u0441\u0442\u0440\u043e\u0435\u043d\u044b \u043d\u0430 \u043f\u0435\u0440\u0435\u0441\u044b\u043b\u043a\u0443 \u043d\u0430 \u043c\u043e\u0439 \u0434\u043e\u043c\u0435\u043d. \u0421 \u0434\u043e\u043c\u0435\u043d\u0430 \u0432\u0441\u0451 \u043b\u0435\u0442\u0438\u0442 \u0432 Gmail. \u041f\u0440\u043e\u0442\u043e\u043a\u043e\u043b\u043e\u043c IMAP \u043d\u0435 \u043f\u043e\u043b\u044c\u0437\u0443\u044e\u0441\u044c \u043c\u043d\u043e\u0433\u043e \u043b\u0435\u0442 (\u0434\u0430 \u0435\u0449\u0451 \u043a\u0430\u043a\u0438\u0435 \u0442\u043e \u043f\u043b\u0430\u0442\u043d\u044b\u0435 \u043c\u0443\u0442\u043a\u0438 \u0432 \u0420\u0424 \u043d\u0435\u0434\u0430\u0432\u043d\u043e \u043f\u0440\u0438\u0434\u0443\u043c\u0430\u043b\u0438). \u0410 \u0432\u043e\u0442 \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441 Google \u043c\u0435\u043d\u044f \u043f\u043e\u043b\u043d\u043e\u0441\u0442\u044c\u044e \u0443\u0441\u0442\u0440\u0430\u0438\u0432\u0430\u0435\u0442, \u043f\u043e\u0438\u0441\u043a \u043c\u0433\u043d\u043e\u0432\u0435\u043d\u043d\u044b\u0439, \u0443\u0434\u043e\u0431\u043d\u044b\u0435 \u043c\u0435\u0442\u043a\u0438 \u0438 \u0441\u043e\u0440\u0442\u0438\u0440\u043e\u0432\u043a\u0430. \u0415\u0441\u0442\u044c \u043c\u0435\u043b\u043e\u0447\u0438, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043d\u0435 \u043d\u0440\u0430\u0432\u044f\u0442\u0441\u044f, \u043d\u043e \u043b\u0443\u0447\u0448\u0435 \u0432\u0430\u0440\u0438\u0430\u043d\u0442\u0430, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0437\u0430\u043a\u0440\u044b\u0432\u0430\u043b \u0431\u044b \u043c\u043e\u0438 \u043f\u043e\u0442\u0440\u0435\u0431\u043d\u043e\u0441\u0442\u0438, \u043f\u043e\u043a\u0430 \u043d\u0435 \u0432\u0441\u0442\u0440\u0435\u0447\u0430\u043b. \u0412 \u0438\u0442\u043e\u0433\u0435 \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u0442\u0441\u044f \u0435\u0434\u0438\u043d\u0430\u044f \u0442\u043e\u0447\u043a\u0430, \u0433\u0434\u0435 \u0432\u0438\u0434\u043d\u0430 \u0432\u0441\u044f \u043f\u0435\u0440\u0435\u043f\u0438\u0441\u043a\u0430.<\/p>\n<p>\u0421\u0445\u0435\u043c\u0430 \u043c\u043d\u043e\u0433\u043e\u0441\u0442\u0443\u043f\u0435\u043d\u0447\u0430\u0442\u0430\u044f. \u041f\u0435\u0440\u0432\u044b\u043c\u0438 \u0441\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u044e\u0442 \u0444\u0438\u043b\u044c\u0442\u0440\u044b \u042f\u043d\u0434\u0435\u043a\u0441\u0430 \u0438 Mail \u2014 \u0447\u0442\u043e-\u0442\u043e \u043e\u043d\u0438 \u043e\u0442\u0441\u0435\u0438\u0432\u0430\u044e\u0442 \u0441\u0430\u043c\u0438, \u0435\u0449\u0451 \u0434\u043e \u043f\u0435\u0440\u0435\u0441\u044b\u043b\u043a\u0438. \u0422\u043e, \u0447\u0442\u043e \u043f\u0440\u043e\u0448\u043b\u043e \u0447\u0435\u0440\u0435\u0437 \u043d\u0438\u0445, \u043f\u0430\u0434\u0430\u0435\u0442 \u043d\u0430 \u043c\u043e\u0439 \u0441\u0435\u0440\u0432\u0435\u0440, \u0433\u0434\u0435 \u0441\u0442\u043e\u0438\u0442 SpamAssassin. \u041b\u043e\u0432\u0438\u0442 \u0435\u0449\u0451 \u0447\u0430\u0441\u0442\u044c. \u041d\u043e \u043f\u043e\u0441\u043b\u0435 \u0434\u0432\u0443\u0445 \u0443\u0440\u043e\u0432\u043d\u0435\u0439 \u0432\u0441\u0451 \u0440\u0430\u0432\u043d\u043e \u0447\u0442\u043e-\u0442\u043e \u043f\u0440\u043e\u0441\u0430\u0447\u0438\u0432\u0430\u0435\u0442\u0441\u044f, \u0441\u043f\u0430\u043c\u0435\u0440\u044b \u0436\u0435 \u043d\u0435 \u0441\u0438\u0434\u044f\u0442 \u0431\u0435\u0437 \u0434\u0435\u043b\u0430. \u0418 \u0432\u043e\u0442 \u044d\u0442\u043e\u0442 \u043e\u0441\u0442\u0430\u0442\u043e\u043a \u0434\u043e\u0435\u0437\u0436\u0430\u0435\u0442 \u0434\u043e Gmail \u0438 \u0447\u0442\u043e-\u0442\u043e \u043e\u0441\u0435\u0434\u0430\u0435\u0442 \u0432 \u043f\u0430\u043f\u043a\u0435 \u0421\u043f\u0430\u043c, \u0430 \u0447\u0442\u043e-\u0442\u043e \u043f\u043e\u043f\u0430\u0434\u0430\u0435\u0442 \u0432\u043e \u0432\u0445\u043e\u0434\u044f\u0449\u0438\u0435 \u0438 \u043f\u0440\u0438\u0445\u043e\u0434\u0438\u0442 \u0440\u0430\u0437\u0434\u0440\u0430\u0436\u0430\u044e\u0449\u0435\u0435 \u0443\u0432\u0435\u0434\u043e\u043c\u043b\u0435\u043d\u0438\u0435. \u0425\u043e\u0442\u0435\u043b\u043e\u0441\u044c, \u0447\u0442\u043e\u0431\u044b \u0441\u043e \u0432\u0440\u0435\u043c\u0435\u043d\u0435\u043c \u043d\u0435 \u043d\u0430\u043a\u0430\u043f\u043b\u0438\u0432\u0430\u043b\u0441\u044f \u043c\u0443\u0441\u043e\u0440 \u0432 \u043f\u0430\u043f\u043a\u0430\u0445, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043d\u0430\u0434\u043e \u0440\u0430\u0437\u0433\u0440\u0435\u0431\u0430\u0442\u044c \u0432\u0440\u0443\u0447\u043d\u0443\u044e. \u041e\u0441\u043e\u0431\u0435\u043d\u043d\u043e \u0432\u0430\u0436\u043d\u043e \u0437\u0430\u0431\u043b\u043e\u043a\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0442\u043e, \u0447\u0442\u043e \u043d\u0435 \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u043f\u043e\u043b\u043d\u043e\u0441\u0442\u044c\u044e \u0441\u043f\u0430\u043c\u043e\u043c: \u043f\u0440\u0438\u0433\u043b\u0430\u0448\u0435\u043d\u0438\u044f \u043d\u0430 \u043a\u043e\u043d\u0444\u0435\u0440\u0435\u043d\u0446\u0438\u0438, \u043f\u0430\u0440\u0442\u043d\u0451\u0440\u0441\u043a\u0438\u0435 \u043f\u0440\u0435\u0434\u043b\u043e\u0436\u0435\u043d\u0438\u044f, \u043a\u0440\u0435\u0434\u0438\u0442\u044b \u2014 \u0444\u043e\u0440\u043c\u0430\u043b\u044c\u043d\u043e \u043d\u0435 \u043d\u0430\u0440\u0443\u0448\u0435\u043d\u0438\u0435, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u0431\u0430\u0439\u0435\u0441\u043e\u0432\u0441\u043a\u0438\u0439 \u0444\u0438\u043b\u044c\u0442\u0440 \u0442\u0430\u043a\u0438\u0435 \u0432\u0435\u0449\u0438 \u043f\u043b\u043e\u0445\u043e \u043b\u043e\u0432\u0438\u0442.<\/p>\n<p>\u0421\u043d\u0430\u0447\u0430\u043b\u0430 \u0434\u0443\u043c\u0430\u043b \u0432\u0437\u044f\u0442\u044c LLM \u0447\u0435\u0440\u0435\u0437 API. Llama \u0438\u043b\u0438 GPT \u043e\u0442\u043b\u0438\u0447\u043d\u043e \u0440\u0430\u0437\u0431\u0438\u0440\u0430\u044e\u0442 \u0442\u0435\u043a\u0441\u0442, \u0441 \u043d\u0438\u043c\u0438 \u0433\u0438\u0431\u043a\u043e \u043d\u0430\u0441\u0442\u0440\u0430\u0438\u0432\u0430\u044e\u0442\u0441\u044f \u043a\u0440\u0438\u0442\u0435\u0440\u0438\u0438. \u041d\u043e \u044d\u0442\u043e \u0432\u043d\u0435\u0448\u043d\u044f\u044f \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u044c. \u0412 \u043d\u0430\u0448\u0435 \u043d\u0435\u0441\u0442\u0430\u0431\u0438\u043b\u044c\u043d\u043e\u0435 \u0441\u0435\u0442\u0435\u0432\u043e\u0435 \u0432\u0440\u0435\u043c\u044f \u0436\u0435\u043b\u0430\u0442\u0435\u043b\u044c\u043d\u043e \u0443\u043c\u0435\u043d\u044c\u0448\u0430\u0442\u044c \u0442\u0430\u043a\u0438\u0435 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438. \u0421\u0435\u0440\u0432\u0438\u0441 \u043c\u043e\u0436\u0435\u0442 \u043f\u043e\u043c\u0435\u043d\u044f\u0442\u044c \u0443\u0441\u043b\u043e\u0432\u0438\u044f, \u043e\u0442\u043a\u043b\u044e\u0447\u0438\u0442\u044c\u0441\u044f \u0432\u0440\u0435\u043c\u0435\u043d\u043d\u043e, \u0433\u0435\u043e\u0431\u043b\u043e\u043a\u0438\u0440\u043e\u0432\u043a\u0438, \u0434\u0430 \u0438 \u043c\u043d\u043e\u0433\u043e \u0447\u0435\u0433\u043e \u0435\u0449\u0451.<\/p>\n<p><strong>\u041b\u043e\u043a\u0430\u043b\u044c\u043d\u0430\u044f BERT-\u043c\u043e\u0434\u0435\u043b\u044c \u0437\u0430\u043a\u0440\u044b\u043b\u0430 \u043e\u0431\u0435 \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u044b.<\/strong> \u0412\u0437\u044f\u043b <code>ruBert-base-antispam<\/code> \u0441 HuggingFace \u2014 \u0444\u0430\u0439\u043d-\u0442\u044e\u043d \u043d\u0430 \u0431\u0430\u0437\u0435 DeepPavlov\/rubert-base-cased-conversational. 177 \u043c\u0438\u043b\u043b\u0438\u043e\u043d\u043e\u0432 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u043e\u0432, 12 \u0441\u043b\u043e\u0451\u0432 \u0442\u0440\u0430\u043d\u0441\u0444\u043e\u0440\u043c\u0435\u0440\u0430, 768 hidden size. \u0424\u0438\u0437\u0438\u0447\u0435\u0441\u043a\u0438 \u043d\u0435 \u043f\u0440\u0438\u043d\u0438\u043c\u0430\u0435\u0442 \u0431\u043e\u043b\u044c\u0448\u0435 512 \u0442\u043e\u043a\u0435\u043d\u043e\u0432 \u043d\u0430 \u0432\u0445\u043e\u0434. \u0412 \u043f\u0430\u043c\u044f\u0442\u0438 \u0437\u0430\u043d\u0438\u043c\u0430\u0435\u0442 \u043e\u043a\u043e\u043b\u043e 550 \u041c\u0411, \u043e\u0442\u0432\u0435\u0442 \u043f\u0440\u0438\u0445\u043e\u0434\u0438\u0442 \u0437\u0430 100-200 \u043c\u0438\u043b\u043b\u0438\u0441\u0435\u043a\u0443\u043d\u0434. \u0411\u0438\u043d\u0430\u0440\u043d\u044b\u0439 \u043a\u043b\u0430\u0441\u0441\u0438\u0444\u0438\u043a\u0430\u0442\u043e\u0440 \u2014 \u0442\u0435\u043a\u0441\u0442 \u043d\u0430 \u0432\u0445\u043e\u0434\u0435, 0 \u0438\u043b\u0438 1 \u043d\u0430 \u0432\u044b\u0445\u043e\u0434\u0435, \u043d\u0438\u043a\u0430\u043a\u0438\u0445 \u043f\u0440\u043e\u043c\u043f\u0442\u043e\u0432 \u0438 reasoning. \u0418\u0434\u0435\u0430\u043b\u044c\u043d\u043e!<\/p>\n<p>\u0412\u0441\u0442\u0440\u043e\u0438\u0442\u044c \u0432\u044b\u0437\u043e\u0432 \u0441\u043a\u0440\u0438\u043f\u0442\u0430 \u043f\u0440\u044f\u043c\u043e \u0432 SMTP-\u043a\u043e\u043d\u0432\u0435\u0439\u0435\u0440 Exim \u043e\u043a\u0430\u0437\u0430\u043b\u043e\u0441\u044c \u043d\u0435\u043f\u0440\u043e\u0441\u0442\u043e. \u041c\u0435\u0445\u0430\u043d\u0438\u0437\u043c\u044b \u0432\u0440\u043e\u0434\u0435 ACL \u0438\u043b\u0438 <code>transport_filter<\/code> \u0438\u043c\u0435\u044e\u0442 \u0441\u0432\u043e\u0438 \u043e\u0441\u043e\u0431\u0435\u043d\u043d\u043e\u0441\u0442\u0438, \u043e\u0441\u043e\u0431\u0435\u043d\u043d\u043e \u0441 \u043c\u0443\u0434\u0440\u0435\u043d\u043e\u0439 \u043f\u0430\u043d\u0435\u043b\u044c\u044e \u0441\u0435\u0440\u0432\u0435\u0440\u0430, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u0441\u0430\u043c\u0430 \u043e\u0431\u043d\u043e\u0432\u043b\u044f\u0435\u0442 \u043c\u043d\u043e\u0433\u0438\u0435 \u0444\u0430\u0439\u043b\u044b. \u0410 \u0442\u043e \u0431\u0443\u0434\u0435\u0442 \u0442\u0430\u043a: \u0433\u0434\u0435-\u0442\u043e \u043f\u0438\u0441\u044c\u043c\u043e \u043d\u0435\u0434\u043e\u0441\u0442\u0443\u043f\u043d\u043e \u0446\u0435\u043b\u0438\u043a\u043e\u043c, \u0433\u0434\u0435-\u0442\u043e \u043f\u0440\u0430\u0432 \u043d\u0435 \u0445\u0432\u0430\u0442\u0430\u0435\u0442, \u0433\u0434\u0435-\u0442\u043e \u043c\u043e\u0434\u0438\u0444\u0438\u0446\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0439 \u0442\u0435\u043a\u0441\u0442 \u043d\u0435 \u043f\u0435\u0440\u0435\u0434\u0430\u0451\u0442\u0441\u044f \u0434\u0430\u043b\u044c\u0448\u0435, \u0433\u0434\u0435-\u0442\u043e \u0444\u0430\u0439\u043b \u043e\u0431\u043d\u043e\u0432\u0438\u043b\u0441\u044f. \u041f\u043e\u0448\u0451\u043b \u0434\u0440\u0443\u0433\u0438\u043c \u043f\u0443\u0442\u0451\u043c \u2014 post-delivery \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u043e\u0439.<\/p>\n<p><strong>\u041f\u043e\u043b\u0443\u0447\u0438\u043b\u0430\u0441\u044c \u0442\u0440\u0451\u0445\u0443\u0440\u043e\u0432\u043d\u0435\u0432\u0430\u044f \u0441\u0435\u0440\u0432\u0435\u0440\u043d\u0430\u044f \u0437\u0430\u0449\u0438\u0442\u0430.<\/strong> \u041f\u0435\u0440\u0432\u044b\u0439 \u0443\u0440\u043e\u0432\u0435\u043d\u044c \u2014 pre-rules, \u043d\u0430\u0431\u043e\u0440 \u0440\u0435\u0433\u0443\u043b\u044f\u0440\u043e\u043a \u0434\u043b\u044f \u043e\u0447\u0435\u0432\u0438\u0434\u043d\u043e\u0433\u043e \u0441\u043f\u0430\u043c\u0430. \u0421\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u044e\u0442 \u0437\u0430 \u043c\u0438\u043b\u043b\u0438\u0441\u0435\u043a\u0443\u043d\u0434\u0443, \u0431\u0435\u0437 \u043e\u0431\u0440\u0430\u0449\u0435\u043d\u0438\u044f \u043a \u043d\u0435\u0439\u0440\u043e\u0441\u0435\u0442\u0438. \u0412\u0442\u043e\u0440\u043e\u0439 \u0443\u0440\u043e\u0432\u0435\u043d\u044c \u2014 \u0441\u0430\u043c\u0430 BERT-\u043c\u043e\u0434\u0435\u043b\u044c, \u043e\u0431\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u0435\u0442 \u0432\u0441\u0451, \u0447\u0442\u043e \u043d\u0435 \u043e\u0442\u0441\u0435\u043a\u043b\u0438 \u0440\u0435\u0433\u0443\u043b\u044f\u0440\u043a\u0438, \u044d\u0442\u043e \u043e\u043a\u043e\u043b\u043e 70% \u043f\u043e\u0442\u043e\u043a\u0430. \u0422\u0440\u0435\u0442\u0438\u0439 \u0443\u0440\u043e\u0432\u0435\u043d\u044c \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u043f\u0430\u0440\u0430\u043b\u043b\u0435\u043b\u044c\u043d\u043e \u2014 SpamAssassin \u0441\u043e \u0441\u0432\u043e\u0438\u043c \u0431\u0430\u0439\u0435\u0441\u043e\u0432\u0441\u043a\u0438\u043c \u0444\u0438\u043b\u044c\u0442\u0440\u043e\u043c. \u0415\u0441\u043b\u0438 \u043e\u043d \u0441\u0442\u0430\u0432\u0438\u0442 score \u0432\u044b\u0448\u0435 \u043f\u043e\u0440\u043e\u0433\u0430, Dovecot \u0447\u0435\u0440\u0435\u0437 Sieve \u043f\u0435\u0440\u0435\u043c\u0435\u0449\u0430\u0435\u0442 \u043f\u0438\u0441\u044c\u043c\u043e \u0432 <code>.Spam<\/code>. \u042d\u0442\u043e \u0441\u0442\u0440\u0430\u0445\u043e\u0432\u043a\u0430 \u043d\u0430 \u0441\u043b\u0443\u0447\u0430\u0439, \u0435\u0441\u043b\u0438 \u043f\u0435\u0440\u0432\u044b\u0435 \u0434\u0432\u0430 \u0443\u0440\u043e\u0432\u043d\u044f \u0447\u0442\u043e-\u0442\u043e \u043f\u0440\u043e\u043f\u0443\u0441\u0442\u0438\u043b\u0438. \u041f\u0440\u0438 \u044d\u0442\u043e\u043c AI-\u0441\u043a\u0440\u0438\u043f\u0442 \u0432\u0441\u0451 \u0440\u0430\u0432\u043d\u043e \u043f\u0440\u043e\u0432\u0435\u0440\u044f\u0435\u0442 \u043f\u0438\u0441\u044c\u043c\u043e: \u0435\u0441\u043b\u0438 SpamAssassin \u043e\u0448\u0438\u0431\u0441\u044f \u0438 \u043f\u043e\u043c\u0435\u0442\u0438\u043b \u043d\u043e\u0440\u043c\u0430\u043b\u044c\u043d\u043e\u0435 \u043f\u0438\u0441\u044c\u043c\u043e, \u0430 AI \u0441\u0447\u0438\u0442\u0430\u0435\u0442 \u0435\u0433\u043e \u0447\u0438\u0441\u0442\u044b\u043c, \u043e\u043d\u043e \u0432\u0441\u0451 \u0440\u0430\u0432\u043d\u043e \u0443\u0439\u0434\u0451\u0442 \u043d\u0430 Gmail. Fail-open \u0441\u0442\u0440\u0430\u0442\u0435\u0433\u0438\u044f \u0432 AI-\u0441\u043a\u0440\u0438\u043f\u0442\u0435 \u0441\u043f\u0430\u0441\u0430\u0435\u0442 \u043e\u0442 \u043f\u0430\u0440\u0430\u043d\u043e\u0438\u0434\u0430\u043b\u044c\u043d\u043e\u0433\u043e SpamAssassin \u0438 \u0431\u0435\u0437 \u0441\u0438\u043b\u044c\u043d\u044b\u0445 \u0437\u0430\u043c\u043e\u0440\u043e\u0447\u0435\u043a \u0441 \u043a\u043e\u044d\u0444\u0444\u0438\u0446\u0438\u0435\u043d\u0442\u0430\u043c\u0438.<\/p>\n<p><strong>\u0421\u0445\u0435\u043c\u0430 \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u0442\u0430\u043a.<\/strong> Exim \u043f\u0440\u0438\u043d\u0438\u043c\u0430\u0435\u0442 \u043f\u0438\u0441\u044c\u043c\u043e \u0438 \u0441\u043a\u043b\u0430\u0434\u044b\u0432\u0430\u0435\u0442 \u0435\u0433\u043e \u0432 Maildir, \u0432 \u043f\u0430\u043f\u043a\u0443 <code>new\/<\/code>. \u041e\u0442\u0434\u0435\u043b\u044c\u043d\u044b\u0439 \u0441\u043a\u0440\u0438\u043f\u0442 \u043a\u0430\u0436\u0434\u044b\u0435 \u043f\u043e\u043b\u043c\u0438\u043d\u0443\u0442\u044b \u043e\u0431\u0445\u043e\u0434\u0438\u0442 \u0432\u0441\u0435 \u0434\u0438\u0440\u0435\u043a\u0442\u043e\u0440\u0438\u0438. \u0418\u0437 MIME \u0432\u044b\u0442\u0430\u0441\u043a\u0438\u0432\u0430\u0435\u0442 \u0442\u0435\u043a\u0441\u0442 \u0438 \u0437\u0430\u0433\u043e\u043b\u043e\u0432\u043a\u0438 \u2014 \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u0438\u0432\u0430\u0435\u0442 \u0438 plain, \u0438 HTML, \u0442\u0435\u0433\u0438 \u0447\u0438\u0441\u0442\u0438\u0442 \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u043d\u044b\u043c <code>HTMLParser<\/code>. \u0421\u043d\u0430\u0447\u0430\u043b\u0430 \u0433\u043e\u043d\u0438\u0442 \u0447\u0435\u0440\u0435\u0437 pre-rules, \u043f\u0440\u0438\u0447\u0451\u043c \u0441\u043c\u043e\u0442\u0440\u0438\u0442 \u043d\u0435 \u0442\u043e\u043b\u044c\u043a\u043e \u0432 \u0442\u0435\u043a\u0441\u0442, \u043d\u043e \u0438 \u0432 \u0437\u0430\u0433\u043e\u043b\u043e\u0432\u043a\u0438. \u0427\u0442\u043e \u043d\u0435 \u043e\u0442\u0441\u0435\u044f\u043b\u043e\u0441\u044c \u2014 \u0438\u0434\u0451\u0442 \u0432 \u043f\u043e\u0441\u0442\u043e\u044f\u043d\u043d\u043e \u0440\u0430\u0431\u043e\u0442\u0430\u044e\u0449\u0438\u0439 daemon \u0447\u0435\u0440\u0435\u0437 Unix-\u0441\u043e\u043a\u0435\u0442. \u0421\u043f\u0430\u043c \u043f\u0435\u0440\u0435\u043a\u043b\u0430\u0434\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u0432 <code>.Spam\/<\/code>, \u043d\u043e\u0440\u043c\u0430\u043b\u044c\u043d\u044b\u0435 \u043f\u0438\u0441\u044c\u043c\u0430 \u0438\u0434\u0443\u0442 \u0432 <code>cur\/<\/code> \u0438 \u043f\u0430\u0440\u0430\u043b\u043b\u0435\u043b\u044c\u043d\u043e \u0443\u043b\u0435\u0442\u0430\u044e\u0442 \u043d\u0430 Gmail \u0447\u0435\u0440\u0435\u0437 sendmail.<\/p>\n<p>\u0417\u0430\u0434\u0435\u0440\u0436\u043a\u0430 \u043d\u0430 \u0434\u043e\u0441\u0442\u0430\u0432\u043a\u0443 \u043f\u0438\u0441\u044c\u043c\u0430 \u0432 30\u201360 \u0441\u0435\u043a\u0443\u043d\u0434 \u043c\u0435\u043d\u044f \u043d\u0435 \u0431\u0435\u0441\u043f\u043e\u043a\u043e\u0438\u0442. \u0412 \u043f\u043e\u0447\u0442\u0435 \u044f \u0432 \u0440\u0435\u0430\u043b\u044c\u043d\u043e\u043c \u0432\u0440\u0435\u043c\u0435\u043d\u0438 \u043d\u0435 \u0441\u0438\u0436\u0443, \u044d\u0442\u043e \u0436 \u043d\u0435 \u0447\u0430\u0442, \u0434\u0430 \u0438 Gmail \u043f\u043e\u0434\u0442\u044f\u0433\u0438\u0432\u0430\u0435\u0442 \u043d\u0435 \u043f\u0440\u044f\u043c \u043c\u0433\u043d\u043e\u0432\u0435\u043d\u043d\u043e. \u041f\u043e\u0447\u0442\u0430 \u043d\u0443\u0436\u043d\u0430 \u0434\u043b\u044f \u0441\u043f\u043e\u043a\u043e\u0439\u043d\u044b\u0445 \u043f\u0435\u0440\u0435\u043f\u0438\u0441\u043e\u043a, \u0430 \u043d\u0435 \u0434\u043b\u044f \u0433\u043e\u043d\u043e\u043a \u043a\u0442\u043e \u0431\u044b\u0441\u0442\u0440\u0435\u0435 \u043e\u0442\u0432\u0435\u0442\u0438\u043b.<\/p>\n<p>\u041f\u0440\u0438\u0432\u043e\u0436\u0443 \u043f\u0440\u0438\u043c\u0435\u0440 daemon (<code>\/opt\/spam_filter\/daemon.py<\/code>):<\/p>\n<pre><code class=\"python\">#!\/usr\/bin\/env python3import socket, sys, os, re, signal, loggingimport torchfrom transformers import AutoTokenizer, AutoModelForSequenceClassificationMODEL_NAME = \"assskelad\/ruBert-base-antispam\"  # \u043b\u044e\u0431\u0430\u044f BertForSequenceClassificationSOCKET_PATH = \"\/tmp\/spam_filter.sock\"MAX_LEN = 512      # \u043b\u0438\u043c\u0438\u0442 BERTMAX_TEXT = 6000    # \u0441\u0438\u043c\u0432\u043e\u043b\u044b \u0438\u0437 \u043f\u0438\u0441\u044c\u043c\u0430logging.basicConfig(level=logging.INFO)logger = logging.getLogger(\"spam_daemon\")torch.set_num_threads(1)tokenizer = AutoTokenizer.from_pretrained(MODEL_NAME)model = AutoModelForSequenceClassification.from_pretrained(MODEL_NAME)model.eval()def predict(text: str) -&gt; int:    inputs = tokenizer(text, return_tensors=\"pt\", truncation=True, max_length=MAX_LEN)    with torch.inference_mode():        out = model(**inputs)        return int(torch.argmax(out.logits, dim=1).item())def handle(conn):    try:        data = conn.recv(1024 * 1024)        text = data.decode(\"utf-8\", errors=\"replace\")[:MAX_TEXT]        result = predict(text) if text else 0        conn.sendall(str(result).encode())    except Exception as e:        logger.error(f\"Error: {e}\")        conn.sendall(b\"0\")    finally:        conn.close()def shutdown(signum, frame):    try:        os.unlink(SOCKET_PATH)    except:        pass    sys.exit(0)signal.signal(signal.SIGTERM, shutdown)signal.signal(signal.SIGINT, shutdown)srv = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM)srv.bind(SOCKET_PATH)srv.listen(10)while True:    conn, _ = srv.accept()    handle(conn)<\/code><div class=\"code-explainer\"><a href=\"https:\/\/sourcecraft.dev\/\" class=\"tm-button code-explainer__link\" style=\"visibility: hidden;\"><img style=\"width:87px;height:14px;object-fit:cover;object-position:left;\"\/><\/a><\/div><\/pre>\n<p>Pre-rules (<code>\/opt\/spam_filter\/pre_rules.py<\/code>) \u2014 \u043f\u0430\u0442\u0442\u0435\u0440\u043d\u044b:<\/p>\n<pre><code class=\"python\">#!\/usr\/bin\/env python3import redef check_pre_rules(text, headers=None):    text_lower = text.lower()    headers = headers or {}        # \u043f\u0430\u0442\u0442\u0435\u0440\u043d\u044b    spam_patterns = [        r'\u0440\u0430\u0441\u0441\u044b\u043b\u043a[\u0430\u0438]\\s+\u043f\u043e\\s+\u0431\u0430\u0437|\u043c\u0438\u043b\u043b\u0438\u043e\u043d\\s+\u0430\u0434\u0440\u0435\u0441',        r'\u0432\u043d\u0435\u0434\u0440\u0435\u043d\u0438.{0,15}crm|\u0431\u043e\u0442\\s+\u043f\u0440\u043e\u0434\u0432\u0438\u0436\u0435\u043d\u0438.{0,20}(?:telegram|whatsapp)',        r'\u0434\u0438\u043f\u043b\u043e\u043c.{0,20}(?:\u043f\u0440\u043e\u0444\u043f\u0435\u0440\u0435\u043f\u043e\u0434\u0433\u043e\u0442\u043e\u0432\u043a|\u0434\u043e\u043f\u043e\u0431\u0440\u0430\u0437\u043e\u0432\u0430\u043d)',        r'\u0431\u0443\u0445\u0433\u0430\u043b\u0442\u0435\u0440\u0441\u043a.{0,30}\u0441\u043e\u043f\u0440\u043e\u0432\u043e\u0436\u0434\u0435\u043d|\u043d\u0443\u043b\u0435\u0432\u043e\u0439.{0,20}\u043d\u0434\u0441',        r'\u0441\u043f\u0430\u0440\u0441\u0438\u0442\u044c.{0,30}\u0431\u0430\u0437\u0443|\u043f\u0430\u0440\u0441\u0438\u043d\u0433.{0,30}\u043a\u043b\u0438\u0435\u043d\u0442\u043e\u0432',        r'\u043f\u043e\u0434\u0442\u0432\u0435\u0440\u0434\u0438\u0442\u0435.{0,30}\u0434\u0430\u043d\u043d\u044b.{0,200}\u043f\u0440\u0435\u0434\u043b\u043e\u0436\u0435\u043d\u0438\u0435\\s+\u0438\u0441\u0442\u0435\u043a\u0430\u0435\u0442',        r'(?:[\u0430-\u044f]\\s){4,}',        r'\u0434\u0435\u043d\u044c\u0433\u0438\\s+\u043f\u043e\u0434\\s+\u0437\u0430\u043b\u043e\u0433.{0,20}(?:\u0430\u0432\u0442\u043e|\u043c\u0430\u0448\u0438\u043d)',        r'\u0441\u0435\u043e\\s+\u043e\u043f\u0442\u0438\u043c\u0438\u0437\u0430\u0446.{0,20}\u043d\u0435\u0434\u043e\u0440\u043e\u0433\u043e',    ]    for pattern in spam_patterns:        if re.search(pattern, text_lower):            return \"SPAM\"        # \u0440\u0430\u0441\u0441\u044b\u043b\u043a\u0438    bulk_headers = any(        k.lower() in ['list-unsubscribe', 'precedence', 'feedback-id', 'x-rpcampaign']        for k in headers    )    if bulk_headers and re.search(r'\u043f\u0440\u0435\u0434\u043b\u0430\u0433\u0430\u0435\u043c|\u043f\u0440\u0438\u0433\u043b\u0430\u0448\u0430\u0435\u043c|\u0431\u0435\u0441\u043f\u043b\u0430\u0442\u043d.{0,20}\u043a\u043e\u043d\u0441\u0443\u043b\u044c\u0442\u0430\u0446', text_lower):        return \"SPAM\"        # \u0441\u043f\u0430\u043c    if re.search(r'\u043a\u0435\u0442\u043e|\u043c\u0435\u0442\u0430\u0431\u043e\u043b\u0438\u0437\u043c|\u0438\u043d\u0441\u0443\u043b\u0438\u043d|\u0436\u0438\u0440\u043e\u0441\u0436\u0438\u0433\u0430\u043d\u0438[\u0435\u044e]|\u0436\u043a\u0442', text_lower) and \\       re.search(r'\u0442\u044b\\s+\u0443\u0441\u0442\u0430\u043b|\u044d\u043d\u0435\u0440\u0433\u0438[\u044f\u0438]\\s+\u043d\u0430\\s+\u043d\u0443\u043b\u0435|\u043c\u044b\\s+\u0434\u0430[\u0435\u0451]\u043c\\s+\u0441\u0438\u0441\u0442\u0435\u043c\u0443', text_lower):        return \"SPAM\"        # \u043d\u0443\u0436\u043d\u044b\u0435 \u043f\u0438\u0441\u044c\u043c\u0430    ham_patterns = [        r'\u043a\u043e\u0434\\s+(?:\u043f\u043e\u0434\u0442\u0432\u0435\u0440\u0436\u0434\u0435\u043d|\u0434\u043b\u044f\\s+\u0432\u0445\u043e\u0434|\u0434\u043e\u0441\u0442\u0443\u043f\u0430):\\s*\\d{4,6}',        r'\u0432\u0430\u0448\\s+\u0437\u0430\u043a\u0430\u0437\\s+\u2116?\\d+|order\\s+#?\\d+',        r'\u0441\u0431\u0440\u043e\u0441\\s+\u043f\u0430\u0440\u043e\u043b|password\\s+reset',        r'\u043f\u043b\u0430\u0442\u0435\u0436\\s+\u043f\u0440\u043e\u0448\u0435\u043b|payment\\s+received',        r'\u0432\u0441\u0442\u0440\u0435\u0447[\u0430\u0438]\\s+(?:\u043f\u0435\u0440\u0435\u043d\u0435\u0441\u0435\u043d|\u043d\u0430\u0437\u043d\u0430\u0447\u0435\u043d|\u0441\u043e\u0441\u0442\u043e\u0438\u0442\u0441\u044f)',    ]    for pattern in ham_patterns:        if re.search(pattern, text_lower):            return \"HAM\"        return None<\/code><div class=\"code-explainer\"><a href=\"https:\/\/sourcecraft.dev\/\" class=\"tm-button code-explainer__link\" style=\"visibility: hidden;\"><img style=\"width:14px;height:14px;object-fit:cover;object-position:left;\"\/><\/a><\/div><\/pre>\n<p><strong>\u041f\u0440\u0430\u0432\u0438\u043b\u043e \u043f\u0440\u043e \u043c\u0430\u0441\u0441\u043e\u0432\u044b\u0435 \u0440\u0430\u0441\u0441\u044b\u043b\u043a\u0438 \u043e\u043a\u0430\u0437\u0430\u043b\u043e\u0441\u044c \u043e\u0447\u0435\u043d\u044c \u043f\u043e\u043b\u0435\u0437\u043d\u044b\u043c.<\/strong> \u041d\u0435\u0439\u0440\u043e\u0441\u0435\u0442\u044c \u0447\u0430\u0441\u0442\u043e \u043f\u0440\u043e\u043f\u0443\u0441\u043a\u0430\u0435\u0442 \u0442\u0430\u043a\u0438\u0435 \u043f\u0438\u0441\u044c\u043c\u0430, \u043f\u043e\u0442\u043e\u043c\u0443 \u0447\u0442\u043e \u043e\u043d\u0438 \u0433\u0440\u0430\u043c\u043c\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0438 \u043a\u043e\u0440\u0440\u0435\u043a\u0442\u043d\u044b \u0438 \u043d\u0435 \u0441\u043e\u0434\u0435\u0440\u0436\u0430\u0442 \u044f\u0432\u043d\u043e\u0433\u043e \u043c\u0443\u0441\u043e\u0440\u0430. \u0410 \u0441\u0432\u044f\u0437\u043a\u0430 \u0437\u0430\u0433\u043e\u043b\u043e\u0432\u043e\u043a <code>List-Unsubscribe<\/code> + \u0441\u043b\u043e\u0432\u043e <code>\u043f\u0440\u0438\u0433\u043b\u0430\u0448\u0430\u0435\u043c<\/code> \u0432 \u0442\u0435\u043a\u0441\u0442\u0435 \u0434\u0430\u0451\u0442 100% \u0442\u043e\u0447\u043d\u043e\u0441\u0442\u0438 \u0431\u0435\u0437 \u043b\u043e\u0436\u043d\u044b\u0445 \u0441\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u043d\u0438\u0439 \u043d\u0430 \u043b\u0438\u0447\u043d\u044b\u0435 \u043f\u0438\u0441\u044c\u043c\u0430. \u041f\u0440\u0430\u0432\u0438\u043b\u043e \u043f\u0440\u043e \u043c\u0435\u0434\u0438\u0446\u0438\u043d\u0441\u043a\u0438\u0435 \u0442\u0435\u0440\u043c\u0438\u043d\u044b \u2014 \u043f\u0440\u0438\u043c\u0435\u0440 \u0441\u043e\u0441\u0442\u0430\u0432\u043d\u043e\u0439 \u0440\u0435\u0433\u0443\u043b\u044f\u0440\u043a\u0438: \u043f\u043e \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u0438 \u0441\u043b\u043e\u0432\u0430 \u043c\u043e\u0433\u0443\u0442 \u0443\u043f\u043e\u0442\u0440\u0435\u0431\u043b\u044f\u0442\u044c\u0441\u044f \u0432 \u043f\u0435\u0440\u0435\u043f\u0438\u0441\u043a\u0435, \u043d\u043e \u0432 \u0441\u043e\u0447\u0435\u0442\u0430\u043d\u0438\u0438 \u0441 \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u043c\u0438 \u044d\u0442\u043e \u043e\u0434\u043d\u043e\u0437\u043d\u0430\u0447\u043d\u044b\u0439 \u0441\u043f\u0430\u043c. \u0422\u0430\u043a \u0444\u0430\u0439\u043b <code>pre_rules.py<\/code> \u0441\u043e \u0432\u0440\u0435\u043c\u0435\u043d\u0435\u043c \u043e\u0431\u0440\u0430\u0441\u0442\u0430\u0435\u0442 \u0441\u043f\u0435\u0446\u0438\u0444\u0438\u0447\u043d\u044b\u043c\u0438 \u043f\u0440\u0430\u0432\u0438\u043b\u0430\u043c\u0438 \u043f\u043e\u0434 \u0432\u0430\u0448 \u043f\u043e\u0442\u043e\u043a, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0438\u043d\u043e\u0433\u0434\u0430 \u043c\u043e\u0436\u043d\u043e \u043f\u043e\u043f\u043e\u043b\u043d\u044f\u0442\u044c.<\/p>\n<p>\u0421\u043e\u043a\u0440\u0430\u0449\u0435\u043d\u043d\u044b\u0439 Post-delivery \u0441\u043a\u0440\u0438\u043f\u0442:<\/p>\n<pre><code class=\"python\">#!\/usr\/bin\/env python3import os, sys, socket, datetime, time, subprocessfrom email import policyfrom email.parser import BytesParserfrom html.parser import HTMLParserimport reSOCKET = \"\/tmp\/spam_filter.sock\"MAIL_BASE = \"\/home\/admin\/mail\"         # \u043f\u0443\u0442\u044cFORWARD_TO = \"your@gmail.com\"          # \u043a\u0443\u0434\u0430 \u043f\u0440\u0438\u0441\u044b\u043b\u0430\u0442\u044cWAIT_SECONDS = 5                       # \u043e\u0436\u0438\u0434\u0430\u043d\u0438\u0435LOCK_FILE = \"\/tmp\/ai_spam_check.lock\"def check_spam(email_bytes):    text, headers = extract_text_and_headers(email_bytes)        pre_verdict = check_pre_rules(text, headers)    if pre_verdict == \"SPAM\":        return True, text[:100], \"pre_rule\"    elif pre_verdict == \"HAM\":        return False, text[:100], \"pre_rule\"        text_bytes = text.encode('utf-8', errors='ignore')    try:        s = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM)        s.settimeout(2)        s.connect(SOCKET)        s.settimeout(5)        s.sendall(text_bytes)        s.shutdown(socket.SHUT_WR)        r = s.recv(8).decode(\"ascii\", errors=\"ignore\").strip()        s.close()        return r == \"1\", text[:100], \"ai\"    except Exception as e:        log(f\"DAEMON_ERROR: {e}\")        return False, text[:100], \"error\"def forward_to_gmail(email_bytes, filename=\"\"):    modified = b\"X-Forwarded-By: AI-Filter\\n\" + email_bytes    p = subprocess.Popen(        [\"\/usr\/sbin\/sendmail\", \"-i\", FORWARD_TO],        stdin=subprocess.PIPE,        stdout=subprocess.DEVNULL,        stderr=subprocess.DEVNULL    )    p.stdin.write(modified)    p.stdin.close()    p.wait()def process_new_dir(new_dir, spam_new_dir, cur_dir):    for filename in os.listdir(new_dir):        filepath = os.path.join(new_dir, filename)        if time.time() - os.path.getmtime(filepath) &lt; WAIT_SECONDS:            continue                with open(filepath, \"rb\") as f:            email_bytes = f.read()                if b\"X-Forwarded-By: AI-Filter\" in email_bytes:            os.rename(filepath, os.path.join(cur_dir, filename + \":2,\"))            continue                is_spam, preview, method = check_spam(email_bytes)        if is_spam:            os.rename(filepath, os.path.join(spam_new_dir, filename))            log(f\"SPAM [{method}]: {filename} | {preview}\")        else:            os.rename(filepath, os.path.join(cur_dir, filename + \":2,\"))            forward_to_gmail(email_bytes, filename)            log(f\"NOT_SPAM [{method}]: {filename} | {preview}\")<\/code><div class=\"code-explainer\"><a href=\"https:\/\/sourcecraft.dev\/\" class=\"tm-button code-explainer__link\" style=\"visibility: hidden;\"><img style=\"width:14px;height:14px;object-fit:cover;object-position:left;\"\/><\/a><\/div><\/pre>\n<p>\u0421\u0430\u043c\u043e\u0435 \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u043e\u0435 \u2014 \u0433\u043e\u043d\u043a\u0438 \u0441 MTA. \u0415\u0441\u043b\u0438 \u0447\u0438\u0442\u0430\u0442\u044c \u0444\u0430\u0439\u043b \u0441\u0440\u0430\u0437\u0443 \u043f\u043e\u0441\u043b\u0435 \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f, \u043c\u043e\u0436\u043d\u043e \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u043d\u0435\u0434\u043e\u043f\u0438\u0441\u0430\u043d\u043d\u043e\u0435 \u043f\u0438\u0441\u044c\u043c\u043e \u043f\u043e\u043a\u0430 \u043e\u043d\u043e \u0441\u043e\u0445\u0440\u0430\u043d\u044f\u0435\u0442\u0441\u044f \u043d\u0430 \u043d\u043e\u0441\u0438\u0442\u0435\u043b\u044c. \u041e\u0442\u0441\u044e\u0434\u0430 <code>WAIT_SECONDS<\/code>: \u0441\u043a\u0440\u0438\u043f\u0442 \u043f\u0440\u043e\u043f\u0443\u0441\u043a\u0430\u0435\u0442 \u0444\u0430\u0439\u043b\u044b \u043c\u043e\u043b\u043e\u0436\u0435 \u0437\u0430\u0434\u0430\u043d\u043d\u043e\u0433\u043e \u0432\u043e\u0437\u0440\u0430\u0441\u0442\u0430. \u042d\u0442\u043e \u043f\u043b\u0430\u0442\u0430 \u0437\u0430 post-delivery.<\/p>\n<p>\u041f\u0435\u0442\u043b\u0438 \u043f\u0435\u0440\u0435\u0441\u044b\u043b\u043a\u0438 \u0442\u043e\u0436\u0435 \u043f\u0440\u0438\u0448\u043b\u043e\u0441\u044c \u0443\u0447\u0435\u0441\u0442\u044c. \u0415\u0441\u043b\u0438 \u0441\u043b\u0443\u0447\u0430\u0439\u043d\u043e \u043e\u0442\u043f\u0440\u0430\u0432\u0438\u0442\u044c \u0441\u0430\u043c\u043e\u043c\u0443 \u0441\u0435\u0431\u0435 \u0438\u043b\u0438 \u0437\u0430\u043c\u043a\u043d\u0443\u0442\u044c \u0446\u0435\u043f\u043e\u0447\u043a\u0443, \u043d\u0430\u0447\u043d\u0451\u0442\u0441\u044f \u0431\u0435\u0441\u043a\u043e\u043d\u0435\u0447\u043d\u044b\u0439 \u0446\u0438\u043a\u043b. \u0417\u0430\u0449\u0438\u0442\u0430 \u2014 \u0437\u0430\u0433\u043e\u043b\u043e\u0432\u043e\u043a <code>X-Forwarded-By<\/code>: \u0441\u043a\u0440\u0438\u043f\u0442 \u0432\u0438\u0434\u0438\u0442 \u0435\u0433\u043e \u0438 \u043f\u0440\u043e\u043f\u0443\u0441\u043a\u0430\u0435\u0442 \u0442\u0430\u043a\u0438\u0435 \u043f\u0438\u0441\u044c\u043c\u0430, \u043f\u0440\u043e\u0441\u0442\u043e \u043f\u0435\u0440\u0435\u043c\u0435\u0449\u0430\u044f \u0432 <code>cur\/<\/code>.<\/p>\n<p>\u041f\u043e RAM \u043f\u0430\u043c\u044f\u0442\u0438: \u043c\u043e\u0434\u0435\u043b\u044c \u0437\u0430\u043d\u0438\u043c\u0430\u0435\u0442 \u043e\u043a\u043e\u043b\u043e 550 \u041c\u0411, \u0441\u043a\u0440\u0438\u043f\u0442 \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0438 \u043f\u0440\u0438 \u0437\u0430\u043f\u0443\u0441\u043a\u0435 \u0435\u0449\u0451 \u043e\u043a\u043e\u043b\u043e 50 \u041c\u0411, Exim 25 \u041c\u0411, Dovecot 10 \u041c\u0411, SpamAssassin 80 \u041c\u0411. \u0418\u0442\u043e\u0433\u043e \u043e\u043a\u043e\u043b\u043e 716 \u041c\u0411 \u043d\u0430 \u0432\u0441\u044e \u0441\u0438\u0441\u0442\u0435\u043c\u0443. \u0423 \u043c\u0435\u043d\u044f \u0441\u0435\u0440\u0432\u0435\u0440 \u043d\u0430 2 \u0433\u0438\u0433\u0430, \u0432 \u0438\u0442\u043e\u0433\u0435 \u0437\u0430\u043d\u044f\u0442\u043e \u043e\u043a\u043e\u043b\u043e \u043e\u0434\u043d\u043e\u0433\u043e. \u0412\u0441\u0451 \u0441\u0442\u0430\u0431\u0438\u043b\u044c\u043d\u043e, \u0431\u0435\u0437 \u0441\u0432\u043e\u043f\u0430. \u0414\u043b\u044f \u0431\u043e\u043b\u0435\u0435 \u0441\u043b\u0430\u0431\u044b\u0445 \u043c\u0430\u0448\u0438\u043d \u043f\u043e\u0434\u043e\u0448\u0451\u043b \u0431\u044b DistilBERT, \u043e\u043d \u0432\u0434\u0432\u043e\u0435 \u043b\u0435\u0433\u0447\u0435, \u043d\u043e \u0443 \u043c\u0435\u043d\u044f \u0437\u0430\u043f\u0430\u0441\u0430 \u0445\u0432\u0430\u0442\u0430\u0435\u0442.<\/p>\n<p>\u0415\u0441\u043b\u0438 daemon \u0443\u043f\u0430\u043b, \u0441\u043e\u043a\u0435\u0442 \u043d\u0435\u0434\u043e\u0441\u0442\u0443\u043f\u0435\u043d \u0438\u043b\u0438 \u043f\u0440\u043e\u0438\u0437\u043e\u0448\u043b\u0430 \u043b\u044e\u0431\u0430\u044f \u043e\u0448\u0438\u0431\u043a\u0430 \u2014 \u043f\u0438\u0441\u044c\u043c\u043e \u0441\u0447\u0438\u0442\u0430\u0435\u0442\u0441\u044f \u043d\u043e\u0440\u043c\u0430\u043b\u044c\u043d\u044b\u043c \u0438 \u0438\u0434\u0451\u0442 \u0434\u0430\u043b\u044c\u0448\u0435. \u041b\u0443\u0447\u0448\u0435 \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u043f\u0430\u0440\u0443 \u0441\u043f\u0430\u043c-\u043f\u0438\u0441\u0435\u043c, \u0447\u0435\u043c \u043f\u0440\u043e\u043f\u0443\u0441\u0442\u0438\u0442\u044c \u0432\u0430\u0436\u043d\u043e\u0435.<\/p>\n<p>\u0414\u043b\u044f \u043c\u043e\u043d\u0438\u0442\u043e\u0440\u0438\u043d\u0433\u0430 \u0435\u0441\u0442\u044c bash-\u0441\u043a\u0440\u0438\u043f\u0442 <code>SPAM<\/code>, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043f\u043e\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u0442 \u0441\u0442\u0430\u0442\u0443\u0441 \u0432\u0441\u0435\u0445 \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u043e\u0432, \u0441\u0442\u0430\u0442\u0438\u0441\u0442\u0438\u043a\u0443 \u0437\u0430 \u0434\u0435\u043d\u044c, \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u0435 \u044f\u0449\u0438\u043a\u043e\u0432 \u0438 trend \u0437\u0430 \u043f\u043e\u0441\u043b\u0435\u0434\u043d\u0438\u0439 \u0447\u0430\u0441 \u043f\u0440\u044f\u043c\u043e \u0432 \u0442\u0435\u0440\u043c\u0438\u043d\u0430\u043b\u0435. \u041a\u043e\u043c\u0430\u043d\u0434\u0430 <code>SPAM -w<\/code> \u0434\u0430\u0451\u0442 live-\u043e\u0431\u043d\u043e\u0432\u043b\u0435\u043d\u0438\u0435 \u043a\u0430\u0436\u0434\u044b\u0435 3 \u0441\u0435\u043a\u0443\u043d\u0434\u044b, <code>SPAM -t<\/code> \u0442\u0435\u0441\u0442\u0438\u0440\u0443\u0435\u0442 \u043c\u043e\u0434\u0435\u043b\u044c \u043d\u0430 10 \u043f\u0440\u0438\u043c\u0435\u0440\u0430\u0445, <code>SPAM -r<\/code> \u2014 pre-rules \u043d\u0430 21 \u043f\u0440\u0438\u043c\u0435\u0440\u0435. \u0414\u043b\u044f \u0430\u0434\u043c\u0438\u043d\u0430 \u043f\u043e\u0447\u0442\u043e\u0432\u043e\u0433\u043e \u0441\u0435\u0440\u0432\u0435\u0440\u0430 \u0443\u0434\u043e\u0431\u043d\u044b\u0439 CLI-\u043c\u043e\u043d\u0438\u0442\u043e\u0440\u0438\u043d\u0433 \u043e\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u043f\u043e\u043b\u0435\u0437\u043d\u0435\u0435 \u043b\u044e\u0431\u043e\u0433\u043e \u0432\u0435\u0431-\u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441\u0430. \u041b\u043e\u0433\u0438 \u043f\u0438\u0448\u0443 \u0432 <code>\/var\/log\/ai_spam.log<\/code> \u0441 \u043f\u043e\u043c\u0435\u0442\u043a\u0430\u043c\u0438 <code>[pre_rule]<\/code> \u0438\u043b\u0438 <code>[ai]<\/code>, \u0447\u0442\u043e\u0431\u044b \u0431\u044b\u043b\u043e \u0432\u0438\u0434\u043d\u043e, \u043a\u0430\u043a\u043e\u0439 \u0443\u0440\u043e\u0432\u0435\u043d\u044c \u0441\u0440\u0430\u0431\u043e\u0442\u0430\u043b.<\/p>\n<p><strong>\u0421\u043f\u0430\u043c \u043f\u0435\u0440\u0435\u0441\u0442\u0430\u043b \u0434\u043e\u0435\u0437\u0436\u0430\u0442\u044c \u0434\u043e Gmail.<\/strong> \u0427\u0442\u043e \u0440\u0430\u043d\u044c\u0448\u0435 \u043e\u0441\u0435\u0434\u0430\u043b\u043e \u0432 \u043f\u0430\u043f\u043a\u0435 \u0438 \u0442\u0440\u0435\u0431\u043e\u0432\u0430\u043b\u043e \u043f\u0435\u0440\u0438\u043e\u0434\u0438\u0447\u0435\u0441\u043a\u043e\u0439 \u0447\u0438\u0441\u0442\u043a\u0438, \u0442\u0435\u043f\u0435\u0440\u044c \u043e\u0441\u0442\u0430\u0451\u0442\u0441\u044f \u043d\u0430 \u0441\u0435\u0440\u0432\u0435\u0440\u0435 \u0432 <code>.Spam\/<\/code>. \u041d\u0430 Gmail \u043f\u043e\u043f\u0430\u0434\u0430\u044e\u0442 \u0442\u043e\u043b\u044c\u043a\u043e \u043f\u0438\u0441\u044c\u043c\u0430, \u043f\u0440\u043e\u0448\u0435\u0434\u0448\u0438\u0435 \u0432\u0441\u0435 \u0442\u0440\u0438 \u0444\u0438\u043b\u044c\u0442\u0440\u0430. \u0418\u043d\u043e\u0433\u0434\u0430 \u043c\u043e\u0434\u0435\u043b\u044c \u043e\u0448\u0438\u0431\u0430\u0435\u0442\u0441\u044f \u2014 \u043d\u0430 \u0440\u0435\u0434\u043a\u0438\u0445 \u0442\u0435\u043c\u0430\u0445 \u0438\u043b\u0438 \u0441\u043f\u0435\u0446\u0438\u0444\u0438\u0447\u0435\u0441\u043a\u043e\u043c \u0441\u043b\u0435\u043d\u0433\u0435. \u0412 \u0442\u0430\u043a\u0438\u0445 \u0441\u043b\u0443\u0447\u0430\u044f\u0445 \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u044e \u043f\u0430\u0442\u0442\u0435\u0440\u043d \u0432 <code>pre_rules.py<\/code>, \u0438 \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u0430 \u0431\u043e\u043b\u044c\u0448\u0435 \u043d\u0435 \u043f\u043e\u0432\u0442\u043e\u0440\u044f\u0435\u0442\u0441\u044f. \u0420\u0430\u0437 \u0432 \u043c\u0435\u0441\u044f\u0446 \u043c\u043e\u0436\u043d\u043e \u0433\u043b\u044f\u043d\u0443\u0442\u044c \u0432 <code>.Spam\/<\/code>, \u043f\u0440\u043e\u0441\u043c\u0430\u0442\u0440\u0438\u0432\u0430\u044e \u0437\u0430\u0433\u043e\u043b\u043e\u0432\u043a\u0438 \u2014 \u043d\u0435 \u043f\u043e\u0442\u0435\u0440\u044f\u043b\u043e\u0441\u044c \u043b\u0438 \u0447\u0435\u0433\u043e. \u041e\u0431\u044b\u0447\u043d\u043e \u043d\u0435\u0442. \u0410 \u0435\u0441\u043b\u0438 \u0447\u0442\u043e \u0438 \u043f\u043e\u043f\u0430\u0434\u0435\u0442 \u043f\u043e \u043e\u0448\u0438\u0431\u043a\u0435 \u2014 \u043f\u0430\u0440\u0430 \u0441\u0442\u0440\u043e\u043a \u0432 \u043a\u043e\u043d\u0444\u0438\u0433\u0435, \u0438 \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u0430 \u0437\u0430\u043a\u0440\u044b\u0442\u0430.<\/p>\n<p>\u041d\u0430\u0433\u0440\u0443\u0437\u043a\u0430 \u043d\u0430 \u0441\u0435\u0440\u0432\u0435\u0440 \u043c\u0438\u043d\u0438\u043c\u0430\u043b\u044c\u043d\u0430\u044f, \u043f\u0440\u0438 \u0441\u043e\u0442\u043d\u0435 \u043f\u0438\u0441\u0435\u043c \u0432 \u0434\u0435\u043d\u044c daemon \u0431\u043e\u043b\u044c\u0448\u0443\u044e \u0447\u0430\u0441\u0442\u044c \u0432\u0440\u0435\u043c\u0435\u043d\u0438 \u0441\u043f\u0438\u0442, CPU \u043f\u043e\u0447\u0442\u0438 \u043d\u0435 \u0435\u0441\u0442. \u0420\u0430\u0437 \u043d\u0430\u0441\u0442\u0440\u043e\u0438\u043b \u0438 \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442, \u0438\u043d\u043e\u0433\u0434\u0430 \u0442\u043e\u043b\u044c\u043a\u043e \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u044e \u043d\u043e\u0432\u044b\u0435 \u0440\u0435\u0433\u0443\u043b\u044f\u0440\u043a\u0438, \u043a\u043e\u0433\u0434\u0430 \u0437\u0430\u043c\u0435\u0447\u0430\u044e \u0432 \u043b\u043e\u0433\u0430\u0445 \u043f\u043e\u0432\u0442\u043e\u0440\u044f\u044e\u0449\u0438\u0439\u0441\u044f \u043c\u0443\u0441\u043e\u0440. <strong>\u041f\u0440\u043e\u0431\u043b\u0435\u043c\u0430 \u0441\u043e \u0441\u043f\u0430\u043c\u043e\u043c \u0437\u0430\u043a\u0440\u044b\u0442\u0430!<\/strong><\/p>\n<p>\u0410 \u043a\u0430\u043a \u0432\u044b \u0431\u043e\u0440\u0435\u0442\u0435\u0441\u044c \u0441\u043e \u0441\u043f\u0430\u043c\u043e\u043c \u043d\u0430 \u0441\u0432\u043e\u0438\u0445 \u0441\u0435\u0440\u0432\u0435\u0440\u0430\u0445? \u0415\u0441\u043b\u0438 \u0431\u0443\u0434\u0443\u0442 \u043d\u0443\u0436\u043d\u044b \u0438\u0441\u0445\u043e\u0434\u043d\u0438\u043a\u0438, \u0442\u043e \u0432\u044b\u043b\u043e\u0436\u0443 \u043d\u0430 GitHub.<\/p>\n<\/div>\n<p>\u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"https:\/\/habr.com\/ru\/articles\/1055518\/\">https:\/\/habr.com\/ru\/articles\/1055518\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u0412\u0430\u0441 \u0442\u043e\u0436\u0435 \u0434\u043e\u0441\u0442\u0430\u0451\u0442 \u0441\u043f\u0430\u043c \u0438 \u0440\u0435\u043a\u043b\u0430\u043c\u0430? \u0420\u0435\u043a\u043b\u0430\u043c\u0443 \u044f \u0431\u043b\u043e\u043a\u0438\u0440\u0443\u044e \u0447\u0435\u0440\u0435\u0437 \u0441\u0432\u043e\u0439 DNS \u0441\u0435\u0440\u0432\u0435\u0440 \u0438 \u043b\u043e\u043a\u0430\u043b\u044c\u043d\u044b\u043c\u0438 CSS \u0444\u0438\u043b\u044c\u0442\u0440\u0430\u043c\u0438, \u0430 \u0432\u043e\u0442 \u0434\u043b\u044f \u043f\u043e\u0447\u0442\u044b \u043f\u0440\u0438\u0448\u043b\u043e\u0441\u044c \u043f\u0440\u0438\u0434\u0443\u043c\u0430\u0442\u044c \u0447\u0442\u043e-\u0442\u043e \u0434\u0440\u0443\u0433\u043e\u0435.\u0411\u0435\u0441\u043f\u043b\u0430\u0442\u043d\u0430\u044f \u0437\u0430\u0449\u0438\u0442\u0430 \u043e\u0442 \u0441\u043f\u0430\u043c\u0430 \u043d\u0430 \u043f\u043e\u0447\u0442\u0435 \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u0418\u0418 \u0444\u0438\u043b\u044c\u0442\u0440\u0430\u0446\u0438\u0438\u041f\u043e\u0447\u0442\u0430 \u0443 \u043c\u0435\u043d\u044f \u0443\u0441\u0442\u0440\u043e\u0435\u043d\u0430 \u043d\u0435\u043c\u043d\u043e\u0433\u043e \u043d\u0435\u043e\u0431\u044b\u0447\u043d\u043e (\u044f \u0442\u0430\u043a \u0434\u0443\u043c\u0430\u044e). \u0412\u0441\u0435 \u043c\u043e\u0438 \u044f\u0449\u0438\u043a\u0438 \u2014 \u042f\u043d\u0434\u0435\u043a\u0441, Mail, \u0441\u0442\u0430\u0440\u044b\u0435 \u0430\u0434\u0440\u0435\u0441\u0430 \u2014 \u043d\u0430\u0441\u0442\u0440\u043e\u0435\u043d\u044b \u043d\u0430 \u043f\u0435\u0440\u0435\u0441\u044b\u043b\u043a\u0443 \u043d\u0430 \u043c\u043e\u0439 \u0434\u043e\u043c\u0435\u043d. \u0421 \u0434\u043e\u043c\u0435\u043d\u0430 \u0432\u0441\u0451 \u043b\u0435\u0442\u0438\u0442 \u0432 Gmail. \u041f\u0440\u043e\u0442\u043e\u043a\u043e\u043b\u043e\u043c IMAP \u043d\u0435 \u043f\u043e\u043b\u044c\u0437\u0443\u044e\u0441\u044c \u043c\u043d\u043e\u0433\u043e \u043b\u0435\u0442 (\u0434\u0430 \u0435\u0449\u0451 \u043a\u0430\u043a\u0438\u0435 \u0442\u043e \u043f\u043b\u0430\u0442\u043d\u044b\u0435 \u043c\u0443\u0442\u043a\u0438 \u0432 \u0420\u0424 \u043d\u0435\u0434\u0430\u0432\u043d\u043e \u043f\u0440\u0438\u0434\u0443\u043c\u0430\u043b\u0438). \u0410 \u0432\u043e\u0442 \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441 Google \u043c\u0435\u043d\u044f \u043f\u043e\u043b\u043d\u043e\u0441\u0442\u044c\u044e \u0443\u0441\u0442\u0440\u0430\u0438\u0432\u0430\u0435\u0442, \u043f\u043e\u0438\u0441\u043a \u043c\u0433\u043d\u043e\u0432\u0435\u043d\u043d\u044b\u0439, \u0443\u0434\u043e\u0431\u043d\u044b\u0435 \u043c\u0435\u0442\u043a\u0438 \u0438 \u0441\u043e\u0440\u0442\u0438\u0440\u043e\u0432\u043a\u0430. \u0415\u0441\u0442\u044c \u043c\u0435\u043b\u043e\u0447\u0438, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043d\u0435 \u043d\u0440\u0430\u0432\u044f\u0442\u0441\u044f, \u043d\u043e \u043b\u0443\u0447\u0448\u0435 \u0432\u0430\u0440\u0438\u0430\u043d\u0442\u0430, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0437\u0430\u043a\u0440\u044b\u0432\u0430\u043b \u0431\u044b \u043c\u043e\u0438 \u043f\u043e\u0442\u0440\u0435\u0431\u043d\u043e\u0441\u0442\u0438, \u043f\u043e\u043a\u0430 \u043d\u0435 \u0432\u0441\u0442\u0440\u0435\u0447\u0430\u043b. \u0412 \u0438\u0442\u043e\u0433\u0435 \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u0442\u0441\u044f \u0435\u0434\u0438\u043d\u0430\u044f \u0442\u043e\u0447\u043a\u0430, \u0433\u0434\u0435 \u0432\u0438\u0434\u043d\u0430 \u0432\u0441\u044f \u043f\u0435\u0440\u0435\u043f\u0438\u0441\u043a\u0430.\u0421\u0445\u0435\u043c\u0430 \u043c\u043d\u043e\u0433\u043e\u0441\u0442\u0443\u043f\u0435\u043d\u0447\u0430\u0442\u0430\u044f. \u041f\u0435\u0440\u0432\u044b\u043c\u0438 \u0441\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u044e\u0442 \u0444\u0438\u043b\u044c\u0442\u0440\u044b \u042f\u043d\u0434\u0435\u043a\u0441\u0430 \u0438 Mail \u2014 \u0447\u0442\u043e-\u0442\u043e \u043e\u043d\u0438 \u043e\u0442\u0441\u0435\u0438\u0432\u0430\u044e\u0442 \u0441\u0430\u043c\u0438, \u0435\u0449\u0451 \u0434\u043e \u043f\u0435\u0440\u0435\u0441\u044b\u043b\u043a\u0438. \u0422\u043e, \u0447\u0442\u043e \u043f\u0440\u043e\u0448\u043b\u043e \u0447\u0435\u0440\u0435\u0437 \u043d\u0438\u0445, \u043f\u0430\u0434\u0430\u0435\u0442 \u043d\u0430 \u043c\u043e\u0439 \u0441\u0435\u0440\u0432\u0435\u0440, \u0433\u0434\u0435 \u0441\u0442\u043e\u0438\u0442 SpamAssassin. \u041b\u043e\u0432\u0438\u0442 \u0435\u0449\u0451 \u0447\u0430\u0441\u0442\u044c. \u041d\u043e \u043f\u043e\u0441\u043b\u0435 \u0434\u0432\u0443\u0445 \u0443\u0440\u043e\u0432\u043d\u0435\u0439 \u0432\u0441\u0451 \u0440\u0430\u0432\u043d\u043e \u0447\u0442\u043e-\u0442\u043e \u043f\u0440\u043e\u0441\u0430\u0447\u0438\u0432\u0430\u0435\u0442\u0441\u044f, \u0441\u043f\u0430\u043c\u0435\u0440\u044b \u0436\u0435 \u043d\u0435 \u0441\u0438\u0434\u044f\u0442 \u0431\u0435\u0437 \u0434\u0435\u043b\u0430. \u0418 \u0432\u043e\u0442 \u044d\u0442\u043e\u0442 \u043e\u0441\u0442\u0430\u0442\u043e\u043a \u0434\u043e\u0435\u0437\u0436\u0430\u0435\u0442 \u0434\u043e Gmail \u0438 \u0447\u0442\u043e-\u0442\u043e \u043e\u0441\u0435\u0434\u0430\u0435\u0442 \u0432 \u043f\u0430\u043f\u043a\u0435 \u0421\u043f\u0430\u043c, \u0430 \u0447\u0442\u043e-\u0442\u043e \u043f\u043e\u043f\u0430\u0434\u0430\u0435\u0442 \u0432\u043e \u0432\u0445\u043e\u0434\u044f\u0449\u0438\u0435 \u0438 \u043f\u0440\u0438\u0445\u043e\u0434\u0438\u0442 \u0440\u0430\u0437\u0434\u0440\u0430\u0436\u0430\u044e\u0449\u0435\u0435 \u0443\u0432\u0435\u0434\u043e\u043c\u043b\u0435\u043d\u0438\u0435. \u0425\u043e\u0442\u0435\u043b\u043e\u0441\u044c, \u0447\u0442\u043e\u0431\u044b \u0441\u043e \u0432\u0440\u0435\u043c\u0435\u043d\u0435\u043c \u043d\u0435 \u043d\u0430\u043a\u0430\u043f\u043b\u0438\u0432\u0430\u043b\u0441\u044f \u043c\u0443\u0441\u043e\u0440 \u0432 \u043f\u0430\u043f\u043a\u0430\u0445, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043d\u0430\u0434\u043e \u0440\u0430\u0437\u0433\u0440\u0435\u0431\u0430\u0442\u044c \u0432\u0440\u0443\u0447\u043d\u0443\u044e. \u041e\u0441\u043e\u0431\u0435\u043d\u043d\u043e \u0432\u0430\u0436\u043d\u043e \u0437\u0430\u0431\u043b\u043e\u043a\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0442\u043e, \u0447\u0442\u043e \u043d\u0435 \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u043f\u043e\u043b\u043d\u043e\u0441\u0442\u044c\u044e \u0441\u043f\u0430\u043c\u043e\u043c: \u043f\u0440\u0438\u0433\u043b\u0430\u0448\u0435\u043d\u0438\u044f \u043d\u0430 \u043a\u043e\u043d\u0444\u0435\u0440\u0435\u043d\u0446\u0438\u0438, \u043f\u0430\u0440\u0442\u043d\u0451\u0440\u0441\u043a\u0438\u0435 \u043f\u0440\u0435\u0434\u043b\u043e\u0436\u0435\u043d\u0438\u044f, \u043a\u0440\u0435\u0434\u0438\u0442\u044b \u2014 \u0444\u043e\u0440\u043c\u0430\u043b\u044c\u043d\u043e \u043d\u0435 \u043d\u0430\u0440\u0443\u0448\u0435\u043d\u0438\u0435, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u0431\u0430\u0439\u0435\u0441\u043e\u0432\u0441\u043a\u0438\u0439 \u0444\u0438\u043b\u044c\u0442\u0440 \u0442\u0430\u043a\u0438\u0435 \u0432\u0435\u0449\u0438 \u043f\u043b\u043e\u0445\u043e \u043b\u043e\u0432\u0438\u0442.\u0421\u043d\u0430\u0447\u0430\u043b\u0430 \u0434\u0443\u043c\u0430\u043b \u0432\u0437\u044f\u0442\u044c LLM \u0447\u0435\u0440\u0435\u0437 API. Llama \u0438\u043b\u0438 GPT \u043e\u0442\u043b\u0438\u0447\u043d\u043e \u0440\u0430\u0437\u0431\u0438\u0440\u0430\u044e\u0442 \u0442\u0435\u043a\u0441\u0442, \u0441 \u043d\u0438\u043c\u0438 \u0433\u0438\u0431\u043a\u043e \u043d\u0430\u0441\u0442\u0440\u0430\u0438\u0432\u0430\u044e\u0442\u0441\u044f \u043a\u0440\u0438\u0442\u0435\u0440\u0438\u0438. \u041d\u043e \u044d\u0442\u043e \u0432\u043d\u0435\u0448\u043d\u044f\u044f \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u044c. \u0412 \u043d\u0430\u0448\u0435 \u043d\u0435\u0441\u0442\u0430\u0431\u0438\u043b\u044c\u043d\u043e\u0435 \u0441\u0435\u0442\u0435\u0432\u043e\u0435 \u0432\u0440\u0435\u043c\u044f \u0436\u0435\u043b\u0430\u0442\u0435\u043b\u044c\u043d\u043e \u0443\u043c\u0435\u043d\u044c\u0448\u0430\u0442\u044c \u0442\u0430\u043a\u0438\u0435 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438. \u0421\u0435\u0440\u0432\u0438\u0441 \u043c\u043e\u0436\u0435\u0442 \u043f\u043e\u043c\u0435\u043d\u044f\u0442\u044c \u0443\u0441\u043b\u043e\u0432\u0438\u044f, \u043e\u0442\u043a\u043b\u044e\u0447\u0438\u0442\u044c\u0441\u044f \u0432\u0440\u0435\u043c\u0435\u043d\u043d\u043e, \u0433\u0435\u043e\u0431\u043b\u043e\u043a\u0438\u0440\u043e\u0432\u043a\u0438, \u0434\u0430 \u0438 \u043c\u043d\u043e\u0433\u043e \u0447\u0435\u0433\u043e \u0435\u0449\u0451.\u041b\u043e\u043a\u0430\u043b\u044c\u043d\u0430\u044f BERT-\u043c\u043e\u0434\u0435\u043b\u044c \u0437\u0430\u043a\u0440\u044b\u043b\u0430 \u043e\u0431\u0435 \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u044b. \u0412\u0437\u044f\u043b ruBert-base-antispam \u0441 HuggingFace \u2014 \u0444\u0430\u0439\u043d-\u0442\u044e\u043d \u043d\u0430 \u0431\u0430\u0437\u0435 DeepPavlov\/rubert-base-cased-conversational. 177 \u043c\u0438\u043b\u043b\u0438\u043e\u043d\u043e\u0432 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u043e\u0432, 12 \u0441\u043b\u043e\u0451\u0432 \u0442\u0440\u0430\u043d\u0441\u0444\u043e\u0440\u043c\u0435\u0440\u0430, 768 hidden size. \u0424\u0438\u0437\u0438\u0447\u0435\u0441\u043a\u0438 \u043d\u0435 \u043f\u0440\u0438\u043d\u0438\u043c\u0430\u0435\u0442 \u0431\u043e\u043b\u044c\u0448\u0435 512 \u0442\u043e\u043a\u0435\u043d\u043e\u0432 \u043d\u0430 \u0432\u0445\u043e\u0434. \u0412 \u043f\u0430\u043c\u044f\u0442\u0438 \u0437\u0430\u043d\u0438\u043c\u0430\u0435\u0442 \u043e\u043a\u043e\u043b\u043e 550 \u041c\u0411, \u043e\u0442\u0432\u0435\u0442 \u043f\u0440\u0438\u0445\u043e\u0434\u0438\u0442 \u0437\u0430 100-200 \u043c\u0438\u043b\u043b\u0438\u0441\u0435\u043a\u0443\u043d\u0434. \u0411\u0438\u043d\u0430\u0440\u043d\u044b\u0439 \u043a\u043b\u0430\u0441\u0441\u0438\u0444\u0438\u043a\u0430\u0442\u043e\u0440 \u2014 \u0442\u0435\u043a\u0441\u0442 \u043d\u0430 \u0432\u0445\u043e\u0434\u0435, 0 \u0438\u043b\u0438 1 \u043d\u0430 \u0432\u044b\u0445\u043e\u0434\u0435, \u043d\u0438\u043a\u0430\u043a\u0438\u0445 \u043f\u0440\u043e\u043c\u043f\u0442\u043e\u0432 \u0438 reasoning. \u0418\u0434\u0435\u0430\u043b\u044c\u043d\u043e!\u0412\u0441\u0442\u0440\u043e\u0438\u0442\u044c \u0432\u044b\u0437\u043e\u0432 \u0441\u043a\u0440\u0438\u043f\u0442\u0430 \u043f\u0440\u044f\u043c\u043e \u0432 SMTP-\u043a\u043e\u043d\u0432\u0435\u0439\u0435\u0440 Exim \u043e\u043a\u0430\u0437\u0430\u043b\u043e\u0441\u044c \u043d\u0435\u043f\u0440\u043e\u0441\u0442\u043e. \u041c\u0435\u0445\u0430\u043d\u0438\u0437\u043c\u044b \u0432\u0440\u043e\u0434\u0435 ACL \u0438\u043b\u0438 transport_filter \u0438\u043c\u0435\u044e\u0442 \u0441\u0432\u043e\u0438 \u043e\u0441\u043e\u0431\u0435\u043d\u043d\u043e\u0441\u0442\u0438, \u043e\u0441\u043e\u0431\u0435\u043d\u043d\u043e \u0441 \u043c\u0443\u0434\u0440\u0435\u043d\u043e\u0439 \u043f\u0430\u043d\u0435\u043b\u044c\u044e \u0441\u0435\u0440\u0432\u0435\u0440\u0430, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u0441\u0430\u043c\u0430 \u043e\u0431\u043d\u043e\u0432\u043b\u044f\u0435\u0442 \u043c\u043d\u043e\u0433\u0438\u0435 \u0444\u0430\u0439\u043b\u044b. \u0410 \u0442\u043e \u0431\u0443\u0434\u0435\u0442 \u0442\u0430\u043a: \u0433\u0434\u0435-\u0442\u043e \u043f\u0438\u0441\u044c\u043c\u043e \u043d\u0435\u0434\u043e\u0441\u0442\u0443\u043f\u043d\u043e \u0446\u0435\u043b\u0438\u043a\u043e\u043c, \u0433\u0434\u0435-\u0442\u043e \u043f\u0440\u0430\u0432 \u043d\u0435 \u0445\u0432\u0430\u0442\u0430\u0435\u0442, \u0433\u0434\u0435-\u0442\u043e \u043c\u043e\u0434\u0438\u0444\u0438\u0446\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0439 \u0442\u0435\u043a\u0441\u0442 \u043d\u0435 \u043f\u0435\u0440\u0435\u0434\u0430\u0451\u0442\u0441\u044f \u0434\u0430\u043b\u044c\u0448\u0435, \u0433\u0434\u0435-\u0442\u043e \u0444\u0430\u0439\u043b \u043e\u0431\u043d\u043e\u0432\u0438\u043b\u0441\u044f. \u041f\u043e\u0448\u0451\u043b \u0434\u0440\u0443\u0433\u0438\u043c \u043f\u0443\u0442\u0451\u043c \u2014 post-delivery \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u043e\u0439.\u041f\u043e\u043b\u0443\u0447\u0438\u043b\u0430\u0441\u044c \u0442\u0440\u0451\u0445\u0443\u0440\u043e\u0432\u043d\u0435\u0432\u0430\u044f \u0441\u0435\u0440\u0432\u0435\u0440\u043d\u0430\u044f \u0437\u0430\u0449\u0438\u0442\u0430. \u041f\u0435\u0440\u0432\u044b\u0439 \u0443\u0440\u043e\u0432\u0435\u043d\u044c \u2014 pre-rules, \u043d\u0430\u0431\u043e\u0440 \u0440\u0435\u0433\u0443\u043b\u044f\u0440\u043e\u043a \u0434\u043b\u044f \u043e\u0447\u0435\u0432\u0438\u0434\u043d\u043e\u0433\u043e \u0441\u043f\u0430\u043c\u0430. \u0421\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u044e\u0442 \u0437\u0430 \u043c\u0438\u043b\u043b\u0438\u0441\u0435\u043a\u0443\u043d\u0434\u0443, \u0431\u0435\u0437 \u043e\u0431\u0440\u0430\u0449\u0435\u043d\u0438\u044f \u043a \u043d\u0435\u0439\u0440\u043e\u0441\u0435\u0442\u0438. \u0412\u0442\u043e\u0440\u043e\u0439 \u0443\u0440\u043e\u0432\u0435\u043d\u044c \u2014 \u0441\u0430\u043c\u0430 BERT-\u043c\u043e\u0434\u0435\u043b\u044c, \u043e\u0431\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u0435\u0442 \u0432\u0441\u0451, \u0447\u0442\u043e \u043d\u0435 \u043e\u0442\u0441\u0435\u043a\u043b\u0438 \u0440\u0435\u0433\u0443\u043b\u044f\u0440\u043a\u0438, \u044d\u0442\u043e \u043e\u043a\u043e\u043b\u043e 70% \u043f\u043e\u0442\u043e\u043a\u0430. \u0422\u0440\u0435\u0442\u0438\u0439 \u0443\u0440\u043e\u0432\u0435\u043d\u044c \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u043f\u0430\u0440\u0430\u043b\u043b\u0435\u043b\u044c\u043d\u043e \u2014 SpamAssassin \u0441\u043e \u0441\u0432\u043e\u0438\u043c \u0431\u0430\u0439\u0435\u0441\u043e\u0432\u0441\u043a\u0438\u043c \u0444\u0438\u043b\u044c\u0442\u0440\u043e\u043c. \u0415\u0441\u043b\u0438 \u043e\u043d \u0441\u0442\u0430\u0432\u0438\u0442 score \u0432\u044b\u0448\u0435 \u043f\u043e\u0440\u043e\u0433\u0430, Dovecot \u0447\u0435\u0440\u0435\u0437 Sieve \u043f\u0435\u0440\u0435\u043c\u0435\u0449\u0430\u0435\u0442 \u043f\u0438\u0441\u044c\u043c\u043e \u0432 .Spam. \u042d\u0442\u043e \u0441\u0442\u0440\u0430\u0445\u043e\u0432\u043a\u0430 \u043d\u0430 \u0441\u043b\u0443\u0447\u0430\u0439, \u0435\u0441\u043b\u0438 \u043f\u0435\u0440\u0432\u044b\u0435 \u0434\u0432\u0430 \u0443\u0440\u043e\u0432\u043d\u044f \u0447\u0442\u043e-\u0442\u043e \u043f\u0440\u043e\u043f\u0443\u0441\u0442\u0438\u043b\u0438. \u041f\u0440\u0438 \u044d\u0442\u043e\u043c AI-\u0441\u043a\u0440\u0438\u043f\u0442 \u0432\u0441\u0451 \u0440\u0430\u0432\u043d\u043e \u043f\u0440\u043e\u0432\u0435\u0440\u044f\u0435\u0442 \u043f\u0438\u0441\u044c\u043c\u043e: \u0435\u0441\u043b\u0438 SpamAssassin \u043e\u0448\u0438\u0431\u0441\u044f \u0438 \u043f\u043e\u043c\u0435\u0442\u0438\u043b \u043d\u043e\u0440\u043c\u0430\u043b\u044c\u043d\u043e\u0435 \u043f\u0438\u0441\u044c\u043c\u043e, \u0430 AI \u0441\u0447\u0438\u0442\u0430\u0435\u0442 \u0435\u0433\u043e \u0447\u0438\u0441\u0442\u044b\u043c, \u043e\u043d\u043e \u0432\u0441\u0451 \u0440\u0430\u0432\u043d\u043e \u0443\u0439\u0434\u0451\u0442 \u043d\u0430 Gmail. Fail-open \u0441\u0442\u0440\u0430\u0442\u0435\u0433\u0438\u044f \u0432 AI-\u0441\u043a\u0440\u0438\u043f\u0442\u0435 \u0441\u043f\u0430\u0441\u0430\u0435\u0442 \u043e\u0442 \u043f\u0430\u0440\u0430\u043d\u043e\u0438\u0434\u0430\u043b\u044c\u043d\u043e\u0433\u043e SpamAssassin \u0438 \u0431\u0435\u0437 \u0441\u0438\u043b\u044c\u043d\u044b\u0445 \u0437\u0430\u043c\u043e\u0440\u043e\u0447\u0435\u043a \u0441 \u043a\u043e\u044d\u0444\u0444\u0438\u0446\u0438\u0435\u043d\u0442\u0430\u043c\u0438.\u0421\u0445\u0435\u043c\u0430 \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u0442\u0430\u043a. Exim \u043f\u0440\u0438\u043d\u0438\u043c\u0430\u0435\u0442 \u043f\u0438\u0441\u044c\u043c\u043e \u0438 \u0441\u043a\u043b\u0430\u0434\u044b\u0432\u0430\u0435\u0442 \u0435\u0433\u043e \u0432 Maildir, \u0432 \u043f\u0430\u043f\u043a\u0443 new\/. \u041e\u0442\u0434\u0435\u043b\u044c\u043d\u044b\u0439 \u0441\u043a\u0440\u0438\u043f\u0442 \u043a\u0430\u0436\u0434\u044b\u0435 \u043f\u043e\u043b\u043c\u0438\u043d\u0443\u0442\u044b \u043e\u0431\u0445\u043e\u0434\u0438\u0442 \u0432\u0441\u0435 \u0434\u0438\u0440\u0435\u043a\u0442\u043e\u0440\u0438\u0438. \u0418\u0437 MIME \u0432\u044b\u0442\u0430\u0441\u043a\u0438\u0432\u0430\u0435\u0442 \u0442\u0435\u043a\u0441\u0442 \u0438 \u0437\u0430\u0433\u043e\u043b\u043e\u0432\u043a\u0438 \u2014 \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u0438\u0432\u0430\u0435\u0442 \u0438 plain, \u0438 HTML, \u0442\u0435\u0433\u0438 \u0447\u0438\u0441\u0442\u0438\u0442 \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u043d\u044b\u043c HTMLParser. \u0421\u043d\u0430\u0447\u0430\u043b\u0430 \u0433\u043e\u043d\u0438\u0442 \u0447\u0435\u0440\u0435\u0437 pre-rules, \u043f\u0440\u0438\u0447\u0451\u043c \u0441\u043c\u043e\u0442\u0440\u0438\u0442 \u043d\u0435 \u0442\u043e\u043b\u044c\u043a\u043e \u0432 \u0442\u0435\u043a\u0441\u0442, \u043d\u043e \u0438 \u0432 \u0437\u0430\u0433\u043e\u043b\u043e\u0432\u043a\u0438. \u0427\u0442\u043e \u043d\u0435 \u043e\u0442\u0441\u0435\u044f\u043b\u043e\u0441\u044c \u2014 \u0438\u0434\u0451\u0442 \u0432 \u043f\u043e\u0441\u0442\u043e\u044f\u043d\u043d\u043e \u0440\u0430\u0431\u043e\u0442\u0430\u044e\u0449\u0438\u0439 daemon \u0447\u0435\u0440\u0435\u0437 Unix-\u0441\u043e\u043a\u0435\u0442. \u0421\u043f\u0430\u043c \u043f\u0435\u0440\u0435\u043a\u043b\u0430\u0434\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u0432 .Spam\/, \u043d\u043e\u0440\u043c\u0430\u043b\u044c\u043d\u044b\u0435 \u043f\u0438\u0441\u044c\u043c\u0430 \u0438\u0434\u0443\u0442 \u0432 cur\/ \u0438 \u043f\u0430\u0440\u0430\u043b\u043b\u0435\u043b\u044c\u043d\u043e \u0443\u043b\u0435\u0442\u0430\u044e\u0442 \u043d\u0430 Gmail \u0447\u0435\u0440\u0435\u0437 sendmail.\u0417\u0430\u0434\u0435\u0440\u0436\u043a\u0430 \u043d\u0430 \u0434\u043e\u0441\u0442\u0430\u0432\u043a\u0443 \u043f\u0438\u0441\u044c\u043c\u0430 \u0432 30\u201360 \u0441\u0435\u043a\u0443\u043d\u0434 \u043c\u0435\u043d\u044f \u043d\u0435 \u0431\u0435\u0441\u043f\u043e\u043a\u043e\u0438\u0442. \u0412 \u043f\u043e\u0447\u0442\u0435 \u044f \u0432 \u0440\u0435\u0430\u043b\u044c\u043d\u043e\u043c \u0432\u0440\u0435\u043c\u0435\u043d\u0438 \u043d\u0435 \u0441\u0438\u0436\u0443, \u044d\u0442\u043e \u0436 \u043d\u0435 \u0447\u0430\u0442, \u0434\u0430 \u0438 Gmail \u043f\u043e\u0434\u0442\u044f\u0433\u0438\u0432\u0430\u0435\u0442 \u043d\u0435 \u043f\u0440\u044f\u043c \u043c\u0433\u043d\u043e\u0432\u0435\u043d\u043d\u043e. \u041f\u043e\u0447\u0442\u0430 \u043d\u0443\u0436\u043d\u0430 \u0434\u043b\u044f \u0441\u043f\u043e\u043a\u043e\u0439\u043d\u044b\u0445 \u043f\u0435\u0440\u0435\u043f\u0438\u0441\u043e\u043a, \u0430 \u043d\u0435 \u0434\u043b\u044f \u0433\u043e\u043d\u043e\u043a \u043a\u0442\u043e \u0431\u044b\u0441\u0442\u0440\u0435\u0435 \u043e\u0442\u0432\u0435\u0442\u0438\u043b.\u041f\u0440\u0438\u0432\u043e\u0436\u0443 \u043f\u0440\u0438\u043c\u0435\u0440 daemon (\/opt\/spam_filter\/daemon.py):#!\/usr\/bin\/env python3import socket, sys, os, re, signal, loggingimport torchfrom transformers import AutoTokenizer, AutoModelForSequenceClassificationMODEL_NAME = &#171;assskelad\/ruBert-base-antispam&#187;  # \u043b\u044e\u0431\u0430\u044f BertForSequenceClassificationSOCKET_PATH = &#171;\/tmp\/spam_filter.sock&#187;MAX_LEN = 512      # \u043b\u0438\u043c\u0438\u0442 BERTMAX_TEXT = 6000    # \u0441\u0438\u043c\u0432\u043e\u043b\u044b \u0438\u0437 \u043f\u0438\u0441\u044c\u043c\u0430logging.basicConfig(level=logging.INFO)logger = logging.getLogger(&#171;spam_daemon&#187;)torch.set_num_threads(1)tokenizer = AutoTokenizer.from_pretrained(MODEL_NAME)model = AutoModelForSequenceClassification.from_pretrained(MODEL_NAME)model.eval()def predict(text: str) -&gt; int:    inputs = tokenizer(text, return_tensors=&#187;pt&#187;, truncation=True, max_length=MAX_LEN)    with torch.inference_mode():        out = model(**inputs)        return int(torch.argmax(out.logits, dim=1).item())def handle(conn):    try:        data = conn.recv(1024 * 1024)        text = data.decode(&#171;utf-8&#8243;, errors=&#187;replace&#187;)[:MAX_TEXT]        result = predict(text) if text else 0        conn.sendall(str(result).encode())    except Exception as e:        logger.error(f&#187;Error: {e}&#187;)        conn.sendall(b&#187;0&#8243;)    finally:        conn.close()def shutdown(signum, frame):    try:        os.unlink(SOCKET_PATH)    except:        pass    sys.exit(0)signal.signal(signal.SIGTERM, shutdown)signal.signal(signal.SIGINT, shutdown)srv = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM)srv.bind(SOCKET_PATH)srv.listen(10)while True:    conn, _ = srv.accept()    handle(conn)Pre-rules (\/opt\/spam_filter\/pre_rules.py) \u2014 \u043f\u0430\u0442\u0442\u0435\u0440\u043d\u044b:#!\/usr\/bin\/env python3import redef check_pre_rules(text, headers=None):    text_lower = text.lower()    headers = headers or {}        # \u043f\u0430\u0442\u0442\u0435\u0440\u043d\u044b    spam_patterns = [        r&#8217;\u0440\u0430\u0441\u0441\u044b\u043b\u043a[\u0430\u0438]\\s+\u043f\u043e\\s+\u0431\u0430\u0437|\u043c\u0438\u043b\u043b\u0438\u043e\u043d\\s+\u0430\u0434\u0440\u0435\u0441&#8217;,        r&#8217;\u0432\u043d\u0435\u0434\u0440\u0435\u043d\u0438.{0,15}crm|\u0431\u043e\u0442\\s+\u043f\u0440\u043e\u0434\u0432\u0438\u0436\u0435\u043d\u0438.{0,20}(?:telegram|whatsapp)&#8217;,        r&#8217;\u0434\u0438\u043f\u043b\u043e\u043c.{0,20}(?:\u043f\u0440\u043e\u0444\u043f\u0435\u0440\u0435\u043f\u043e\u0434\u0433\u043e\u0442\u043e\u0432\u043a|\u0434\u043e\u043f\u043e\u0431\u0440\u0430\u0437\u043e\u0432\u0430\u043d)&#8217;,        r&#8217;\u0431\u0443\u0445\u0433\u0430\u043b\u0442\u0435\u0440\u0441\u043a.{0,30}\u0441\u043e\u043f\u0440\u043e\u0432\u043e\u0436\u0434\u0435\u043d|\u043d\u0443\u043b\u0435\u0432\u043e\u0439.{0,20}\u043d\u0434\u0441&#8217;,        r&#8217;\u0441\u043f\u0430\u0440\u0441\u0438\u0442\u044c.{0,30}\u0431\u0430\u0437\u0443|\u043f\u0430\u0440\u0441\u0438\u043d\u0433.{0,30}\u043a\u043b\u0438\u0435\u043d\u0442\u043e\u0432&#8217;,        r&#8217;\u043f\u043e\u0434\u0442\u0432\u0435\u0440\u0434\u0438\u0442\u0435.{0,30}\u0434\u0430\u043d\u043d\u044b.{0,200}\u043f\u0440\u0435\u0434\u043b\u043e\u0436\u0435\u043d\u0438\u0435\\s+\u0438\u0441\u0442\u0435\u043a\u0430\u0435\u0442&#8217;,        r'(?:[\u0430-\u044f]\\s){4,}&#8217;,        r&#8217;\u0434\u0435\u043d\u044c\u0433\u0438\\s+\u043f\u043e\u0434\\s+\u0437\u0430\u043b\u043e\u0433.{0,20}(?:\u0430\u0432\u0442\u043e|\u043c\u0430\u0448\u0438\u043d)&#8217;,        r&#8217;\u0441\u0435\u043e\\s+\u043e\u043f\u0442\u0438\u043c\u0438\u0437\u0430\u0446.{0,20}\u043d\u0435\u0434\u043e\u0440\u043e\u0433\u043e&#8217;,    ]    for pattern in spam_patterns:        if re.search(pattern, text_lower):            return &#171;SPAM&#187;        # \u0440\u0430\u0441\u0441\u044b\u043b\u043a\u0438    bulk_headers = any(        k.lower() in [&#8216;list-unsubscribe&#8217;, &#8216;precedence&#8217;, &#8216;feedback-id&#8217;, &#8216;x-rpcampaign&#8217;]        for k in headers    )    if bulk_headers and re.search(r&#8217;\u043f\u0440\u0435\u0434\u043b\u0430\u0433\u0430\u0435\u043c|\u043f\u0440\u0438\u0433\u043b\u0430\u0448\u0430\u0435\u043c|\u0431\u0435\u0441\u043f\u043b\u0430\u0442\u043d.{0,20}\u043a\u043e\u043d\u0441\u0443\u043b\u044c\u0442\u0430\u0446&#8217;, text_lower):        return &#171;SPAM&#187;        # \u0441\u043f\u0430\u043c    if re.search(r&#8217;\u043a\u0435\u0442\u043e|\u043c\u0435\u0442\u0430\u0431\u043e\u043b\u0438\u0437\u043c|\u0438\u043d\u0441\u0443\u043b\u0438\u043d|\u0436\u0438\u0440\u043e\u0441\u0436\u0438\u0433\u0430\u043d\u0438[\u0435\u044e]|\u0436\u043a\u0442&#8217;, text_lower) and \\       re.search(r&#8217;\u0442\u044b\\s+\u0443\u0441\u0442\u0430\u043b|\u044d\u043d\u0435\u0440\u0433\u0438[\u044f\u0438]\\s+\u043d\u0430\\s+\u043d\u0443\u043b\u0435|\u043c\u044b\\s+\u0434\u0430[\u0435\u0451]\u043c\\s+\u0441\u0438\u0441\u0442\u0435\u043c\u0443&#8217;, text_lower):        return &#171;SPAM&#187;        # \u043d\u0443\u0436\u043d\u044b\u0435 \u043f\u0438\u0441\u044c\u043c\u0430    ham_patterns = [        r&#8217;\u043a\u043e\u0434\\s+(?:\u043f\u043e\u0434\u0442\u0432\u0435\u0440\u0436\u0434\u0435\u043d|\u0434\u043b\u044f\\s+\u0432\u0445\u043e\u0434|\u0434\u043e\u0441\u0442\u0443\u043f\u0430):\\s*\\d{4,6}&#8217;,        r&#8217;\u0432\u0430\u0448\\s+\u0437\u0430\u043a\u0430\u0437\\s+\u2116?\\d+|order\\s+#?\\d+&#8217;,        r&#8217;\u0441\u0431\u0440\u043e\u0441\\s+\u043f\u0430\u0440\u043e\u043b|password\\s+reset&#8217;,        r&#8217;\u043f\u043b\u0430\u0442\u0435\u0436\\s+\u043f\u0440\u043e\u0448\u0435\u043b|payment\\s+received&#8217;,        r&#8217;\u0432\u0441\u0442\u0440\u0435\u0447[\u0430\u0438]\\s+(?:\u043f\u0435\u0440\u0435\u043d\u0435\u0441\u0435\u043d|\u043d\u0430\u0437\u043d\u0430\u0447\u0435\u043d|\u0441\u043e\u0441\u0442\u043e\u0438\u0442\u0441\u044f)&#8217;,    ]    for pattern in ham_patterns:        if re.search(pattern, text_lower):            return &#171;HAM&#187;        return None\u041f\u0440\u0430\u0432\u0438\u043b\u043e \u043f\u0440\u043e \u043c\u0430\u0441\u0441\u043e\u0432\u044b\u0435 \u0440\u0430\u0441\u0441\u044b\u043b\u043a\u0438 \u043e\u043a\u0430\u0437\u0430\u043b\u043e\u0441\u044c \u043e\u0447\u0435\u043d\u044c \u043f\u043e\u043b\u0435\u0437\u043d\u044b\u043c. \u041d\u0435\u0439\u0440\u043e\u0441\u0435\u0442\u044c \u0447\u0430\u0441\u0442\u043e \u043f\u0440\u043e\u043f\u0443\u0441\u043a\u0430\u0435\u0442 \u0442\u0430\u043a\u0438\u0435 \u043f\u0438\u0441\u044c\u043c\u0430, \u043f\u043e\u0442\u043e\u043c\u0443 \u0447\u0442\u043e \u043e\u043d\u0438 \u0433\u0440\u0430\u043c\u043c\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0438 \u043a\u043e\u0440\u0440\u0435\u043a\u0442\u043d\u044b \u0438 \u043d\u0435 \u0441\u043e\u0434\u0435\u0440\u0436\u0430\u0442 \u044f\u0432\u043d\u043e\u0433\u043e \u043c\u0443\u0441\u043e\u0440\u0430. \u0410 \u0441\u0432\u044f\u0437\u043a\u0430 \u0437\u0430\u0433\u043e\u043b\u043e\u0432\u043e\u043a List-Unsubscribe + \u0441\u043b\u043e\u0432\u043e \u043f\u0440\u0438\u0433\u043b\u0430\u0448\u0430\u0435\u043c \u0432 \u0442\u0435\u043a\u0441\u0442\u0435 \u0434\u0430\u0451\u0442 100% \u0442\u043e\u0447\u043d\u043e\u0441\u0442\u0438 \u0431\u0435\u0437 \u043b\u043e\u0436\u043d\u044b\u0445 \u0441\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u043d\u0438\u0439 \u043d\u0430 \u043b\u0438\u0447\u043d\u044b\u0435 \u043f\u0438\u0441\u044c\u043c\u0430. \u041f\u0440\u0430\u0432\u0438\u043b\u043e \u043f\u0440\u043e \u043c\u0435\u0434\u0438\u0446\u0438\u043d\u0441\u043a\u0438\u0435 \u0442\u0435\u0440\u043c\u0438\u043d\u044b \u2014 \u043f\u0440\u0438\u043c\u0435\u0440 \u0441\u043e\u0441\u0442\u0430\u0432\u043d\u043e\u0439 \u0440\u0435\u0433\u0443\u043b\u044f\u0440\u043a\u0438: \u043f\u043e \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u0438 \u0441\u043b\u043e\u0432\u0430 \u043c\u043e\u0433\u0443\u0442 \u0443\u043f\u043e\u0442\u0440\u0435\u0431\u043b\u044f\u0442\u044c\u0441\u044f \u0432 \u043f\u0435\u0440\u0435\u043f\u0438\u0441\u043a\u0435, \u043d\u043e \u0432 \u0441\u043e\u0447\u0435\u0442\u0430\u043d\u0438\u0438 \u0441 \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u043c\u0438 \u044d\u0442\u043e \u043e\u0434\u043d\u043e\u0437\u043d\u0430\u0447\u043d\u044b\u0439 \u0441\u043f\u0430\u043c. \u0422\u0430\u043a \u0444\u0430\u0439\u043b pre_rules.py \u0441\u043e \u0432\u0440\u0435\u043c\u0435\u043d\u0435\u043c \u043e\u0431\u0440\u0430\u0441\u0442\u0430\u0435\u0442 \u0441\u043f\u0435\u0446\u0438\u0444\u0438\u0447\u043d\u044b\u043c\u0438 \u043f\u0440\u0430\u0432\u0438\u043b\u0430\u043c\u0438 \u043f\u043e\u0434 \u0432\u0430\u0448 \u043f\u043e\u0442\u043e\u043a, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0438\u043d\u043e\u0433\u0434\u0430 \u043c\u043e\u0436\u043d\u043e \u043f\u043e\u043f\u043e\u043b\u043d\u044f\u0442\u044c.\u0421\u043e\u043a\u0440\u0430\u0449\u0435\u043d\u043d\u044b\u0439 Post-delivery \u0441\u043a\u0440\u0438\u043f\u0442:#!\/usr\/bin\/env python3import os, sys, socket, datetime, time, subprocessfrom email import policyfrom email.parser import BytesParserfrom html.parser import HTMLParserimport reSOCKET = &#171;\/tmp\/spam_filter.sock&#187;MAIL_BASE = &#171;\/home\/admin\/mail&#187;         # \u043f\u0443\u0442\u044cFORWARD_TO = &#171;your@gmail.com&#187;          # \u043a\u0443\u0434\u0430 \u043f\u0440\u0438\u0441\u044b\u043b\u0430\u0442\u044cWAIT_SECONDS = 5                       # \u043e\u0436\u0438\u0434\u0430\u043d\u0438\u0435LOCK_FILE = &#171;\/tmp\/ai_spam_check.lock&#187;def check_spam(email_bytes):    text, headers = extract_text_and_headers(email_bytes)        pre_verdict = check_pre_rules(text, headers)    if pre_verdict == &#171;SPAM&#187;:        return True, text[:100], &#171;pre_rule&#187;    elif pre_verdict == &#171;HAM&#187;:        return False, text[:100], &#171;pre_rule&#187;        text_bytes = text.encode(&#8216;utf-8&#8242;, errors=&#8217;ignore&#8217;)    try:        s = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM)        s.settimeout(2)        s.connect(SOCKET)        s.settimeout(5)        s.sendall(text_bytes)        s.shutdown(socket.SHUT_WR)        r = s.recv(8).decode(&#171;ascii&#187;, errors=&#187;ignore&#187;).strip()        s.close()        return r == &#171;1&#187;, text[:100], &#171;ai&#187;    except Exception as e:        log(f&#187;DAEMON_ERROR: {e}&#187;)        return False, text[:100], &#171;error&#187;def forward_to_gmail(email_bytes, filename=&#187;&#187;):    modified = b&#187;X-Forwarded-By: AI-Filter\\n&#187; + email_bytes    p = subprocess.Popen(        [&#171;\/usr\/sbin\/sendmail&#187;, &#171;-i&#187;, FORWARD_TO],        stdin=subprocess.PIPE,        stdout=subprocess.DEVNULL,        stderr=subprocess.DEVNULL    )    p.stdin.write(modified)    p.stdin.close()    p.wait()def process_new_dir(new_dir, spam_new_dir, cur_dir):    for filename in os.listdir(new_dir):        filepath = os.path.join(new_dir, filename)        if time.time() &#8212; os.path.getmtime(filepath) &lt; WAIT_SECONDS:            continue                with open(filepath, &#171;rb&#187;) as f:            email_bytes = f.read()                if b&#187;X-Forwarded-By: AI-Filter&#187; in email_bytes:            os.rename(filepath, os.path.join(cur_dir, filename + &#171;:2,&#187;))            continue                is_spam, preview, method = check_spam(email_bytes)        if is_spam:&#8230;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[],"tags":[],"class_list":["post-486159","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/486159","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=486159"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/486159\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=486159"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=486159"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=486159"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}