{"id":301535,"date":"2020-04-08T21:00:31","date_gmt":"2020-04-08T21:00:31","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=301535"},"modified":"-0001-11-30T00:00:00","modified_gmt":"2020-04-08T21:00:31","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=301535","title":{"rendered":"\u0410\u043b\u0433\u043e\u0440\u0438\u0442\u043c \u043e\u0431\u0440\u0430\u0442\u043d\u043e\u0433\u043e \u0440\u0430\u0441\u043f\u0440\u043e\u0441\u0442\u0440\u0430\u043d\u0435\u043d\u0438\u044f \u043e\u0448\u0438\u0431\u043a\u0438 \u043d\u0430 \u043f\u0440\u0438\u043c\u0435\u0440\u0435 Word2Vec"},"content":{"rendered":"\n<div class=\"post__text post__text-html post__text_v1\" id=\"post-content-body\" data-io-article-url=\"https:\/\/habr.com\/ru\/post\/496186\/\">\n<p>\u041f\u043e\u0441\u043a\u043e\u043b\u044c\u043a\u0443 \u044f \u0441\u0442\u043e\u043b\u043a\u043d\u0443\u043b\u0441\u044f \u0441 \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0435\u043d\u043d\u044b\u043c\u0438 \u0437\u0430\u0442\u0440\u0443\u0434\u043d\u0435\u043d\u0438\u044f\u043c\u0438 \u0432 \u043f\u043e\u0438\u0441\u043a\u0430\u0445 \u043e\u0431\u044a\u044f\u0441\u043d\u0435\u043d\u0438\u044f \u043c\u0435\u0445\u0430\u043d\u0438\u0437\u043c\u0430 \u043e\u0431\u0440\u0430\u0442\u043d\u043e\u0433\u043e \u0440\u0430\u0441\u043f\u0440\u043e\u0441\u0442\u0440\u0430\u043d\u0435\u043d\u0438\u044f \u043e\u0448\u0438\u0431\u043a\u0438, \u043a\u043e\u0442\u043e\u0440\u043e\u0435 \u043c\u043d\u0435 \u043f\u043e\u043d\u0440\u0430\u0432\u0438\u043b\u043e\u0441\u044c \u0431\u044b, \u044f \u0440\u0435\u0448\u0438\u043b \u043d\u0430\u043f\u0438\u0441\u0430\u0442\u044c \u0441\u043e\u0431\u0441\u0442\u0432\u0435\u043d\u043d\u044b\u0439 \u043f\u043e\u0441\u0442 \u043e\u0431 \u043e\u0431\u0440\u0430\u0442\u043d\u043e\u043c \u0440\u0430\u0441\u043f\u0440\u043e\u0441\u0442\u0440\u0430\u043d\u0435\u043d\u0438\u0438 \u043e\u0448\u0438\u0431\u043a\u0438 \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u0432 \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c Word2Vec. \u041c\u043e\u044f \u0446\u0435\u043b\u044c, \u2014 \u043e\u0431\u044a\u044f\u0441\u043d\u0438\u0442\u044c \u0441\u0443\u0449\u043d\u043e\u0441\u0442\u044c \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u0430, \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044f \u043f\u0440\u043e\u0441\u0442\u0443\u044e, \u043d\u043e \u043d\u0435\u0442\u0440\u0438\u0432\u0438\u0430\u043b\u044c\u043d\u0443\u044e \u043d\u0435\u0439\u0440\u043e\u0441\u0435\u0442\u044c. \u041a\u0440\u043e\u043c\u0435 \u0442\u043e\u0433\u043e, word2vec \u0441\u0442\u0430\u043b \u043d\u0430\u0441\u0442\u043e\u043b\u044c\u043a\u043e \u043f\u043e\u043f\u0443\u043b\u044f\u0440\u043d\u044b\u043c \u0432 NLP \u0441\u043e\u043e\u0431\u0449\u0435\u0441\u0442\u0432\u0435, \u0447\u0442\u043e \u0431\u0443\u0434\u0435\u0442 \u043f\u043e\u043b\u0435\u0437\u043d\u043e \u0441\u043e\u0441\u0440\u0435\u0434\u043e\u0442\u043e\u0447\u0438\u0442\u044c\u0441\u044f \u043d\u0430 \u043d\u0435\u043c.<\/p>\n<p><a name=\"habracut\"><\/a>  <\/p>\n<p>\u0414\u0430\u043d\u043d\u044b\u0439 \u043f\u043e\u0441\u0442 \u0441\u0432\u044f\u0437\u0430\u043d \u0441 \u0434\u0440\u0443\u0433\u0438\u043c, \u0431\u043e\u043b\u0435\u0435 <a href=\"http:\/\/www.claudiobellei.com\/2018\/01\/07\/backprop-word2vec-python\/\" rel=\"nofollow\">\u043f\u0440\u0430\u043a\u0442\u0438\u0447\u0435\u0441\u043a\u0438\u043c \u043f\u043e\u0441\u0442\u043e\u043c<\/a> \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0440\u0435\u043a\u043e\u043c\u0435\u043d\u0434\u0443\u044e \u043f\u0440\u043e\u0447\u0438\u0442\u0430\u0442\u044c, \u0432 \u043d\u0435\u043c \u0440\u0430\u0441\u0441\u043c\u0430\u0442\u0440\u0438\u0432\u0430\u0435\u0442\u0441\u044f \u043d\u0435\u043f\u043e\u0441\u0440\u0435\u0434\u0441\u0442\u0432\u0435\u043d\u043d\u0430\u044f \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f word2vec \u043d\u0430 \u044f\u0437\u044b\u043a\u0435 python. \u0412 \u0434\u0430\u043d\u043d\u043e\u043c \u0436\u0435 \u043f\u043e\u0441\u0442\u0435 \u043c\u044b \u0441\u043e\u0441\u0440\u0435\u0434\u043e\u0442\u043e\u0447\u0438\u043c\u0441\u044f \u0432 \u043e\u0441\u043d\u043e\u0432\u043d\u043e\u043c \u043d\u0430 \u0442\u0435\u043e\u0440\u0435\u0442\u0438\u0447\u0435\u0441\u043a\u043e\u0439 \u0447\u0430\u0441\u0442\u0438.<\/p>\n<p>  <\/p>\n<p>\u041d\u0430\u0447\u043d\u0435\u043c \u0441 \u0432\u0435\u0449\u0435\u0439 \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u044b \u0434\u043b\u044f \u043d\u0430\u0441\u0442\u043e\u044f\u0449\u0435\u0433\u043e \u043f\u043e\u043d\u0438\u043c\u0430\u043d\u0438\u044f \u043e\u0431\u0440\u0430\u0442\u043d\u043e\u0433\u043e \u0440\u0430\u0441\u043f\u0440\u043e\u0441\u0442\u0440\u0430\u043d\u0435\u043d\u0438\u044f. \u041f\u043e\u043c\u0438\u043c\u043e \u043f\u043e\u043d\u044f\u0442\u0438\u0439 \u0438\u0437 \u043c\u0430\u0448\u0438\u043d\u043d\u043e\u0433\u043e \u043e\u0431\u0443\u0447\u0435\u043d\u0438\u044f, \u0442\u0430\u043a\u0438\u0445 \u043a\u0430\u043a, \u0444\u0443\u043d\u043a\u0446\u0438\u044f \u043f\u043e\u0442\u0435\u0440\u044c \u0438 \u0433\u0440\u0430\u0434\u0438\u0435\u043d\u0442\u043d\u044b\u0439 \u0441\u043f\u0443\u0441\u043a, \u043f\u0440\u0438\u0433\u043e\u0434\u044f\u0442\u0441\u044f \u0435\u0449\u0435 \u0434\u0432\u0430 \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u0430 \u0438\u0437 \u043c\u0430\u0442\u0435\u043c\u0430\u0442\u0438\u043a\u0438:<\/p>\n<p>  <\/p>\n<ul>\n<li>\u043b\u0438\u043d\u0435\u0439\u043d\u0430\u044f \u0430\u043b\u0433\u0435\u0431\u0440\u0430 (\u0432 \u0447\u0430\u0441\u0442\u043d\u043e\u0441\u0442\u0438 \u043c\u0430\u0442\u0440\u0438\u0447\u043d\u043e\u0435 \u0443\u043c\u043d\u043e\u0436\u0435\u043d\u0438\u0435)<\/li>\n<li><a href=\"https:\/\/www.khanacademy.org\/math\/multivariable-calculus\/multivariable-derivatives\/differentiating-vector-valued-functions\/a\/multivariable-chain-rule-simple-version\" rel=\"nofollow\">\u043f\u0440\u0430\u0432\u0438\u043b\u043e \u0446\u0435\u043f\u043e\u0447\u043a\u0438 \u0434\u0438\u0444\u0444\u0435\u0440\u0435\u043d\u0446\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u0444\u0443\u043d\u043a\u0446\u0438\u0439 \u043e\u0442 \u043c\u043d\u043e\u0433\u0438\u0445 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0445<\/a><\/li>\n<\/ul>\n<p>  <\/p>\n<p>\u0415\u0441\u043b\u0438 \u0432\u0430\u043c \u0437\u043d\u0430\u043a\u043e\u043c\u044b \u044d\u0442\u0438 \u043f\u043e\u043d\u044f\u0442\u0438\u044f, \u0442\u043e \u0434\u0430\u043b\u044c\u043d\u0435\u0439\u0448\u0438\u0435 \u0440\u0430\u0441\u0441\u0443\u0436\u0434\u0435\u043d\u0438\u044f \u043e\u043a\u0430\u0436\u0443\u0442\u0441\u044f \u043f\u0440\u043e\u0441\u0442\u044b\u043c\u0438. \u0415\u0441\u043b\u0438 \u0436\u0435 \u0432\u044b \u0435\u0449\u0435 \u043d\u0435 \u043e\u0441\u0432\u043e\u0438\u043b\u0438 \u0438\u0445, \u0442\u043e \u0432\u0441\u0435 \u0440\u0430\u0432\u043d\u043e \u0441\u043c\u043e\u0436\u0435\u0442\u0435 \u043f\u043e\u043d\u044f\u0442\u044c \u043e\u0441\u043d\u043e\u0432\u044b \u043e\u0431\u0440\u0430\u0442\u043d\u043e\u0433\u043e \u0440\u0430\u0441\u043f\u0440\u043e\u0441\u0442\u0440\u0430\u043d\u0435\u043d\u0438\u044f.<\/p>\n<p>  <\/p>\n<p>\u0421\u043f\u0435\u0440\u0432\u0430 \u044f \u0445\u043e\u0447\u0443 \u0434\u0430\u0442\u044c \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u0435 \u043f\u043e\u043d\u044f\u0442\u0438\u044e \u043e\u0431\u0440\u0430\u0442\u043d\u043e\u0433\u043e \u0440\u0430\u0441\u043f\u0440\u043e\u0441\u0442\u0440\u0430\u043d\u0435\u043d\u0438\u044f, \u0435\u0441\u043b\u0438 \u0441\u043c\u044b\u0441\u043b \u0431\u0443\u0434\u0435\u0442 \u043d\u0435\u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e \u043f\u043e\u043d\u044f\u0442\u0435\u043d, \u043e\u043d \u0431\u0443\u0434\u0435\u0442 \u0440\u0430\u0441\u043a\u0440\u044b\u0442 \u043f\u043e\u0434\u0440\u043e\u0431\u043d\u0435\u0435 \u0432 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0445 \u043f\u0443\u043d\u043a\u0442\u0430\u0445.<\/p>\n<p>  <\/p>\n<h3 id=\"1-chto-takoe-algoritm-obratnogo-rasprostraneniya\">1. \u0427\u0442\u043e \u0442\u0430\u043a\u043e\u0435 \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c \u043e\u0431\u0440\u0430\u0442\u043d\u043e\u0433\u043e \u0440\u0430\u0441\u043f\u0440\u043e\u0441\u0442\u0440\u0430\u043d\u0435\u043d\u0438\u044f<\/h3>\n<p>  <\/p>\n<p>\u0412 \u0440\u0430\u043c\u043a\u0430\u0445 \u043d\u0435\u0439\u0440\u043e\u043d\u043d\u043e\u0439 \u0441\u0435\u0442\u0438, \u0435\u0434\u0438\u043d\u0441\u0442\u0432\u0435\u043d\u043d\u044b\u043c\u0438 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u0430\u043c\u0438 \u0443\u0447\u0430\u0441\u0442\u0432\u0443\u044e\u0449\u0438\u043c\u0438 \u0432 \u043e\u0431\u0443\u0447\u0435\u043d\u0438\u0438 \u0441\u0435\u0442\u0438, \u0442\u043e \u0435\u0441\u0442\u044c \u043c\u0438\u043d\u0438\u043c\u0438\u0437\u0430\u0446\u0438\u0438 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u043f\u043e\u0442\u0435\u0440\u044c, \u044f\u0432\u043b\u044f\u044e\u0442\u0441\u044f \u0432\u0435\u0441\u0430 (\u0437\u0434\u0435\u0441\u044c \u0438\u043c\u0435\u044e \u0432 \u0432\u0438\u0434\u0443 \u0432\u0435\u0441\u0430 \u0432 \u0448\u0438\u0440\u043e\u043a\u043e\u043c \u0441\u043c\u044b\u0441\u043b\u0435, \u043e\u0442\u043d\u043e\u0441\u044f \u043a \u043d\u0438\u043c \u0438 \u0441\u043c\u0435\u0449\u0435\u043d\u0438\u044f). \u0412\u0435\u0441\u0430 \u0438\u0437\u043c\u0435\u043d\u044f\u044e\u0442\u0441\u044f \u043d\u0430 \u043a\u0430\u0436\u0434\u043e\u0439 \u0438\u0442\u0435\u0440\u0430\u0446\u0438\u0438, \u043f\u043e\u043a\u0430 \u043c\u044b \u043d\u0435 \u043f\u0440\u0438\u0431\u043b\u0438\u0437\u0438\u043c\u0441\u044f \u043a \u043c\u0438\u043d\u0438\u043c\u0443\u043c\u0443 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u043f\u043e\u0442\u0435\u0440\u044c.<\/p>\n<p>  <\/p>\n<p>\u0412 \u0442\u0430\u043a\u043e\u043c \u043a\u043e\u043d\u0442\u0435\u043a\u0441\u0442\u0435, \u043e\u0431\u0440\u0430\u0442\u043d\u043e\u0435 \u0440\u0430\u0441\u043f\u0440\u043e\u0441\u0442\u0440\u0430\u043d\u0435\u043d\u0438\u0435 \u2014 \u044d\u0442\u043e \u044d\u0444\u0444\u0435\u043a\u0442\u0438\u0432\u043d\u044b\u0439 \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c \u043d\u0430\u0445\u043e\u0436\u0434\u0435\u043d\u0438\u044f \u043e\u043f\u0442\u0438\u043c\u0430\u043b\u044c\u043d\u044b\u0445 \u0432\u0435\u0441\u043e\u0432 \u043d\u0435\u0439\u0440\u043e\u043d\u043d\u043e\u0439 \u0441\u0435\u0442\u0438, \u0442\u043e \u0435\u0441\u0442\u044c \u0442\u0435\u0445, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043e\u043f\u0442\u0438\u043c\u0438\u0437\u0438\u0440\u0443\u044e\u0442 \u0444\u0443\u043d\u043a\u0446\u0438\u044e \u043f\u043e\u0442\u0435\u0440\u044c.<br \/>  \u0421\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u043d\u044b\u0439 \u0441\u043f\u043e\u0441\u043e\u0431 \u043d\u0430\u0445\u043e\u0436\u0434\u0435\u043d\u0438\u044f \u044d\u0442\u0438\u0445 \u0432\u0435\u0441\u043e\u0432, \u043f\u0440\u0438\u043c\u0435\u043d\u0435\u043d\u0438\u0435 \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u0430 \u0433\u0440\u0430\u0434\u0438\u0435\u043d\u0442\u043d\u043e\u0433\u043e \u0441\u043f\u0443\u0441\u043a\u0430, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043f\u043e\u0434\u0440\u0430\u0437\u0443\u043c\u0435\u0432\u0430\u0435\u0442 \u043d\u0430\u0445\u043e\u0436\u0434\u0435\u043d\u0438\u0435 \u0447\u0430\u0441\u0442\u043d\u044b\u0445 \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u043d\u044b\u0445 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u043f\u043e\u0442\u0435\u0440\u044c \u043f\u043e \u0432\u0441\u0435\u043c \u0432\u0435\u0441\u0430\u043c.<br \/>  \u0414\u043b\u044f \u0442\u0440\u0438\u0432\u0438\u0430\u043b\u044c\u043d\u044b\u0445 \u0437\u0430\u0434\u0430\u0447 \u0432 \u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u0432\u0441\u0435\u0433\u043e \u0434\u0432\u0435 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0445, \u043b\u0435\u0433\u043a\u043e \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u0438\u0442\u044c \u043a\u0430\u043a \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u0433\u0440\u0430\u0434\u0438\u0435\u043d\u0442\u043d\u044b\u0439 \u0441\u043f\u0443\u0441\u043a, \u0435\u0441\u043b\u0438 \u0432\u044b \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0438\u0442\u0435 \u043d\u0430 \u0440\u0438\u0441\u0443\u043d\u043e\u043a, \u0442\u043e \u0443\u0432\u0438\u0434\u0438\u0442\u0435 \u0442\u0440\u0435\u0445\u043c\u0435\u0440\u043d\u044b\u0439 \u0433\u0440\u0430\u0444\u0438\u043a \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u043f\u043e\u0442\u0435\u0440\u044c, \u043a\u0430\u043a \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u0432\u0435\u0441\u043e\u0432 w1 \u0438 w2.<\/p>\n<p>  <\/p>\n<p><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/webt\/bz\/br\/pp\/bzbrppuglfkr0oy7-mgsldzhed4.png\"><br \/>  <em>\u0420\u0438\u0441\u0443\u043d\u043e\u043a 1. \u0412\u0438\u0437\u0443\u0430\u043b\u044c\u043d\u043e\u0435 \u043e\u0431\u044a\u044f\u0441\u043d\u0435\u043d\u0438\u0435 \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u0430 \u0433\u0440\u0430\u0434\u0438\u0435\u043d\u0442\u043d\u043e\u0433\u043e \u0441\u043f\u0443\u0441\u043a\u0430.<\/em><\/p>\n<p>  <\/p>\n<p>\u0412\u043d\u0430\u0447\u0430\u043b\u0435 \u043c\u044b \u043d\u0435 \u0437\u043d\u0430\u0435\u043c \u043e\u043f\u0442\u0438\u043c\u0430\u043b\u044c\u043d\u044b\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f, \u0442\u043e \u0435\u0441\u0442\u044c \u043d\u0435 \u0437\u043d\u0430\u0435\u043c \u043a\u0430\u043a\u0438\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f w1 \u0438 w2 \u043c\u0438\u043d\u0438\u043c\u0438\u0437\u0438\u0440\u0443\u044e\u0442 \u0444\u0443\u043d\u043a\u0446\u0438\u044e \u043f\u043e\u0442\u0435\u0440\u044c.<\/p>\n<p>  <\/p>\n<p>\u0414\u043e\u043f\u0443\u0441\u0442\u0438\u043c, \u043c\u044b \u043d\u0430\u0447\u0438\u043d\u0430\u0435\u043c \u0441 \u043a\u0440\u0430\u0441\u043d\u043e\u0439 \u0442\u043e\u0447\u043a\u0438. \u0415\u0441\u043b\u0438 \u043c\u044b \u0437\u043d\u0430\u0435\u043c \u043a\u0430\u043a \u0438\u0437\u043c\u0435\u043d\u044f\u0435\u0442\u0441\u044f \u0444\u0443\u043d\u043a\u0446\u0438\u044f \u043f\u043e\u0442\u0435\u0440\u044c \u043f\u0440\u0438 \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u0438 \u0432\u0435\u0441\u043e\u0432, \u0442\u043e \u0435\u0441\u0442\u044c \u0435\u0441\u043b\u0438 \u043c\u044b \u0437\u043d\u0430\u0435\u043c \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u043d\u044b\u0435 <math><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/formulas\/4ff\/9e8\/b3e\/4ff9e8b3e96473ae4d599f5796ab4610.svg\" alt=\"$\\partial\\mathcal{L}\/\\partial w_1$\" data-tex=\"inline\"><\/math> \u0438 <math><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/formulas\/e2a\/c5d\/c17\/e2ac5dc174084155cd115c5d4a464a51.svg\" alt=\"$\\partial\\mathcal{L}\/\\partial w_2$\" data-tex=\"inline\"><\/math>, \u0442\u043e \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u0441\u0434\u0432\u0438\u043d\u0443\u0442\u044c \u043a\u0440\u0430\u0441\u043d\u0443\u044e \u0442\u043e\u0447\u043a\u0443 \u0431\u043b\u0438\u0436\u0435 \u043a \u043c\u0438\u043d\u0438\u043c\u0443\u043c\u0443 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u043f\u043e\u0442\u0435\u0440\u044c, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u0430 \u043d\u0430 \u0433\u0440\u0430\u0444\u0438\u043a\u0435 \u0441\u0438\u043d\u0435\u0439 \u0442\u043e\u0447\u043a\u043e\u0439. \u0428\u0430\u0433 \u0441\u0434\u0432\u0438\u0433\u0430 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u0435\u0442\u0441\u044f \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u043e\u043c <math><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/formulas\/bb9\/97f\/87c\/bb997f87cffdb02b3cf68579e8e7f520.svg\" alt=\"$\\eta$\" data-tex=\"inline\"><\/math>, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043e\u0431\u044b\u0447\u043d\u043e \u043d\u0430\u0437\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u043e\u043c \u043e\u0431\u0443\u0447\u0435\u043d\u0438\u044f.<\/p>\n<p>  <\/p>\n<h3 id=\"2-word2vec\">2. Word2Vec<\/h3>\n<p>  <\/p>\n<p>\u0417\u0430\u0434\u0430\u0447\u0430 \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u0430 word2vec, \u043d\u0430\u0439\u0442\u0438 \u044d\u043c\u0431\u0435\u0434\u0434\u0438\u043d\u0433\u0438 \u0441\u043b\u043e\u0432 \u0432 \u0437\u0430\u0434\u0430\u043d\u043d\u043e\u043c \u0442\u0435\u043a\u0441\u0442\u043e\u0432\u043e\u043c \u043a\u043e\u0440\u043f\u0443\u0441\u0435, \u0434\u0440\u0443\u0433\u0438\u043c\u0438 \u0441\u043b\u043e\u0432\u0430\u043c\u0438, \u044d\u0442\u043e \u043c\u0435\u0442\u043e\u0434\u0438\u043a\u0430 \u043f\u043e\u0438\u0441\u043a\u0430 \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u0438\u0439 \u0441\u043b\u043e\u0432 \u0432 \u043d\u0438\u0437\u043a\u043e\u0439 \u0440\u0430\u0437\u043c\u0435\u0440\u043d\u043e\u0441\u0442\u0438. \u041a\u0430\u043a \u0441\u043b\u0435\u0434\u0441\u0442\u0432\u0438\u0435, \u043a\u043e\u0433\u0434\u0430 \u043c\u044b \u0433\u043e\u0432\u043e\u0440\u0438\u043c \u043e word2vec, \u043c\u044b \u043e\u0431\u044b\u0447\u043d\u043e \u0433\u043e\u0432\u043e\u0440\u0438\u043c \u043e \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f\u0445 NLP.<\/p>\n<p>  <\/p>\n<p>\u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u043c\u043e\u0434\u0435\u043b\u044c word2vec \u043e\u0431\u0443\u0447\u0435\u043d\u043d\u0430\u044f \u0441\u043e \u0441\u043a\u0440\u044b\u0442\u044b\u043c \u0441\u043b\u043e\u0435\u043c \u0440\u0430\u0437\u043c\u0435\u0440\u043d\u043e\u0441\u0442\u0438 [N, 3], \u0433\u0434\u0435 N -\u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u0441\u043b\u043e\u0432 \u0432 \u0441\u043b\u043e\u0432\u0430\u0440\u0435, \u0434\u0430\u0441\u0442 \u0442\u0440\u0435\u0445\u043c\u0435\u0440\u043d\u044b\u0435 \u044d\u043c\u0431\u0435\u0434\u0434\u0438\u043d\u0433\u0438 \u0441\u043b\u043e\u0432. \u042d\u0442\u043e \u0437\u043d\u0430\u0447\u0438\u0442 \u0447\u0442\u043e, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0441\u043b\u043e\u0432\u043e &#8216;\u043a\u0432\u0430\u0440\u0442\u0438\u0440\u0430&#8217;, \u0431\u0443\u0434\u0435\u0442 \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u043e \u0442\u0440\u0435\u0445\u043c\u0435\u0440\u043d\u044b\u043c \u0432\u0435\u043a\u0442\u043e\u0440\u043e\u043c \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u0445 \u0447\u0438\u0441\u0435\u043b, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0431\u0443\u0434\u0435\u0442 \u0431\u043b\u0438\u0437\u043e\u043a (\u0432\u043e\u0441\u043f\u0440\u0438\u043d\u0438\u043c\u0430\u0439\u0442\u0435 \u044d\u0442\u043e \u043a\u0430\u043a <a href=\"https:\/\/ru.wikipedia.org\/wiki\/%D0%95%D0%B2%D0%BA%D0%BB%D0%B8%D0%B4%D0%BE%D0%B2%D0%B0_%D0%BC%D0%B5%D1%82%D1%80%D0%B8%D0%BA%D0%B0\" rel=\"nofollow\">\u0415\u0432\u043a\u043b\u0438\u0434\u043e\u0432\u0443 \u043c\u0435\u0442\u0440\u0438\u043a\u0443<\/a>), \u043a \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u0438\u044e \u0430\u043d\u0430\u043b\u043e\u0433\u0438\u0447\u043d\u043e\u0433\u043e \u0441\u043b\u043e\u0432\u0430, \u0442\u0430\u043a\u043e\u0433\u043e \u043a\u0430\u043a &#8216;\u0434\u043e\u043c&#8217;. \u0414\u0440\u0443\u0433\u0438\u043c\u0438 \u0441\u043b\u043e\u0432\u0430\u043c\u0438, word2vec \u044d\u0442\u043e \u0442\u0435\u0445\u043d\u0438\u043a\u0430 \u043e\u0442\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u044f \u0441\u043b\u043e\u0432 \u0432 \u0447\u0438\u0441\u043b\u0430.<\/p>\n<p>  <\/p>\n<p>\u0412 \u043a\u043e\u043d\u0442\u0435\u043a\u0441\u0442\u0435 word2vec \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044e\u0442\u0441\u044f \u0434\u0432\u0435 \u043e\u0441\u043d\u043e\u0432\u043d\u044b\u0435 \u043c\u043e\u0434\u0435\u043b\u0438: \u043c\u0435\u0448\u043e\u043a \u0441\u043b\u043e\u0432 (CBOW) \u0438 \u0441\u043a\u0438\u043f\u0433\u0440\u0430\u043c\u043c\u044b (skip-gram). \u0421\u043d\u0430\u0447\u0430\u043b\u0430 \u043c\u044b \u0440\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u043f\u0440\u043e\u0441\u0442\u0435\u0439\u0448\u0443\u044e \u043c\u043e\u0434\u0435\u043b\u044c, CBOW, \u0441 \u043e\u043a\u043d\u043e\u043c \u0438\u0437 \u043e\u0434\u043d\u043e\u0433\u043e \u0441\u043b\u043e\u0432\u0430, \u0437\u0430\u0442\u0435\u043c \u043f\u0435\u0440\u0435\u0439\u0434\u0435\u043c \u043a \u043e\u043a\u043d\u0443 \u0438\u0437 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u0438\u0445 \u0441\u043b\u043e\u0432 \u0438 \u043d\u0430\u043a\u043e\u043d\u0435\u0446 \u0440\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u043c\u043e\u0434\u0435\u043b\u044c skip-gram.<\/p>\n<p>  <\/p>\n<p>\u041f\u043e \u043c\u0435\u0440\u0435 \u043f\u0440\u043e\u0434\u0432\u0438\u0436\u0435\u043d\u0438\u044f \u044f \u043f\u043e\u043a\u0430\u0436\u0443 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u043d\u0435\u0431\u043e\u043b\u044c\u0448\u0438\u0445 \u043f\u0440\u0438\u043c\u0435\u0440\u043e\u0432 \u0441 \u0442\u0435\u043a\u0441\u0442\u043e\u043c \u0441\u043e\u0441\u0442\u043e\u044f\u0449\u0438\u043c \u0432\u0441\u0435\u0433\u043e \u0438\u0437 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u0438\u0445 \u0441\u043b\u043e\u0432. \u041e\u0434\u043d\u0430\u043a\u043e \u0438\u043c\u0435\u0439\u0442\u0435 \u0432 \u0432\u0438\u0434\u0443, \u0447\u0442\u043e \u043e\u0431\u044b\u0447\u043d\u043e woed2vec \u0442\u0440\u0435\u043d\u0438\u0440\u0443\u0435\u0442\u0441\u044f \u0441 \u043c\u0438\u043b\u043b\u0438\u0430\u0440\u0434\u0430\u043c\u0438 \u0441\u043b\u043e\u0432.<\/p>\n<p>  <\/p>\n<h3 id=\"3-prostaya-model-cbow\">3. \u041f\u0440\u043e\u0441\u0442\u0430\u044f \u043c\u043e\u0434\u0435\u043b\u044c CBOW<\/h3>\n<p>  <\/p>\n<p>\u0412 CBOW \u043c\u043e\u0434\u0435\u043b\u0438 \u0437\u0430\u0434\u0430\u0447\u0430 \u0441\u043e\u0441\u0442\u043e\u0438\u0442 \u0432 \u043f\u043e\u0438\u0441\u043a\u0435 \u0441\u043b\u043e\u0432\u0430 \u043f\u043e \u0435\u0433\u043e \u043a\u043e\u043d\u0442\u0435\u043a\u0441\u0442\u0443. \u0412 \u043f\u0440\u043e\u0441\u0442\u0435\u0439\u0448\u0435\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u043a\u043e\u0433\u0434\u0430 \u043a\u043e\u043d\u0442\u0435\u043a\u0441\u0442 \u0441\u043b\u043e\u0432\u0430 \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d \u043e\u0434\u043d\u0438\u043c \u0441\u043b\u043e\u0432\u043e\u043c, \u043d\u0435\u0439\u0440\u043e\u043d\u043d\u0430\u044f \u0441\u0435\u0442\u044c \u0431\u0443\u0434\u0435\u0442 \u0432\u044b\u0433\u043b\u044f\u0434\u0435\u0442\u044c \u0442\u0430\u043a:<br \/>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/webt\/cg\/za\/qw\/cgzaqw-lq0uflpmj3fkwi1n4xk8.png\"><br \/>  <em>\u0420\u0438\u0441\u0443\u043d\u043e\u043a 2. \u0422\u043e\u043f\u043e\u043b\u043e\u0433\u0438\u044f \u043c\u043e\u0434\u0435\u043b\u0438 Continuous Bag-of-Words \u043c\u043e\u0434\u0435\u043b\u0438 \u0441 \u043a\u043e\u043d\u0442\u0435\u043a\u0441\u0442\u043e\u043c \u0438\u0437 \u043e\u0434\u043d\u043e\u0433\u043e \u0441\u043b\u043e\u0432\u0430<\/em><\/p>\n<p>  <\/p>\n<p>\u041e\u0434\u0438\u043d \u0432\u0445\u043e\u0434\u043d\u043e\u0439 \u0441\u043b\u043e\u0439, \u043e\u0434\u0438\u043d \u0441\u043a\u0440\u044b\u0442\u044b\u0439 \u0441\u043b\u043e\u0439 \u0438 \u0432\u044b\u0445\u043e\u0434\u043d\u043e\u0439 \u0441\u043b\u043e\u0439, \u0444\u0443\u043d\u043a\u0446\u0438\u044f \u0430\u043a\u0442\u0438\u0432\u0430\u0446\u0438\u0438 \u0441\u043a\u0440\u044b\u0442\u043e\u0433\u043e \u0441\u043b\u043e\u044f<br \/>  a = 1 (identity function, \u0438\u043b\u0438 \u0444\u0443\u043d\u043a\u0446\u0438\u044f \u043b\u0438\u043d\u0435\u0439\u043d\u043e\u0439 \u0430\u043a\u0442\u0438\u0432\u0430\u0446\u0438\u0438, \u0445\u043e\u0442\u044f \u043f\u043e\u0441\u043b\u0435\u0434\u043d\u0435\u0435 \u043d\u0435\u043f\u0440\u0430\u0432\u0438\u043b\u044c\u043d\u043e).<br \/>  \u0412 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u0430\u043a\u0442\u0438\u0432\u0430\u0446\u0438\u0438 \u0432\u044b\u0445\u043e\u0434\u043d\u043e\u0433\u043e \u0441\u043b\u043e\u044f \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f Softmax.<\/p>\n<p>  <\/p>\n<p>\u0412\u0445\u043e\u0434\u043d\u043e\u0439 \u0441\u043b\u043e\u0439 \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d <a href=\"https:\/\/ru.wikipedia.org\/wiki\/%D0%A3%D0%BD%D0%B8%D1%82%D0%B0%D1%80%D0%BD%D1%8B%D0%B9_%D0%BA%D0%BE%D0%B4\" rel=\"nofollow\">one hot encoding<\/a> \u0432\u0435\u043a\u0442\u043e\u0440\u043e\u043c, \u0434\u043b\u0438\u043d\u0430 \u043a\u043e\u0442\u043e\u0440\u043e\u0433\u043e \u0441\u043e\u0432\u043f\u0430\u0434\u0430\u0435\u0442 \u0441 \u0440\u0430\u0437\u043c\u0435\u0440\u043e\u043c \u043c\u0430\u0441\u0441\u0438\u0432\u0430 \u0441\u043b\u043e\u0432, \u0432\u0441\u0435 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u044b \u0434\u0430\u043d\u043d\u043e\u0433\u043e \u0432\u0435\u043a\u0442\u043e\u0440\u0430 \u0440\u0430\u0432\u043d\u044b \u043d\u0443\u043b\u044e, \u043a\u0440\u043e\u043c\u0435 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u043e\u0432, \u0438\u043d\u0434\u0435\u043a\u0441\u044b \u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u0441\u043e\u0432\u043f\u0430\u0434\u0430\u044e\u0442 \u0441 \u0438\u043d\u0434\u0435\u043a\u0441\u0430\u043c\u0438 \u0441\u043b\u043e\u0432 \u0438\u0437 \u043a\u043e\u043d\u0442\u0435\u043a\u0441\u0442\u0430, \u043f\u043e \u0434\u0430\u043d\u043d\u044b\u043c \u0438\u043d\u0434\u0435\u043a\u0441\u0430\u043c \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u0432\u0435\u043a\u0442\u043e\u0440\u0430 \u0440\u0430\u0432\u043d\u044b 1.<\/p>\n<p>  <\/p>\n<p>\u041f\u0440\u0438\u043c\u0435\u0440: \u0441\u043b\u043e\u0432\u0430\u0440\u044c [&#8216;\u043c\u0430\u043c\u0430&#8217;, &#8216;\u043c\u044b\u043b\u0430&#8217;, &#8216;\u0440\u0430\u043c\u0443&#8217;, &#8216;\u043c\u0430\u0448\u0430&#8217;, &#8216;\u0435\u043b\u0430&#8217;, &#8216;\u043a\u0430\u0448\u0443&#8217;]<br \/>  OneHot(&#8216;\u043c\u0430\u0448\u0430&#8217;) = [0, 0, 0, 1, 0, 0]<br \/>  OneHot([&#8216;\u043c\u0430\u043c\u0430&#8217;, &#8216;\u043c\u0430\u0448\u0430&#8217;]) = [1, 0, 0, 1, 0, 0]<br \/>  OneHot([&#8216;\u043c\u0430\u043c\u0430&#8217;, &#8216;\u0435\u043b\u0430&#8217;, &#8216;\u043a\u0430\u0448\u0443&#8217;]) = [1, 0, 0, 0, 1, 1]<\/p>\n<p>  <\/p>\n<p>\u041f\u0435\u0440\u0435\u0439\u0434\u0435\u043c \u043a \u0432\u0435\u0441\u0430\u043c, \u0432\u0435\u0441\u043e\u0432\u044b\u0435 \u043a\u043e\u044d\u0444\u0444\u0438\u0446\u0438\u0435\u043d\u0442\u044b \u043c\u0435\u0436\u0434\u0443 \u0432\u0445\u043e\u0434\u043d\u044b\u043c \u0438 \u0441\u043a\u0440\u044b\u0442\u044b\u043c \u0441\u043b\u043e\u0435\u043c \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u044b \u043c\u0430\u0442\u0440\u0438\u0446\u0435\u0439 W \u0440\u0430\u0437\u043c\u0435\u0440\u0430 <math><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/formulas\/dae\/366\/c17\/dae366c17a7cf1d0bb54c87d659f8ea3.svg\" alt=\"$V\\times N$\" data-tex=\"inline\"><\/math>, \u043c\u0430\u0442\u0440\u0438\u0446\u0430 \u043c\u0435\u0436\u0434\u0443 \u0441\u043a\u0440\u044b\u0442\u044b\u043c \u0438 \u0432\u044b\u0445\u043e\u0434\u043d\u044b\u043c \u0441\u043b\u043e\u0435\u043c <math><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/formulas\/f69\/ee3\/c06\/f69ee3c06fab8202500c9559310ddf87.svg\" alt=\"$W\u2019$\" data-tex=\"inline\"><\/math> \u0440\u0430\u0437\u043c\u0435\u0440\u043e\u043c <math><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/formulas\/3d5\/78f\/44e\/3d578f44ef9a3acd79bf8ad47d8a8167.svg\" alt=\"$N\\times V$\" data-tex=\"inline\"><\/math>, \u0433\u0434\u0435 V \u2014 \u0440\u0430\u0437\u043c\u0435\u0440 \u0441\u043b\u043e\u0432\u0430\u0440\u044f, N \u2014 \u0440\u0430\u0437\u043c\u0435\u0440 \u044d\u043c\u0431\u0435\u0434\u0434\u0438\u043d\u0433 \u0432\u0435\u043a\u0442\u043e\u0440\u0430 (\u0442\u043e \u0435\u0441\u0442\u044c, \u0442\u0435 \u0432\u0435\u043a\u0442\u043e\u0440\u0430 \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0438 \u043f\u044b\u0442\u0430\u0435\u0442\u0441\u044f \u043d\u0430\u0439\u0442\u0438 word2vec)<\/p>\n<p>  <\/p>\n<p>\u0412\u044b\u0445\u043e\u0434\u043d\u043e\u0439 \u0432\u0435\u043a\u0442\u043e\u0440 y \u0441\u0440\u0430\u0432\u043d\u0438\u0432\u0430\u0435\u043c \u0441 \u043e\u0436\u0438\u0434\u0430\u0435\u043c\u044b\u043c \u0432\u0435\u043a\u0442\u043e\u0440\u043e\u043c t, \u0447\u0435\u043c \u043e\u043d\u0438 \u0431\u043b\u0438\u0436\u0435, \u0442\u0435\u043c \u0432\u044b\u0448\u0435 \u044d\u0444\u0444\u0435\u043a\u0442\u0438\u0432\u043d\u043e\u0441\u0442\u044c \u043d\u0435\u0439\u0440\u043e\u043d\u043d\u043e\u0439 \u0441\u0435\u0442\u0438, \u0438, \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0435\u043d\u043d\u043e, \u043c\u0435\u043d\u044c\u0448\u0435 \u0444\u0443\u043d\u043a\u0446\u0438\u044f \u043f\u043e\u0442\u0435\u0440\u044c.<\/p>\n<p>  <\/p>\n<p>\u0415\u0441\u043b\u0438 \u043d\u0430 \u0442\u0435\u043a\u0443\u0449\u0435\u043c \u044d\u0442\u0430\u043f\u0435 \u0447\u0442\u043e \u0442\u043e \u0437\u0432\u0443\u0447\u0438\u0442 \u043d\u0435\u043f\u043e\u043d\u044f\u0442\u043d\u043e, \u0442\u043e \u043f\u0440\u0438\u043c\u0435\u0440 \u043d\u0438\u0436\u0435 \u0434\u043e\u043b\u0436\u0435\u043d \u043f\u0440\u043e\u044f\u0441\u043d\u0438\u0442\u044c \u0441\u0438\u0442\u0443\u0430\u0446\u0438\u044e.<\/p>\n<p>  <\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">\u041f\u0440\u0438\u043c\u0435\u0440<\/b><\/p>\n<div class=\"spoiler_text\">\n<p>\u041f\u0440\u0435\u0434\u043f\u043e\u043b\u043e\u0436\u0438\u043c, \u043c\u044b \u0445\u043e\u0442\u0438\u043c \u043e\u0431\u0443\u0447\u0438\u0442\u044c word2vec \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u043c \u0442\u0435\u043a\u0441\u0442\u043e\u043c:<br \/>  <strong>&quot;I like playing football&quot;<\/strong><br \/>  \u041c\u044b \u0440\u0435\u0448\u0430\u0435\u043c \u043e\u0431\u0443\u0447\u0438\u0442\u044c \u043c\u043e\u0434\u0435\u043b\u044c CBOW \u0441 \u043e\u0434\u043d\u0438\u043c \u043a\u043e\u043d\u0442\u0435\u043a\u0441\u0442\u043d\u044b\u043c \u0441\u043b\u043e\u0432\u043e\u043c \u043a\u0430\u043a \u043d\u0430 \u0440\u0438\u0441\u0443\u043d\u043a\u0435 (2) \u0432\u044b\u0448\u0435.<br \/>  \u0423\u0447\u0438\u0442\u044b\u0432\u0430\u044f \u0442\u0435\u043a\u0441\u0442 \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0443 \u043d\u0430\u0441 \u0435\u0441\u0442\u044c, \u043d\u0430\u0448 \u0441\u043b\u043e\u0432\u0430\u0440\u044c \u0431\u0443\u0434\u0435\u0442 \u0441\u043e\u0441\u0442\u043e\u044f\u0442\u044c \u0438\u0437 4 \u0441\u043b\u043e\u0432, \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0435\u043d\u043d\u043e V=4, \u0442\u0430\u043a\u0436\u0435 \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u043c \u0447\u0442\u043e \u0441\u043a\u0440\u044b\u0442\u044b\u0439 \u0441\u043b\u043e\u0439 \u0431\u0443\u0434\u0435\u0442 \u0438\u043c\u0435\u0442\u044c \u0434\u0432\u0430 \u043d\u0435\u0439\u0440\u043e\u043d\u0430, \u0442\u043e \u0435\u0441\u0442\u044c N=2, \u043d\u0430\u0448\u0430 \u043d\u0435\u0439\u0440\u043e\u0441\u0435\u0442\u044c \u0431\u0443\u0434\u0435\u0442 \u0432\u044b\u0433\u043b\u044f\u0434\u0435\u0442\u044c \u0442\u0430\u043a:<\/p>\n<p>  <\/p>\n<p><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/webt\/qf\/ar\/qb\/qfarqbyuysmjcl2hydfrm2-odts.png\"><\/p>\n<p>  <\/p>\n<p>\u0421\u043e \u0441\u043b\u043e\u0432\u0430\u0440\u0451\u043c:<\/p>\n<p>  <\/p>\n<p><math><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/formulas\/f41\/b67\/718\/f41b67718ee43b9e0cec668116703326.svg\" alt=\"$\\textrm{Vocabulary}=[\\textrm{\u201cI\u201d}, \\textrm{\u201clike\u201d}, \\textrm{\u201cplaying\u201d}, \\textrm{\u201cfootball\u201d}]$\" data-tex=\"display\"><\/math><\/p>\n<p>  <\/p>\n<p>\u0414\u0430\u043b\u0435\u0435 \u043c\u044b \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u0435\u043c \u043a\u0430\u043a \u0432\u044b\u0431\u0438\u0440\u0430\u0442\u044c &#8216;\u0446\u0435\u043b\u0435\u0432\u043e\u0435&#8217; \u0438 &#8216;\u043a\u043e\u043d\u0442\u0435\u043a\u0441\u0442\u043d\u043e\u0435&#8217; \u0441\u043b\u043e\u0432\u043e, \u0438 \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u043f\u043e\u0441\u0442\u0440\u043e\u0438\u0442\u044c \u043d\u0430\u0448\u0438 \u043e\u0431\u0443\u0447\u0430\u044e\u0449\u0438\u0435 \u043f\u0440\u0438\u043c\u0435\u0440\u044b \u0434\u0432\u0438\u0433\u0430\u044f\u0441\u044c \u043e\u043a\u043d\u043e\u043c \u043f\u043e \u0442\u0435\u043a\u0441\u0442\u0443. \u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440:<\/p>\n<p>  <\/p>\n<p><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/webt\/kg\/ut\/cs\/kgutcsbzj7b41ay5mzfukwb6jki.png\"><\/p>\n<p>  <\/p>\n<p>\u0422\u043e\u0433\u0434\u0430 \u043e\u0431\u0443\u0447\u0430\u044e\u0449\u0438\u0435 \u043f\u0440\u0438\u043c\u0435\u0440\u044b \u0431\u0443\u0434\u0443\u0442 \u0432\u044b\u0433\u043b\u044f\u0434\u0435\u0442\u044c \u0442\u0430\u043a:<\/p>\n<p>  <\/p>\n<p><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/webt\/qd\/bg\/cr\/qdbgcrhudxqzgnbydeiotmkrrnw.png\"><\/p>\n<p>  <\/p>\n<p>\u0427\u0442\u043e\u0431\u044b \u043f\u0435\u0440\u0435\u0434\u0430\u0442\u044c \u044d\u0442\u0438 \u0434\u0430\u043d\u043d\u044b\u0435 \u0432 \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c \u043f\u043e\u043d\u0430\u0434\u043e\u0431\u0438\u0442\u0441\u044f \u043f\u0440\u0435\u043e\u0431\u0440\u0430\u0437\u043e\u0432\u0430\u0442\u044c \u0438\u0445 \u0432 \u0447\u0438\u0441\u043b\u0430, \u0434\u043b\u044f \u0447\u0435\u0433\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c one-hot encoding.<\/p>\n<p>  <\/p>\n<p><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/webt\/vx\/nd\/wk\/vxndwk_m7kav8udm9mrpvklsglq.png\"><\/p>\n<p>  <\/p>\n<p>\u041d\u0430 \u0434\u0430\u043d\u043d\u044b\u0439 \u043c\u043e\u043c\u0435\u043d\u0442, \u043c\u044b \u0445\u043e\u0442\u0438\u043c \u043e\u0431\u0443\u0447\u0438\u0442\u044c \u043d\u0430\u0448\u0443 \u043c\u043e\u0434\u0435\u043b\u044c, \u043d\u0430\u0445\u043e\u0434\u044f \u0432\u0435\u0441\u0430, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043c\u0438\u043d\u0438\u043c\u0438\u0437\u0438\u0440\u0443\u044e\u0442 \u0444\u0443\u043d\u043a\u0446\u0438\u044e \u043f\u043e\u0442\u0435\u0440\u044c. \u042d\u0442\u043e \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u0435\u0442 \u043d\u0430\u0445\u043e\u0436\u0434\u0435\u043d\u0438\u044e \u0432\u0435\u0441\u043e\u0432, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0441 \u0443\u0447\u0435\u0442\u043e\u043c \u0432\u0435\u043a\u0442\u043e\u0440\u0430 \u043a\u043e\u043d\u0442\u0435\u043a\u0441\u0442\u0430 \u043c\u043e\u0433\u0443\u0442 \u0441 \u0432\u044b\u0441\u043e\u043a\u043e\u0439 \u0442\u043e\u0447\u043d\u043e\u0441\u0442\u044c\u044e \u043f\u0440\u0435\u0434\u0441\u043a\u0430\u0437\u0430\u0442\u044c, \u0447\u0442\u043e \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u044e\u0449\u0438\u043c \u0446\u0435\u043b\u0435\u0432\u044b\u043c \u0441\u043b\u043e\u0432\u043e\u043c.<\/p>\n<\/div>\n<\/div>\n<p>  <\/p>\n<h3 id=\"31-funkciya-poter-loss-function\">3.1 \u0424\u0443\u043d\u043a\u0446\u0438\u044f \u043f\u043e\u0442\u0435\u0440\u044c (Loss function)<\/h3>\n<p>  <\/p>\n<p>\u0418\u0441\u0445\u043e\u0434\u044f \u0438\u0437 \u0442\u043e\u043f\u043e\u043b\u043e\u0433\u0438\u0438 \u043d\u0430 \u0440\u0438\u0441\u0443\u043d\u043a\u0435 1, \u0434\u0430\u0432\u0430\u0439\u0442\u0435 \u0437\u0430\u043f\u0438\u0448\u0435\u043c \u043a\u0430\u043a \u043f\u043e\u0441\u0447\u0438\u0442\u0430\u0442\u044c \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u0441\u043a\u0440\u044b\u0442\u043e\u0433\u043e \u0438 \u0432\u044b\u0445\u043e\u0434\u043d\u043e\u0433\u043e \u0441\u043b\u043e\u0435\u0432, \u043f\u0440\u0438 \u0432\u0445\u043e\u0434\u0435 x:<\/p>\n<p>  <\/p>\n<p><math><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/formulas\/bb4\/c9f\/b9e\/bb4c9fb9e2b2e33f1fc0512659b25501.svg\" alt=\"$\\begin{eqnarray*} \\textbf{h} = &amp; W^T\\textbf{x} \\hspace{7.0cm} \\\\ \\textbf{u}= &amp; W'^T\\textbf{h}=W'^TW^T\\textbf{x} \\hspace{4.6cm} \\\\ \\textbf{y}= &amp; \\ \\ \\mathbb{S}\\textrm{oftmax}(\\textbf{u})= \\mathbb{S}\\textrm{oftmax}(W'^TW^T\\textbf{x}) \\hspace{2cm} \\end{eqnarray*}$\" data-tex=\"display\"><\/math><\/p>\n<p>  <\/p>\n<p>\u0433\u0434\u0435, h \u2014 \u0441\u0443\u043c\u043c\u0430 \u043d\u0430 \u0441\u043a\u0440\u044b\u0442\u043e\u043c \u0441\u043b\u043e\u0435, u \u2014 \u0441\u0443\u043c\u043c\u0430 \u043d\u0430 \u0432\u044b\u0445\u043e\u0434\u043d\u043e\u043c \u0441\u043b\u043e\u0435, y \u2014 \u0432\u044b\u0445\u043e\u0434 \u0441\u0435\u0442\u0438.<\/p>\n<p>  <\/p>\n<p>\u0422\u0435\u043f\u0435\u0440\u044c, \u043f\u0440\u0435\u0434\u043f\u043e\u043b\u043e\u0436\u0438\u043c, \u043c\u044b \u043e\u0431\u0443\u0447\u0430\u0435\u043c \u043c\u043e\u0434\u0435\u043b\u044c \u043f\u043e \u043f\u0430\u0440\u0435 \u0446\u0435\u043b\u0435\u0432\u043e\u0435 \u0441\u043b\u043e\u0432\u043e, \u043a\u043e\u043d\u0442\u0435\u043a\u0441\u0442\u043d\u043e\u0435 \u0441\u043b\u043e\u0432\u043e (wt, wc). \u0426\u0435\u043b\u0435\u0432\u043e\u0435 \u0441\u043b\u043e\u0432\u043e \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442 \u0441\u043e\u0431\u043e\u0439 \u0438\u0434\u0435\u0430\u043b\u044c\u043d\u043e\u0435 \u043f\u0440\u0435\u0434\u0441\u043a\u0430\u0437\u0430\u043d\u0438\u0435 \u043d\u0435\u0439\u0440\u043e\u043d\u043d\u043e\u0439 \u0441\u0435\u0442\u0438, \u0432 \u0432\u0438\u0434\u0435 onehot encoding \u0432\u0435\u043a\u0442\u043e\u0440\u0430.<\/p>\n<p>  <\/p>\n<p>\u0424\u0443\u043d\u043a\u0446\u0438\u044f \u043f\u043e\u0442\u0435\u0440\u044c \u0434\u043e\u043b\u0436\u043d\u0430 \u0431\u0443\u0434\u0435\u0442 \u043e\u0446\u0435\u043d\u0438\u0442\u044c \u0432\u044b\u0445\u043e\u0434\u043d\u043e\u0439 \u0441\u043b\u043e\u0439, \u043e\u0442\u043d\u043e\u0441\u0438\u0442\u0435\u043b\u044c\u043d\u043e onehot \u0432\u0435\u043a\u0442\u043e\u0440\u0430 wt (\u0446\u0435\u043b\u0435\u0432\u043e\u0433\u043e \u0441\u043b\u043e\u0432\u0430).<\/p>\n<p>  <\/p>\n<p>\u041f\u043e\u0441\u043a\u043e\u043b\u044c\u043a\u0443 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f softmax \u043c\u043e\u0436\u043d\u043e \u0438\u043d\u0442\u0435\u0440\u043f\u0440\u0435\u0442\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u043a\u0430\u043a \u0443\u0441\u043b\u043e\u0432\u043d\u044b\u0435 \u0432\u0435\u0440\u043e\u044f\u0442\u043d\u043e\u0441\u0442\u0438 \u0446\u0435\u043b\u0435\u0432\u043e\u0433\u043e \u0441\u043b\u043e\u0432\u0430, \u0442\u043e \u0443\u0447\u0438\u0442\u044b\u0432\u0430\u044f \u043a\u043e\u043d\u0442\u0435\u043a\u0441\u0442\u043d\u043e\u0435 \u0441\u043b\u043e\u0432\u043e \u0444\u0443\u043d\u043a\u0446\u0438\u044e \u043f\u043e\u0442\u0435\u0440\u044c \u043c\u043e\u0436\u043d\u043e \u0437\u0430\u043f\u0438\u0441\u0430\u0442\u044c \u0432 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u043c \u0432\u0438\u0434\u0435:<\/p>\n<p>  <\/p>\n<p><math>$$display$$\\begin{equation*} \\mathcal{L} = -\\log \\mathbb{P}(w_t|w_c)=-\\log y_{j^*}\\ =-\\log[\\mathbb{S}\\textrm{oftmax}(u_{j^*})]=-\\log\\left(\\frac{\\exp{u_{j^*}}}{\\sum_i \\exp{u_i}}\\right), \\end{equation*}$$display$$<\/math><\/p>\n<p>  <\/p>\n<p>, \u0433\u0434\u0435 j* \u2014 \u043e\u0436\u0438\u0434\u0430\u0435\u043c\u0430\u044f \u043f\u043e\u0437\u0438\u0446\u0438\u044f \u043f\u0440\u0430\u0432\u0438\u043b\u044c\u043d\u043e \u043f\u0440\u0435\u0434\u0441\u043a\u0430\u0437\u0430\u043d\u043d\u043e\u0433\u043e \u0441\u043b\u043e\u0432\u0430.<br \/>  \u0414\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u0438\u0435 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u043b\u043e\u0433\u0430\u0440\u0438\u0444\u043c\u0430 \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u043d\u044b\u043c \u043f\u043e\u0434\u0445\u043e\u0434\u043e\u043c. \u0418\u0437 \u0434\u0430\u043d\u043d\u043e\u0433\u043e \u0432\u044b\u0440\u0430\u0436\u0435\u043d\u0438\u044f \u043c\u044b \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u043c \u0443\u0440\u0430\u0432\u043d\u0435\u043d\u0438\u0435 (1):<\/p>\n<p>  <\/p>\n<p><math>$$display$$\\begin{equation} \\bbox[lightblue,5px,border:2px solid red]{ \\mathcal{L} = -u_{j^*} + \\log \\sum_i \\exp{(u_i)}. } \\label{eq:loss} \\end{equation} \\&gt;(1)$$display$$<\/math><\/p>\n<p>  <\/p>\n<p>\u0424\u0443\u043d\u043a\u0446\u0438\u044f \u043f\u043e\u0442\u0435\u0440\u044c \u043c\u0430\u043a\u0441\u0438\u043c\u0438\u0437\u0438\u0440\u0443\u0435\u0442 \u0432\u0435\u0440\u043e\u044f\u0442\u043d\u043e\u0441\u0442\u044c \u043f\u0440\u0435\u0434\u0441\u043a\u0430\u0437\u0430\u043d\u0438\u044f \u043f\u0440\u0430\u0432\u0438\u043b\u044c\u043d\u043e\u0433\u043e \u0441\u043b\u043e\u0432\u0430 \u0438\u0441\u0445\u043e\u0434\u044f \u0438\u0437 \u0437\u0430\u0434\u0430\u043d\u043d\u043e\u0433\u043e \u043a\u043e\u043d\u0442\u0435\u043a\u0441\u0442\u0430.<\/p>\n<p>  <\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">\u041f\u0440\u0438\u043c\u0435\u0440<\/b><\/p>\n<div class=\"spoiler_text\">\n<p>\u0412\u0435\u0440\u043d\u0435\u043c\u0441\u044f \u043a \u043f\u0440\u0435\u0434\u044b\u0434\u0443\u0449\u0435\u043c\u0443 \u043f\u0440\u0438\u043c\u0435\u0440\u0443 \u043f\u0440\u0435\u0434\u043b\u043e\u0436\u0435\u043d\u0438\u044f &quot;I like play football&quot;, \u043f\u0440\u0435\u0434\u043f\u043e\u043b\u043e\u0436\u0438\u043c \u043c\u044b \u043e\u0431\u0443\u0447\u0430\u0435\u043c \u043c\u043e\u0434\u0435\u043b\u044c \u043f\u043e \u043f\u0435\u0440\u0432\u043e\u0439 \u0437\u0430\u043f\u0438\u0441\u0438 \u043e\u0431\u0443\u0447\u0430\u044e\u0449\u0438\u0445 \u0434\u0430\u043d\u043d\u044b\u0445, \u0441 \u043a\u043e\u043d\u0442\u0435\u043a\u0441\u0442\u043d\u044b\u043c \u0441\u043b\u043e\u0432\u043e\u043c &quot;I&quot; \u0438 \u0446\u0435\u043b\u0435\u0432\u044b\u043c \u0441\u043b\u043e\u0432\u043e\u043c &quot;like&quot;, \u0432 \u0438\u0434\u0435\u0430\u043b\u0435 \u0432\u0435\u0441\u0430 \u0441\u0435\u0442\u0438 \u0434\u043e\u043b\u0436\u043d\u044b \u0431\u044b\u0442\u044c \u0442\u0430\u043a\u0438\u043c\u0438, \u0447\u0442\u043e\u0431\u044b \u043f\u0440\u0438 \u0432\u0432\u043e\u0434\u0435 <math><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/formulas\/d3b\/e7e\/e90\/d3be7ee907763dc0bfa584f3e3944053.svg\" alt=\"$\\textbf{x}=(1, 0, 0, 0)$\" data-tex=\"inline\"><\/math> \u2014 \u0447\u0442\u043e \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u0435\u0442 \u0441\u043b\u043e\u0432\u0443 &quot;I&quot;, \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 \u0440\u0430\u0431\u043e\u0442\u044b \u0431\u044b\u043b \u0431\u043b\u0438\u0437\u043e\u043a \u043a <math><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/formulas\/7bb\/8a1\/0c4\/7bb8a10c4b2bb533add080cc9d060613.svg\" alt=\"$\\hat{\\textbf{y}}=(0, 1, 0, 0)$\" data-tex=\"inline\"><\/math>, \u0447\u0442\u043e \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u0435\u0442 \u0441\u043b\u043e\u0432\u0443 &quot;like&quot;.<\/p>\n<p>  <\/p>\n<p>\u0421\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u043d\u044b\u0439 \u043f\u043e\u0434\u0445\u043e\u0434 \u043a \u0438\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u0432\u0435\u0441\u043e\u0432 word2vec, \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435 \u043d\u043e\u0440\u043c\u0430\u043b\u044c\u043d\u043e\u0433\u043e \u0440\u0430\u0441\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u044f. \u041f\u0440\u0438\u043c\u0435\u043c \u043d\u0430\u0447\u0430\u043b\u044c\u043d\u043e\u0435 \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u0435 \u0432\u0435\u0441\u043e\u0432 \u043c\u0430\u0442\u0440\u0438\u0446\u044b W \u0440\u0430\u0437\u043c\u0435\u0440\u043e\u043c <math><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/formulas\/4b0\/6f4\/f17\/4b06f4f173f370ff153e0a79610d21af.svg\" alt=\"$4\\times 2$\" data-tex=\"inline\"><\/math><\/p>\n<p>  <\/p>\n<p><math><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/formulas\/687\/c10\/644\/687c10644e8ad30a55614ea7ed96d44a.svg\" alt=\"$W = \\begin{pmatrix} -1.38118728 &amp; 0.54849373 \\\\ 0.39389902 &amp; -1.1501331 \\\\ -1.16967628 &amp; 0.36078022 \\\\ 0.06676289 &amp; -0.14292845 \\end{pmatrix}$\" data-tex=\"display\"><\/math><\/p>\n<p>  <\/p>\n<p>\u0418 \u043d\u0430\u0447\u0430\u043b\u044c\u043d\u043e\u0435 \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u0435 \u0432\u0435\u0441\u043e\u0432 \u043c\u0430\u0442\u0440\u0438\u0446\u044b <math><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/formulas\/f69\/ee3\/c06\/f69ee3c06fab8202500c9559310ddf87.svg\" alt=\"$W\u2019$\" data-tex=\"inline\"><\/math> \u0440\u0430\u0437\u043c\u0435\u0440\u043e\u043c <math><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/formulas\/d75\/d55\/4ac\/d75d554acb50a21522c0ea93def796bd.svg\" alt=\"$2\\times 4$\" data-tex=\"inline\"><\/math><\/p>\n<p>  <\/p>\n<p><math><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/formulas\/42b\/12d\/080\/42b12d080fd4cf72b394503f9dbcf4ee.svg\" alt=\"$W' = \\begin{pmatrix} 1.39420129 &amp; -0.89441757 &amp; 0.99869667 &amp; 0.44447037 \\\\ 0.69671796 &amp; -0.23364341 &amp; 0.21975196 &amp; -0.0022673 \\end{pmatrix}$\" data-tex=\"display\"><\/math><\/p>\n<p>  <\/p>\n<p>\u0414\u043b\u044f \u043e\u0431\u0443\u0447\u0430\u044e\u0449\u0438\u0445 \u0434\u0430\u043d\u043d\u044b\u0445 &quot;I like&quot; \u043c\u044b \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u043c:<\/p>\n<p>  <\/p>\n<p><math><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/formulas\/25b\/6f2\/b4a\/25b6f2b4aa0182646944994098405748.svg\" alt=\"$\\textbf{h} = W^T\\textbf{x}= \\begin{pmatrix} -1.38118728 \\\\ 0.54849373 \\end{pmatrix}$\" data-tex=\"display\"><\/math><\/p>\n<p>  <\/p>\n<p>\u0417\u0430\u0442\u0435\u043c<\/p>\n<p>  <\/p>\n<p><math><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/formulas\/1b0\/680\/335\/1b068033519462e089bc1084ab11dac2.svg\" alt=\"$\\textbf{u} = W'^T\\textbf{h}= \\begin{pmatrix} -1.54350765 \\\\ 1.10720623 \\\\ -1.25885456 \\\\ -0.61514042 \\end{pmatrix}$\" data-tex=\"display\"><\/math><\/p>\n<p>  <\/p>\n<p>\u0418 \u043d\u0430\u043a\u043e\u043d\u0435\u0446<\/p>\n<p>  <\/p>\n<p><math><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/formulas\/dfa\/dde\/5bb\/dfadde5bbb9ce2394edf6bdde50f2fe8.svg\" alt=\"$\\textbf{y} = \\mathbb{S}\\textrm{oftmax}(\\textbf{u})= \\begin{pmatrix} 0.05256567 \\\\ 0.7445479 \\\\ 0.06987559 \\\\ 0.13301083 \\end{pmatrix}$\" data-tex=\"display\"><\/math><\/p>\n<p>  <\/p>\n<p>\u041d\u0430 \u044d\u0442\u043e\u043c \u044d\u0442\u0430\u043f\u0435 \u0444\u0443\u043d\u043a\u0446\u0438\u044f \u043f\u043e\u0442\u0435\u0440\u044c \u0431\u0443\u0434\u0435\u0442 \u043e\u0442\u0440\u0438\u0446\u0430\u0442\u0435\u043b\u044c\u043d\u044b\u043c \u043b\u043e\u0433\u0430\u0440\u0438\u0444\u043c\u043e\u043c \u0432\u0442\u043e\u0440\u043e\u0433\u043e \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u0430 <math><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/formulas\/71b\/61d\/5c2\/71b61d5c2aa9dcf6f9880aa2c5254252.svg\" alt=\"$\\textbf{y}$\" data-tex=\"inline\"><\/math>, \u0438\u043b\u0438<\/p>\n<p>  <\/p>\n<p><math><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/formulas\/b55\/88e\/75f\/b5588e75f25adf2ffa40a2bc288e7d2e.svg\" alt=\"$\\mathcal{L}=-\\log\\mathbb{P}(\\textrm{\u201clike\u201d}|\\textrm{\u201cI\u201d})=-\\log y_3 = -\\log(0.7445479)= 0.2949781.$\" data-tex=\"display\"><\/math><\/p>\n<p>  <\/p>\n<p>\u0422\u0430\u043a\u0436\u0435, \u043c\u044b \u043c\u043e\u0433\u043b\u0438 \u0431\u044b \u0440\u0430\u0441\u0441\u0447\u0438\u0442\u0430\u0442\u044c \u0435\u0435 \u043f\u0440\u0438 \u043f\u043e\u043c\u043e\u0449\u0438 \u0443\u0440\u0430\u0432\u043d\u0435\u043d\u0438\u044f (1):<\/p>\n<p>  <\/p>\n<p><math><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/formulas\/e15\/ace\/8b5\/e15ace8b5cb5c23b1466c9e168c9626a.svg\" alt=\"$\\begin{eqnarray*} \\mathcal{L}=-u_2+\\log\\sum_{i=1}^4 u_i=-1.10720623 + \\log[\\exp(-1.54350765)+\\exp(1.10720623) \\\\ +\\exp(-1.25885456)+\\exp(-0.61514042)]=0.2949781. \\end{eqnarray*}$\" data-tex=\"display\"><\/math><\/p>\n<p>  <\/p>\n<p>\u0422\u0435\u043f\u0435\u0440\u044c, \u043f\u0440\u0435\u0436\u0434\u0435 \u0447\u0435\u043c \u043f\u0435\u0440\u0435\u0439\u0442\u0438 \u043a \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u043c\u0443 \u043e\u0431\u0443\u0447\u0430\u044e\u0449\u0435\u043c\u0443 \u043f\u0440\u0438\u043c\u0435\u0440\u0443 &quot;like play&quot;, \u043c\u044b \u0434\u043e\u043b\u0436\u043d\u044b \u0438\u0437\u043c\u0435\u043d\u0438\u0442\u044c \u0432\u0435\u0441\u0430 \u043d\u0435\u0439\u0440\u043e\u0441\u0435\u0442\u0438, \u043a\u0430\u043a \u044d\u0442\u043e \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u0440\u0430\u0441\u0441\u043a\u0430\u0436\u0435\u0442 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0439 \u043f\u0443\u043d\u043a\u0442 \u043f\u0440\u043e \u043e\u0431\u0440\u0430\u0442\u043d\u043e\u0435 \u0440\u0430\u0441\u043f\u0440\u043e\u0441\u0442\u0440\u0430\u043d\u0435\u043d\u0438\u0435.<\/p>\n<\/div>\n<\/div>\n<p>  <\/p>\n<h3 id=\"32-algoritm-obratnogo-rasprostraneniya-dlya-modeli-cbow\">3.2 \u0410\u043b\u0433\u043e\u0440\u0438\u0442\u043c \u043e\u0431\u0440\u0430\u0442\u043d\u043e\u0433\u043e \u0440\u0430\u0441\u043f\u0440\u043e\u0441\u0442\u0440\u0430\u043d\u0435\u043d\u0438\u044f \u0434\u043b\u044f \u043c\u043e\u0434\u0435\u043b\u0438 CBOW<\/h3>\n<p>  <\/p>\n<p>\u0422\u0435\u043f\u0435\u0440\u044c, \u0438\u043c\u0435\u044f \u0432 \u043d\u0430\u043b\u0438\u0447\u0438\u0438 \u0444\u0443\u043d\u043a\u0446\u0438\u044e \u043f\u043e\u0442\u0435\u0440\u044c, \u043c\u044b \u0445\u043e\u0442\u0438\u043c \u043d\u0430\u0439\u0442\u0438 \u0432\u0435\u0441\u0430 W \u0438 W` \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0435\u0435 \u043c\u0438\u043d\u0438\u043c\u0438\u0437\u0438\u0440\u0443\u044e\u0442. \u0412 \u0442\u0435\u0440\u043c\u0438\u043d\u0430\u0445 \u043c\u0430\u0448\u0438\u043d\u043d\u043e\u0433\u043e \u043e\u0431\u0443\u0447\u0435\u043d\u0438\u044f, \u043c\u044b \u0445\u043e\u0442\u0438\u043c \u0447\u0442\u043e\u0431\u044b \u043c\u043e\u0434\u0435\u043b\u044c \u043e\u0431\u0443\u0447\u0438\u043b\u0430\u0441\u044c.<\/p>\n<p>  <\/p>\n<p>\u0412 \u043f\u0435\u0440\u0432\u043e\u043c \u0440\u0430\u0437\u0434\u0435\u043b\u0435 \u043c\u044b \u0443\u0436\u0435 \u043e\u0431\u0441\u0443\u0434\u0438\u043b\u0438 \u0447\u0442\u043e \u0432 \u043c\u0438\u0440\u0435 \u043d\u0435\u0439\u0440\u043e\u043d\u043d\u044b\u0439 \u0441\u0435\u0442\u0435\u0439 \u044d\u0442\u0430 \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u0430 \u0440\u0435\u0448\u0430\u0435\u0442\u0441\u044f \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435\u043c \u0433\u0440\u0430\u0434\u0438\u0435\u043d\u0442\u043d\u043e\u0433\u043e \u0441\u043f\u0443\u0441\u043a\u0430. \u041d\u0430 \u0440\u0438\u0441\u0443\u043d\u043a\u0435 (1) \u043f\u043e\u043a\u0430\u0437\u0430\u043d\u043e \u043a\u0430\u043a \u043f\u0440\u0438\u043c\u0435\u043d\u0438\u0442\u044c \u044d\u0442\u043e\u0442 \u043c\u0435\u0442\u043e\u0434 \u0438 \u043e\u0431\u043d\u043e\u0432\u0438\u0442\u044c \u043c\u0430\u0442\u0440\u0438\u0446\u044b \u0432\u0435\u0441\u043e\u0432 W \u0438 W`. \u041d\u0430\u043c \u043d\u0443\u0436\u043d\u043e \u043d\u0430\u0439\u0442\u0438 \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u043d\u044b\u0435 <math><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/formulas\/f29\/067\/151\/f2906715116a29f81156ddb4aecdd50d.svg\" alt=\"$\\partial \\mathcal{L}\/\\partial{W}$\" data-tex=\"inline\"><\/math> \u0438 <math><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/formulas\/adb\/4ac\/818\/adb4ac818067757d8d1ffee7f567fabd.svg\" alt=\"$\\partial \\mathcal{L}\/\\partial{W\u2019}$\" data-tex=\"inline\"><\/math><\/p>\n<p>  <\/p>\n<p>\u042f \u0441\u0447\u0438\u0442\u0430\u044e \u0447\u0442\u043e \u0441\u0430\u043c\u044b\u0439 \u043f\u0440\u043e\u0441\u0442\u043e\u0439 \u0441\u043f\u043e\u0441\u043e\u0431 \u043f\u043e\u043d\u044f\u0442\u044c \u043a\u0430\u043a \u044d\u0442\u043e \u0441\u0434\u0435\u043b\u0430\u0442\u044c, \u044d\u0442\u043e \u0437\u0430\u043f\u0438\u0441\u0430\u0442\u044c \u0441\u043e\u043e\u0442\u043d\u043e\u0448\u0435\u043d\u0438\u044f \u043c\u0435\u0436\u0434\u0443 \u0444\u0443\u043d\u043a\u0446\u0438\u0435\u0439 \u043f\u043e\u0442\u0435\u0440\u044c \u0438 \u043c\u0430\u0442\u0440\u0438\u0446\u0430\u043c\u0438 \u0432\u0435\u0441\u043e\u0432. \u0413\u043b\u044f\u0434\u044f \u043d\u0430 \u0443\u0440\u0430\u0432\u043d\u0435\u043d\u0438\u0435 (1) \u044f\u0441\u043d\u043e \u0447\u0442\u043e \u0444\u0443\u043d\u043a\u0446\u0438\u044f \u043f\u043e\u0442\u0435\u0440\u044c \u0437\u0430\u0432\u0438\u0441\u0438\u0442 \u043e\u0442 \u0432\u0435\u0441\u043e\u0432 W \u0438 W`, \u0447\u0435\u0440\u0435\u0437 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u0443\u044e u=[u1, &#8230;., uV], \u0438\u043b\u0438<\/p>\n<p>  <\/p>\n<p><math>$$display$$\\begin{equation*} \\mathcal{L} = \\mathcal{L}(\\mathbf{u}(W,W&#8217;))=\\mathcal{L}(u_1(W,W&#8217;), u_2(W,W&#8217;),\\dots, u_V(W,W&#8217;))\\ . \\end{equation*}$$display$$<\/math><\/p>\n<p>  <\/p>\n<p>\u041f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u043d\u044b\u0435 \u043c\u043e\u0436\u043d\u043e \u0438\u0437 \u043f\u0440\u0430\u0432\u0438\u043b\u0430 \u0446\u0435\u043f\u043e\u0447\u043a\u0438 \u0434\u043b\u044f \u0444\u0443\u043d\u043a\u0446\u0438\u0439 \u043c\u043d\u043e\u0433\u0438\u0445 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0445:<\/p>\n<p>  <\/p>\n<p><math>$$display$$\\begin{equation} \\frac{\\partial\\mathcal{L}}{\\partial W&#8217;_{ij}} = \\sum_{k=1}^V\\frac{\\partial\\mathcal{L}}{\\partial u_k}\\frac{\\partial u_k}{\\partial W&#8217;_{ij}} \\label{eq:dLdWp} \\end{equation} \\&gt;(2)$$display$$<\/math><\/p>\n<p>  <\/p>\n<p>\u0438<\/p>\n<p>  <\/p>\n<p><math>$$display$$\\begin{equation} \\frac{\\partial\\mathcal{L}}{\\partial W_{ij}} = \\sum_{k=1}^V\\frac{\\partial\\mathcal{L}}{\\partial u_k}\\frac{\\partial u_k}{\\partial W_{ij}}\\ . \\label{eq:dLdW} \\end{equation} \\&gt;(3)$$display$$<\/math><\/p>\n<p>  <\/p>\n<p>\u0418 \u044d\u0442\u043e \u0431\u043e\u043b\u044c\u0448\u0430\u044f \u0447\u0430\u0441\u0442\u044c \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u0430 \u043e\u0431\u0440\u0430\u0442\u043d\u043e\u0433\u043e \u0440\u0430\u0441\u043f\u0440\u043e\u0441\u0442\u0440\u0430\u043d\u0435\u043d\u0438\u044f, \u043d\u0430 \u0434\u0430\u043d\u043d\u044b\u0439 \u043c\u043e\u043c\u0435\u043d\u0442 \u043d\u0430\u043c \u043f\u0440\u043e\u0441\u0442\u043e \u043d\u0443\u0436\u043d\u043e \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0438\u0442\u044c \u0443\u0440\u0430\u0432\u043d\u0435\u043d\u0438\u044f (2) \u0438 (3) \u0434\u043b\u044f \u043d\u0430\u0448\u0435\u0433\u043e \u0441\u043b\u0443\u0447\u0430\u044f.<\/p>\n<p>  <\/p>\n<p>\u041d\u0430\u0447\u043d\u0435\u043c \u0441 \u0443\u0440\u0430\u0432\u043d\u0435\u043d\u0438\u044f (2), \u043e\u0431\u0440\u0430\u0442\u0438\u0442\u0435 \u0432\u043d\u0438\u043c\u0430\u043d\u0438\u0435 \u0447\u0442\u043e \u0432\u0435\u0441 W<code>ij, \u043e\u0442\u043d\u043e\u0441\u0438\u0442\u0441\u044f \u043a \u043c\u0430\u0442\u0440\u0438\u0446\u0435 W<\/code>, \u0438 \u0441\u043e\u0435\u0434\u0438\u043d\u044f\u0435\u0442 \u043d\u0435\u0439\u0440\u043e\u043d i \u0432 \u0441\u043a\u0440\u044b\u0442\u043e\u043c \u0441\u043b\u043e\u0435 \u0441 \u043d\u0435\u0439\u0440\u043e\u043d\u043e\u043c j \u0432 \u0432\u044b\u0445\u043e\u0434\u043d\u043e\u043c \u0441\u043b\u043e\u0435, \u0438 \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0435\u043d\u043d\u043e \u043e\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u0442 \u0432\u043b\u0438\u044f\u043d\u0438\u0435 \u0442\u043e\u043b\u044c\u043a\u043e \u043d\u0430 \u0432\u044b\u0445\u043e\u0434 uj (\u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0435\u043d\u043d\u043e \u0438 \u043d\u0430 yj).<\/p>\n<p>  <\/p>\n<p><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/webt\/dr\/dh\/ix\/drdhixsbllzjxbktub0djqv4c-k.png\"><br \/>  <em>\u0420\u0438\u0441\u0443\u043d\u043e\u043a 3. (a) \u0412\u044b\u0445\u043e\u0434\u043d\u043e\u0439 \u0443\u0437\u0435\u043b <math><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/formulas\/5ac\/81e\/f64\/5ac81ef6445035d5740cd6fe382d3cfb.svg\" alt=\"$y_j$\" data-tex=\"inline\"><\/math> \u0437\u0430\u0432\u0438\u0441\u0438\u0442 \u043e\u0442 \u043e\u0431\u0449\u0435\u0433\u043e \u0443\u0437\u043b\u0430 <math><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/formulas\/f19\/ffb\/556\/f19ffb55694eae33eb7b3c52c972e49a.svg\" alt=\"$h_i$\" data-tex=\"inline\"><\/math> \u0441\u043a\u0440\u044b\u0442\u043e\u0433\u043e \u0441\u043b\u043e\u044f \u0442\u043e\u043b\u044c\u043a\u043e \u0447\u0435\u0440\u0435\u0437 \u044d\u043b\u0435\u043c\u0435\u043d\u0442 <math><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/formulas\/71a\/5d1\/4e0\/71a5d14e0bdadc22261b7cfe5b347321.svg\" alt=\"$W'_{ij}$\" data-tex=\"inline\"><\/math> \u043c\u0430\u0442\u0440\u0438\u0446\u044b <math><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/formulas\/f69\/ee3\/c06\/f69ee3c06fab8202500c9559310ddf87.svg\" alt=\"$W'$\" data-tex=\"inline\"><\/math>. (b) \u041d\u043e \u043a\u0440\u043e\u043c\u0435 \u0442\u043e\u0433\u043e, \u044d\u0442\u043e\u0442 \u0436\u0435 \u0432\u044b\u0445\u043e\u0434\u043d\u043e\u0439 \u0443\u0437\u0435\u043b \u0437\u0430\u0432\u0438\u0441\u0438\u0442 \u043e\u0442 \u043e\u0431\u0449\u0435\u0433\u043e \u0432\u0445\u043e\u0434\u043d\u043e\u0433\u043e \u0443\u0437\u043b\u0430 <math><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/formulas\/83c\/204\/4b8\/83c2044b820fe8885df38c03ba9d636c.svg\" alt=\"$x_k$\" data-tex=\"inline\"><\/math> \u0447\u0435\u0440\u0435\u0437 N \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u043e\u0432 <math><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/formulas\/666\/061\/021\/666061021ef5eb8b1000bc21af2bc636.svg\" alt=\"$W_{k1}\\dots W_{kN}$\" data-tex=\"inline\"><\/math> \u043c\u0430\u0442\u0440\u0438\u0446\u044b W.<\/em><\/p>\n<p>  <\/p>\n<p>\u0421\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u043e, \u0441\u0440\u0435\u0434\u0438 \u0432\u0441\u0435\u0445 \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u043d\u044b\u0445 <math><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/formulas\/1af\/cf8\/bfc\/1afcf8bfc047532d38b6fd560d7e2fe3.svg\" alt=\"$\\partial u_k\/\\partial W'_{ij}$\" data-tex=\"inline\"><\/math>, \u0442\u043e\u043b\u044c\u043a\u043e \u043e\u0434\u043d\u0430, \u0433\u0434\u0435 k=j, \u0431\u0443\u0434\u0435\u0442 \u043e\u0442\u043b\u0438\u0447\u0430\u0442\u044c\u0441\u044f \u043e\u0442 0. <\/p>\n<p>  <\/p>\n<p>\u0423\u0440\u0430\u0432\u043d\u0435\u043d\u0438\u0435 (4):<\/p>\n<p>  <\/p>\n<p><math>$$display$$\\begin{equation} \\frac{\\partial\\mathcal{L}}{\\partial W&#8217;_{ij}} = \\frac{\\partial\\mathcal{L}}{\\partial u_j}\\frac{\\partial u_j} {\\partial W&#8217;_{ij}} \\label{eq:derivative#1} \\end{equation} \\&gt;(4)$$display$$<\/math><\/p>\n<p>  <\/p>\n<p>\u0414\u0430\u0432\u0430\u0439\u0442\u0435 \u043f\u043e\u0441\u0447\u0438\u0442\u0430\u0435\u043c <math><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/formulas\/cb7\/af7\/d8e\/cb7af7d8e5d3a9f01a6c239f208fc5c2.svg\" alt=\"$\\partial \\mathcal{L}\/\\partial u_j$\" data-tex=\"inline\"><\/math>, \u0443\u0440\u0430\u0432\u043d\u0435\u043d\u0438\u0435 (5):<\/p>\n<p>  <\/p>\n<p><math>$$display$$\\begin{equation} \\frac{\\partial\\mathcal{L}}{\\partial u_j} = -\\delta_{jj^*} + y_j := e_j \\label{eq:term#1} \\end{equation} \\&gt;(5)$$display$$<\/math><\/p>\n<p>  <\/p>\n<p>, \u0433\u0434\u0435 <math><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/formulas\/f51\/561\/088\/f5156108837eb5bb7c74a67d650ee90a.svg\" alt=\"$\\delta_{jj^*}$\" data-tex=\"inline\"><\/math> \u2014 <a href=\"https:\/\/ru.wikipedia.org\/wiki\/%D0%A1%D0%B8%D0%BC%D0%B2%D0%BE%D0%BB_%D0%9A%D1%80%D0%BE%D0%BD%D0%B5%D0%BA%D0%B5%D1%80%D0%B0\" rel=\"nofollow\">\u0434\u0435\u043b\u044c\u0442\u0430 \u041a\u0440\u043e\u043d\u0435\u043a\u0435\u0440\u0430<\/a>, \u0444\u0443\u043d\u043a\u0446\u0438\u044f \u0434\u0432\u0443\u0445 \u0446\u0435\u043b\u044b\u0445 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0445, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u0440\u0430\u0432\u043d\u0430 1, \u0435\u0441\u043b\u0438 \u043e\u043d\u0438 \u0440\u0430\u0432\u043d\u044b, \u0438 0 \u0432 \u043f\u0440\u043e\u0442\u0438\u0432\u043d\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435.<\/p>\n<p>  <\/p>\n<p>\u0412 \u0443\u0440\u0430\u0432\u043d\u0435\u043d\u0438\u0438 (5) \u043c\u044b \u0432\u0432\u0435\u043b\u0438 \u0432\u0435\u043a\u0442\u043e\u0440 e \u0440\u0430\u0437\u043c\u0435\u0440\u043d\u043e\u0441\u0442\u0438 N (\u0440\u0430\u0437\u043c\u0435\u0440 \u0441\u043b\u043e\u0432\u0430\u0440\u044f), \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043c\u044b \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c \u0447\u0442\u043e\u0431\u044b \u0441\u043d\u0438\u0437\u0438\u0442\u044c \u0441\u043b\u043e\u0436\u043d\u043e\u0441\u0442\u044c \u043e\u0431\u043e\u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0439, \u044d\u0442\u043e\u0442 \u0432\u0435\u043a\u0442\u043e\u0440 \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442 \u0441\u043e\u0431\u043e\u0439 \u0440\u0430\u0437\u043d\u0438\u0446\u0443 \u043c\u0435\u0436\u0434\u0443 \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u043d\u044b\u043c \u0438 \u043e\u0436\u0438\u0434\u0430\u0435\u043c\u044b\u043c \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u043e\u043c, \u0442\u043e \u0435\u0441\u0442\u044c \u044d\u0442\u043e \u0432\u0435\u043a\u0442\u043e\u0440 \u043e\u0448\u0438\u0431\u043e\u043a \u043f\u0440\u0435\u0434\u0441\u043a\u0430\u0437\u0430\u043d\u0438\u044f.<\/p>\n<p>  <\/p>\n<p>\u0414\u043b\u044f \u0432\u0442\u043e\u0440\u043e\u0433\u043e \u0447\u043b\u0435\u043d\u0430 \u043f\u0440\u0430\u0432\u043e\u0439 \u0447\u0430\u0441\u0442\u0438 \u0443\u0440\u0430\u0432\u043d\u0435\u043d\u0438\u044f (4) \u043c\u044b \u043f\u043e\u043b\u0443\u0447\u0438\u043c \u0443\u0440\u0430\u0432\u043d\u0435\u043d\u0438\u044f (6):<\/p>\n<p>  <\/p>\n<p><math>$$display$$\\begin{equation} \\frac{\\partial u_j}{\\partial W&#8217;_{ij}} = \\sum_{k=1}^V W_{ik}x_k \\label{eq:term#2} \\end{equation} \\&gt;(6)$$display$$<\/math><\/p>\n<p>  <\/p>\n<p>\u041f\u043e\u0441\u043b\u0435 \u043f\u043e\u0434\u0441\u0442\u0430\u0432\u043d\u043e\u0432\u043a\u0438 \u0443\u0440\u0430\u0432\u043d\u0435\u043d\u0438\u0439 (5) \u0438 (6) \u0432 \u0443\u0440\u0430\u0432\u043d\u0435\u043d\u0438\u0435 (4) \u043c\u044b \u043f\u043e\u043b\u0443\u0447\u0438\u043c \u0443\u0440\u0430\u0432\u043d\u0435\u043d\u0438\u0435 (7):<\/p>\n<p>  <\/p>\n<p><math>$$display$$\\begin{equation} \\bbox[white,5px,border:2px dotted red]{ \\frac{\\partial\\mathcal{L}}{\\partial W&#8217;_{ij}} = (-\\delta_{jj^*} + y_j) \\left(\\sum_{k=1}^V W_{ki}x_k\\right) } \\label{eq:backprop1} \\end{equation} \\&gt;(7)$$display$$<\/math><\/p>\n<p>  <\/p>\n<p>\u041c\u044b \u043c\u043e\u0436\u0435\u043c \u043d\u0430\u0439\u0442\u0438 \u0432\u044b\u043f\u043e\u043b\u043d\u0438\u0442\u044c \u0430\u043d\u0430\u043b\u043e\u0433\u0438\u0447\u043d\u043e\u0435 \u0443\u043f\u0440\u0430\u0436\u043d\u0435\u043d\u0438\u0435 \u0434\u043b\u044f \u043f\u043e\u0438\u0441\u043a\u0430 \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u043d\u043e\u0439 <math><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/formulas\/e1b\/48b\/847\/e1b48b847c7d80748291a63448079f94.svg\" alt=\"$\\partial\\mathcal{L}\/\\partial W_{ij}$\" data-tex=\"inline\"><\/math>, \u043e\u0434\u043d\u0430\u043a\u043e \u043d\u0430 \u044d\u0442\u043e\u0442 \u0440\u0430\u0437 \u043e\u0442\u043c\u0435\u0442\u0438\u043c \u0447\u0442\u043e \u043f\u043e\u0441\u043b\u0435 \u0437\u0430\u0434\u0430\u043d\u0438\u044f \u0432\u0445\u043e\u0434\u0430 Xk, \u0432\u044b\u0445\u043e\u0434 yj \u043d\u0435\u0439\u0440\u043e\u043d\u0430 j \u0437\u0430\u0432\u0438\u0441\u0438\u0442 \u043e\u0442 \u0432\u0441\u0435\u0445 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u043e\u0432 \u043c\u0430\u0442\u0440\u0438\u0446\u044b W \u0441\u043e\u0435\u0434\u0438\u043d\u0435\u043d\u043d\u044b\u0445 \u0441\u043e \u0432\u0445\u043e\u0434\u043e\u043c, \u043a\u0430\u043a \u0432\u0438\u0434\u043d\u043e \u043d\u0430 \u0440\u0438\u0441\u0443\u043d\u043a\u0435 3(b). \u041f\u043e\u044d\u0442\u043e\u043c\u0443 \u043c\u044b \u0434\u043e\u043b\u0436\u043d\u044b \u043e\u0446\u0435\u043d\u0438\u0432\u0430\u0442\u044c \u0432\u0441\u0435 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u044b \u0432 \u0441\u0443\u043c\u043c\u0435. \u041f\u0440\u0435\u0436\u0434\u0435 \u0447\u0435\u043c \u043f\u0435\u0440\u0435\u0439\u0442\u0438 \u043a \u043e\u0446\u0435\u043d\u043a\u0435 <math><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/formulas\/9fc\/a4d\/63d\/9fca4d63dd60caaaf5e43cf15df1622e.svg\" alt=\"$\\partial u_k\/\\partial W_{ij}$\" data-tex=\"inline\"><\/math>, \u043f\u043e\u043b\u0435\u0437\u043d\u043e \u043f\u0435\u0440\u0435\u0437\u0430\u043f\u0438\u0441\u0430\u0442\u044c \u0432\u044b\u0440\u0430\u0436\u0435\u043d\u0438\u0435 \u0434\u043b\u044f \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u0430 uk \u0438\u0437 \u0432\u0435\u043a\u0442\u043e\u0440\u0430 u \u043a\u0430\u043a:<\/p>\n<p>  <\/p>\n<p><math>$$display$$\\begin{equation*} u_k = \\sum_{m=1}^N\\sum_{l=1}^VW&#8217;_{mk}W_{lm}x_l\\ . \\end{equation*}$$display$$<\/math><\/p>\n<p>  <\/p>\n<p>\u0418\u0437 \u044d\u0442\u043e\u0433\u043e \u0443\u0440\u0430\u0432\u043d\u0435\u043d\u0438\u044f \u043b\u0435\u0433\u043a\u043e \u0432\u044b\u0432\u0435\u0441\u0442\u0438 <math><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/formulas\/9fc\/a4d\/63d\/9fca4d63dd60caaaf5e43cf15df1622e.svg\" alt=\"$\\partial u_k\/\\partial W_{ij}$\" data-tex=\"inline\"><\/math>, \u043f\u043e\u0441\u043a\u043e\u043b\u044c\u043a\u0443 \u0435\u0434\u0438\u043d\u0441\u0442\u0432\u0435\u043d\u043d\u044b\u0439 \u0432\u044b\u0436\u0438\u0432\u0448\u0438\u0439 \u0447\u043b\u0435\u043d \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u043d\u043e\u0439 \u0431\u0443\u0434\u0435\u0442 \u0441 \u0438\u043d\u0434\u0435\u043a\u0441\u0430\u043c\u0438 l=i \u0438 m=j, \u0438\u043b\u0438 \u0436\u0435 \u0432 \u0432\u0438\u0434\u0435 \u0443\u0440\u0430\u0432\u043d\u0435\u043d\u0438\u044f (8):<\/p>\n<p>  <\/p>\n<p><math>$$display$$\\begin{equation} \\frac{\\partial u_k}{\\partial W_{ij}} = W&#8217;_{jk}x_i\\ . \\label{eq:term#3} \\end{equation} \\&gt;(8)$$display$$<\/math><\/p>\n<p>  <\/p>\n<p>\u041d\u0430\u043a\u043e\u043d\u0435\u0446 \u043f\u0440\u0438\u043c\u0435\u043d\u0438\u0432 \u0443\u0440\u0430\u0432\u043d\u0435\u043d\u0438\u044f (5) \u0438 (8) \u043c\u044b \u043f\u043e\u043b\u0443\u0447\u0438\u043c \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442, \u0443\u0440\u0430\u0432\u043d\u0435\u043d\u0438\u0435 (9):<\/p>\n<p>  <\/p>\n<p><math>$$display$$\\begin{equation} \\bbox[white,5px,border:2px dotted red]{ \\frac{\\partial \\mathcal{L}}{\\partial W_{ij}} = \\sum_{k=1}^V (-\\delta_{kk^*}+y_k)W&#8217;_{jk}x_i } \\label{eq:backprop2} \\end{equation} \\&gt;(9)$$display$$<\/math><\/p>\n<p>  <\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">\u0412\u0435\u043a\u0442\u043e\u0440\u0438\u0437\u0430\u0446\u0438\u044f<\/b><\/p>\n<div class=\"spoiler_text\">\n<p>\u041c\u044b \u043c\u043e\u0436\u0435\u043c \u0443\u043f\u0440\u043e\u0441\u0442\u0438\u0442\u044c \u0437\u0430\u043f\u0438\u0441\u044c \u0443\u0440\u0430\u0432\u043d\u0435\u043d\u0438\u0439. (7) \u0438 (9) \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044f \u0432\u0435\u043a\u0442\u043e\u0440\u043d\u0443\u044e \u043d\u043e\u0442\u0430\u0446\u0438\u044e. \u0421\u0434\u0435\u043b\u0430\u0432 \u044d\u0442\u043e \u043c\u044b \u043f\u043e\u043b\u0443\u0447\u0438\u043c \u0434\u043b\u044f \u0443\u0440\u0430\u0432\u043d\u0435\u043d\u0438\u044f (7)<\/p>\n<p>  <\/p>\n<p><math>$$display$$\\begin{equation} \\bbox[white,5px,border:2px dotted red]{ \\frac{\\partial\\mathcal{L}}{\\partial W&#8217;} = (W^T\\textbf{x}) \\otimes \\textbf{e} } \\end{equation} \\&gt;(10)$$display$$<\/math><\/p>\n<p>  <\/p>\n<p>\u0413\u0434\u0435 \u0441\u0438\u043c\u0432\u043e\u043b \u2297 \u043e\u0431\u043e\u0437\u043d\u0430\u0447\u0430\u0435\u0442 \u0432\u0435\u043a\u0442\u043e\u0440\u043d\u043e\u0435 \u043f\u0440\u043e\u0438\u0437\u0432\u0435\u0434\u0435\u043d\u0438\u0435.<\/p>\n<p>  <\/p>\n<p>\u0414\u043b\u044f \u0443\u0440\u0430\u0432\u043d\u0435\u043d\u0438\u044f (9) \u043c\u044b \u043f\u043e\u043b\u0443\u0447\u0438\u043c:<\/p>\n<p>  <\/p>\n<p><math>$$display$$\\begin{equation} \\bbox[white,5px,border:2px dotted red]{ \\frac{\\partial \\mathcal{L}}{\\partial W} = \\textbf{x}\\otimes(W&#8217;\\textbf{e}) } \\end{equation} \\&gt;(11)$$display$$<\/math><\/p>\n<\/div>\n<\/div>\n<p>  <\/p>\n<h3 id=\"33-gradientnyy-spusk-na-osnove-poluchennyh-vyshe-rezultatov\">3.3 \u0413\u0440\u0430\u0434\u0438\u0435\u043d\u0442\u043d\u044b\u0439 \u0441\u043f\u0443\u0441\u043a \u043d\u0430 \u043e\u0441\u043d\u043e\u0432\u0435 \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u043d\u044b\u0445 \u0432\u044b\u0448\u0435 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u043e\u0432<\/h3>\n<p>  <\/p>\n<p>\u0422\u0435\u043f\u0435\u0440\u044c, \u043a\u043e\u0433\u0434\u0430 \u0443 \u043d\u0430\u0441 \u0435\u0441\u0442\u044c \u0443\u0440\u0430\u0432\u043d\u0435\u043d\u0438\u044f (7) \u0438 (9), \u0443 \u043d\u0430\u0441 \u0435\u0441\u0442\u044c \u0432\u0441\u0435 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e\u0435 \u0434\u043b\u044f \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u043e\u0434\u043d\u043e\u0439 \u0438\u0442\u0435\u0440\u0430\u0446\u0438\u0438 \u043e\u0431\u0443\u0447\u0435\u043d\u0438\u044f \u043d\u0435\u0439\u0440\u043e\u0441\u0435\u0442\u0438 \u043d\u0430 \u0431\u0430\u0437\u0435 \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u0430 \u043e\u0431\u0440\u0430\u0442\u043d\u043e\u0433\u043e \u0440\u0430\u0441\u043f\u0440\u043e\u0441\u0442\u0440\u0430\u043d\u0435\u043d\u0438\u044f \u043e\u0448\u0438\u0431\u043a\u0438, \u043f\u0440\u0438\u043c\u0435\u043d\u044f\u044f \u0433\u0440\u0430\u0434\u0438\u0435\u043d\u0442\u043d\u044b\u0439 \u0441\u043f\u0443\u0441\u043a. \u041a\u0430\u0436\u0434\u0430\u044f \u0438\u0442\u0435\u0440\u0430\u0446\u0438\u044f \u0434\u043e\u043b\u0436\u043d\u0430 \u043d\u0435\u043c\u043d\u043e\u0433\u043e \u043f\u0440\u0438\u0431\u043b\u0438\u0436\u0430\u0442\u044c \u043a \u043c\u0438\u043d\u0438\u043c\u0443\u043c\u0443 \u0444\u0443\u043d\u043a\u0446\u0438\u044e \u043f\u043e\u0442\u0435\u0440\u044c. \u041f\u043e\u0441\u043b\u0435 \u0437\u0430\u0434\u0430\u043d\u0438\u044f \u0441\u043a\u043e\u0440\u043e\u0441\u0442\u0438 \u043e\u0431\u0443\u0447\u0435\u043d\u0438\u044f <math><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/formulas\/b2f\/97b\/200\/b2f97b2001cd7c8f44963400dece06ef.svg\" alt=\"$\\eta&gt;0$\" data-tex=\"inline\"><\/math>, \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u043e\u0431\u043d\u043e\u0432\u0438\u0442\u044c \u043d\u0430\u0448\u0438 \u0432\u0435\u0441\u0430 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c:<\/p>\n<p>  <\/p>\n<p><math><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/formulas\/92c\/38a\/9b6\/92c38a9b6e9cd79ca41f5ebfa08dabd7.svg\" alt=\"$\\begin{eqnarray} W_{\\textrm{new}} &amp; = W_{\\textrm{old}} - \\eta \\frac{\\partial \\mathcal{L}}{\\partial W} \\nonumber \\\\ W'_{\\textrm{new}} &amp; = W'_{\\textrm{old}} - \\eta \\frac{\\partial \\mathcal{L}}{\\partial W'} \\nonumber \\\\ \\end{eqnarray}$\" data-tex=\"display\"><\/math><\/p>\n<p>  <\/p>\n<h3 id=\"34-iteraciya-algoritma\">3.4 \u0418\u0442\u0435\u0440\u0430\u0446\u0438\u044f \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u0430<\/h3>\n<p>  <\/p>\n<p>\u0412\u0441\u0435 \u043e\u043f\u0438\u0441\u0430\u043d\u043d\u043e\u0435 \u0432\u044b\u0448\u0435 \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0432\u0441\u0435\u0433\u043e \u043b\u0438\u0448\u044c \u043e\u0434\u043d\u0438\u043c \u043c\u0430\u043b\u0435\u043d\u044c\u043a\u0438\u043c \u0448\u0430\u0433\u043e\u0432 \u0432\u0441\u0435\u0433\u043e \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u0430 \u043e\u043f\u0442\u0438\u043c\u0438\u0437\u0430\u0446\u0438\u0438. \u0412 \u0447\u0430\u0441\u0442\u043d\u043e\u0441\u0442\u0438, \u0434\u043e \u044d\u0442\u043e\u0433\u043e \u043c\u043e\u043c\u0435\u043d\u0442\u0430 \u043c\u044b \u043e\u0431\u0443\u0447\u0430\u043b\u0438 \u043d\u0430\u0448\u0443 \u043d\u0435\u0439\u0440\u043e\u0441\u0435\u0442\u044c \u0432\u0441\u0435\u0433\u043e \u043d\u0430 \u043e\u0434\u043d\u043e\u043c \u0442\u0440\u0435\u043d\u0438\u0440\u043e\u0432\u043e\u0447\u043d\u043e\u043c \u043f\u0440\u0438\u043c\u0435\u0440\u0435. \u0427\u0442\u043e\u0431\u044b \u0437\u0430\u0432\u0435\u0440\u0448\u0438\u0442\u044c \u043f\u0435\u0440\u0432\u044b\u0439 \u043f\u0440\u043e\u0445\u043e\u0434, \u043c\u044b \u0434\u043e\u043b\u0436\u043d\u044b \u043f\u0440\u0438\u043c\u0435\u043d\u0438\u0442\u044c \u0432\u0441\u0435 \u043e\u0431\u0443\u0447\u0430\u044e\u0449\u0438\u0435 \u043f\u0440\u0438\u043c\u0435\u0440\u044b. \u0421\u0434\u0435\u043b\u0430\u0432 \u044d\u0442\u043e, \u043c\u044b \u043f\u0440\u043e\u0439\u0434\u0435\u043c \u043e\u0434\u043d\u0443 \u044d\u043f\u043e\u0445\u0443 \u043e\u0431\u0443\u0447\u0435\u043d\u0438\u044f. \u041f\u043e\u0441\u043b\u0435 \u0447\u0435\u0433\u043e \u043d\u0430\u043c \u043d\u0443\u0436\u043d\u043e \u0431\u0443\u0434\u0435\u0442 \u043f\u043e\u0432\u0442\u043e\u0440\u044f\u0442\u044c \u0446\u0438\u043a\u043b \u043e\u0431\u0443\u0447\u0435\u043d\u0438\u044f, \u043f\u0440\u043e\u0439\u0434\u044f \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e\u0435 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u044d\u043f\u043e\u0445, \u043f\u043e\u043a\u0430 \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u044f \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u043f\u043e\u0442\u0435\u0440\u044c \u043d\u0435 \u0441\u0442\u0430\u043d\u0443\u0442 \u043d\u0435\u0437\u043d\u0430\u0447\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u043c\u0438, \u043f\u043e\u0441\u043b\u0435 \u0447\u0435\u0433\u043e \u043c\u043e\u0436\u043d\u043e \u0431\u0443\u0434\u0435\u0442 \u043e\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u044c\u0441\u044f \u0438 \u0441\u0447\u0438\u0442\u0430\u0442\u044c \u043d\u0435\u0439\u0440\u043e\u0441\u0435\u0442\u044c \u043e\u0431\u0443\u0447\u0435\u043d\u043d\u043e\u0439.<\/p>\n<p>  <\/p>\n<h3 id=\"4-algoritm-obratnogo-rasprostraneniya-dlya-konteksta-iz-neskolkih-slov-v-modeli-cbow\">4. \u0410\u043b\u0433\u043e\u0440\u0438\u0442\u043c \u043e\u0431\u0440\u0430\u0442\u043d\u043e\u0433\u043e \u0440\u0430\u0441\u043f\u0440\u043e\u0441\u0442\u0440\u0430\u043d\u0435\u043d\u0438\u044f \u0434\u043b\u044f \u043a\u043e\u043d\u0442\u0435\u043a\u0441\u0442\u0430 \u0438\u0437 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u0438\u0445 \u0441\u043b\u043e\u0432 \u0432 \u043c\u043e\u0434\u0435\u043b\u0438 CBOW<\/h3>\n<p>  <\/p>\n<p>\u041c\u044b \u0443\u0436\u0435 \u0437\u043d\u0430\u0435\u043c \u043a\u0430\u043a \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c \u043e\u0431\u0440\u0430\u0442\u043d\u043e\u0433\u043e \u0440\u0430\u0441\u043f\u0440\u043e\u0441\u0442\u0440\u0430\u043d\u0435\u043d\u0438\u044f \u0434\u043b\u044f \u043c\u043e\u0434\u0435\u043b\u0438 CBOW \u0441 \u043e\u0434\u043d\u0438\u043c \u0441\u043b\u043e\u0432\u043e\u043c \u043d\u0430 \u0432\u0445\u043e\u0434\u0435. \u0422\u0435\u043f\u0435\u0440\u044c \u0443\u0432\u0435\u043b\u0438\u0447\u0438\u043c \u0441\u043b\u043e\u0436\u043d\u043e\u0441\u0442\u044c \u0438 \u0434\u043e\u0431\u0430\u0432\u0438\u043c \u0432 \u043a\u043e\u043d\u0442\u0435\u043a\u0441\u0442 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0441\u043b\u043e\u0432. \u0420\u0438\u0441\u0443\u043d\u043e\u043a (4) \u043f\u043e\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u0442 \u043a\u0430\u043a \u0432\u044b\u0433\u043b\u044f\u0434\u0438\u0442 \u043d\u0435\u0439\u0440\u043e\u0441\u0435\u0442\u044c \u0442\u0435\u043f\u0435\u0440\u044c. \u0412\u0445\u043e\u0434 \u0442\u0435\u043f\u0435\u0440\u044c \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442 \u0441\u043e\u0431\u043e\u0439 \u0441\u0435\u0440\u0438\u044e OneHot Encoded \u0432\u0435\u043a\u0442\u043e\u0440\u043e\u0432 \u0441\u043b\u043e\u0432 \u0432\u0445\u043e\u0434\u044f\u0449\u0438\u0445 \u0432 \u043a\u043e\u043d\u0442\u0435\u043a\u0441\u0442. \u041a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u0441\u043b\u043e\u0432 \u0432 \u043a\u043e\u043d\u0442\u0435\u043a\u0441\u0442\u0435 \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u043e\u043c \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u0437\u0430\u0434\u0430\u0432\u0430\u0442\u044c \u043f\u0440\u0438 \u0438\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 word2vec. \u0421\u043a\u0440\u044b\u0442\u044b\u0439 \u0441\u043b\u043e\u0439 \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u0442 \u0443\u0441\u0440\u0435\u0434\u043d\u0435\u043d\u0438\u0435 \u0438\u0437 \u0432\u0441\u0435\u0445 \u043a\u043e\u043d\u0442\u0435\u043a\u0441\u0442\u043d\u044b\u0445 \u0441\u043b\u043e\u0432.<\/p>\n<p>  <\/p>\n<p><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/webt\/jl\/di\/fb\/jldifb0bv9u7vdzvq0py-4zwk5q.png\"><br \/>  <em>\u0420\u0438\u0441\u0443\u043d\u043e\u043a 4. \u0422\u043e\u043f\u043e\u043b\u043e\u0433\u0438\u044f \u043c\u043e\u0434\u0435\u043b\u0438 CBOW \u0441 \u043a\u043e\u043d\u0442\u0435\u043a\u0441\u0442\u043e\u043c \u0438\u0437 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u0438\u0445 \u0441\u043b\u043e\u0432<\/em><\/p>\n<p>  <\/p>\n<p>\u0423\u0440\u0430\u0432\u043d\u0435\u043d\u0438\u044f \u043c\u043e\u0434\u0435\u043b\u0438 CBOW \u0441 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u0438\u043c\u0438 \u043a\u043e\u043d\u0442\u0435\u043a\u0441\u0442\u043d\u044b\u043c\u0438 \u0441\u043b\u043e\u0432\u0430\u043c\u0438 \u044f\u0432\u043b\u044f\u044e\u0442\u0441\u044f \u043e\u0431\u043e\u0431\u0449\u0435\u043d\u0438\u0435\u043c \u0443\u0440\u0430\u0432\u043d\u0435\u043d\u0438\u0439 \u043c\u043e\u0434\u0435\u043b\u0438 CBOW \u0441 \u043e\u0434\u043d\u0438\u043c \u043a\u043e\u043d\u0442\u0435\u043a\u0441\u0442\u043d\u044b\u043c \u0441\u043b\u043e\u0432\u043e\u043c.<\/p>\n<p>  <\/p>\n<p><math><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/formulas\/f67\/f34\/bf1\/f67f34bf1b049ffeaf7eb34743c26c04.svg\" alt=\"$\\begin{eqnarray} \\textbf{h} = &amp; \\frac{1}{C} W^T \\sum_{c=1}^C\\textbf{x}^{(c)} = W^T\\overline{\\textbf{x}}\\hspace{5.8cm} \\nonumber \\\\ \\textbf{u}= &amp; W'^T\\textbf{h}= \\frac{1}{C}\\sum_{c=1}^CW'^T W^T\\textbf{x}^{(c)}=W'^T W^T\\overline{\\textbf{x}} \\hspace{2.8cm} \\nonumber \\\\ \\textbf{y}= &amp; \\ \\ \\mathbb{S}\\textrm{oftmax}(\\textbf{u})= \\mathbb{S}\\textrm{oftmax}\\left( W'^T W^T\\overline{\\textbf{x}}\\right) \\hspace{3.6cm} \\nonumber \\end{eqnarray}$\" data-tex=\"display\"><\/math><\/p>\n<p>  <\/p>\n<p>\u041e\u0431\u0440\u0430\u0442\u0438\u0442\u0435 \u0432\u043d\u0438\u043c\u0430\u043d\u0438\u0435, \u0447\u0442\u043e \u0434\u043b\u044f \u0443\u0434\u043e\u0431\u0441\u0442\u0432\u0430 \u043c\u044b \u0432\u0432\u0435\u043b\u0438 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u0435 &#8216;\u0443\u0441\u0440\u0435\u0434\u043d\u0435\u043d\u043d\u044b\u0439&#8217; \u0432\u0445\u043e\u0434\u043d\u043e\u0439 \u0432\u0435\u043a\u0442\u043e\u0440 <math><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/formulas\/90c\/ab5\/c9a\/90cab5c9a37068a45e899393c011d36f.svg\" alt=\"$\\overline{\\textbf{x}}=\\sum_{c=1}^C\\textbf{x}^{(c)}\/C$\" data-tex=\"inline\"><\/math><\/p>\n<p>  <\/p>\n<p>\u041a\u0430\u043a \u0438 \u043f\u0440\u0435\u0436\u0434\u0435, \u0447\u0442\u043e\u0431\u044b \u043f\u0440\u0438\u043c\u0435\u043d\u0438\u0442\u044c \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c \u043e\u0431\u0440\u0430\u0442\u043d\u043e\u0433\u043e \u0440\u0430\u0441\u043f\u0440\u043e\u0441\u0442\u0440\u0430\u043d\u0435\u043d\u0438\u044f \u043d\u0430\u043c \u043d\u0443\u0436\u043d\u043e \u0432\u044b\u043f\u0438\u0441\u0430\u0442\u044c \u0444\u0443\u043d\u043a\u0446\u0438\u044e \u043f\u043e\u0442\u0435\u0440\u044c \u0438 \u0432\u044b\u043f\u0438\u0441\u0430\u0442\u044c \u0435\u0435 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438. \u0424\u0443\u043d\u043a\u0446\u0438\u044f \u043f\u043e\u0442\u0435\u0440\u044c \u0432\u044b\u0433\u043b\u044f\u0434\u0438\u0442 \u0442\u0430\u043a\u0436\u0435 \u043a\u0430\u043a \u0438 \u0440\u0430\u043d\u044c\u0448\u0435: <\/p>\n<p>  <\/p>\n<p><math>$$display$$\\begin{equation} \\mathcal{L} = -\\log\\mathbb{P}(w_o|w_{c,1},w_{c,2},\\dots,w_{c,C})=-u_{j^*} + \\log \\sum_i \\exp{(u_i)}. \\end{equation} \\&gt;(12)$$display$$<\/math><\/p>\n<p>  <\/p>\n<p>\u0421\u043d\u043e\u0432\u0430 \u0432\u044b\u043f\u0438\u0448\u0435\u043c \u0443\u0440\u0430\u0432\u043d\u0435\u043d\u0438\u044f \u043f\u043e \u043f\u0440\u0430\u0432\u0438\u043b\u0443 \u0446\u0435\u043f\u043e\u0447\u043a\u0438, \u0430\u043d\u0430\u043b\u043e\u0433\u0438\u0447\u043d\u043e \u043f\u0440\u0435\u0434\u044b\u0434\u0443\u0449\u0438\u043c:<\/p>\n<p>  <\/p>\n<p><math>$$display$$\\begin{equation} \\frac{\\partial\\mathcal{L}}{\\partial W&#8217;_{ij}} = \\sum_{k=1}^V\\frac{\\partial\\mathcal{L}}{\\partial u_k}\\frac{\\partial u_k}{\\partial W&#8217;_{ij}} \\end{equation} \\&gt;(13)$$display$$<\/math><\/p>\n<p>  <\/p>\n<p>\u0438<\/p>\n<p>  <\/p>\n<p><math>$$display$$\\begin{equation} \\frac{\\partial\\mathcal{L}}{\\partial W_{ij}} = \\sum_{k=1}^V\\frac{\\partial\\mathcal{L}}{\\partial u_k}\\frac{\\partial u_k}{\\partial W_{ij}}\\ . \\end{equation} \\&gt;(14)$$display$$<\/math><\/p>\n<p>  <\/p>\n<p>\u041f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u043d\u044b\u0435 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u043f\u043e\u0442\u0435\u0440\u044c \u043f\u043e \u0432\u0435\u0441\u0430\u043c \u0442\u0430\u043a\u0438\u0435 \u0436\u0435 \u043a\u0430\u043a \u0434\u043b\u044f \u043c\u043e\u0434\u0435\u043b\u0438 CBOW \u0441 \u043e\u0434\u043d\u0438\u043c \u0441\u043b\u043e\u0432\u043e\u043c \u043d\u0430 \u0432\u0445\u043e\u0434\u0435, \u0441 \u0435\u0434\u0438\u043d\u0441\u0442\u0432\u0435\u043d\u043d\u044b\u043c \u043e\u0442\u043b\u0438\u0447\u0438\u0435\u043c, \u0447\u0442\u043e \u043c\u044b \u0437\u0430\u043c\u0435\u043d\u0438\u043c \u0432\u0445\u043e\u0434\u043d\u043e\u0439 \u0432\u0435\u043a\u0442\u043e\u0440 \u0438\u0437 \u043e\u0434\u043d\u043e\u0433\u043e \u0441\u043b\u043e\u0432\u0430 \u043d\u0430 \u0443\u0441\u0440\u0435\u0434\u043d\u0435\u043d\u043d\u044b\u0439 \u0432\u0435\u043a\u0442\u043e\u0440 \u0438\u0437 \u0441\u043b\u043e\u0432 \u043a\u043e\u043d\u0442\u0435\u043a\u0441\u0442\u0430. \u0412\u044b\u0432\u0435\u0434\u0435\u043c \u044d\u0442\u0438 \u0443\u0440\u0430\u0432\u043d\u0435\u043d\u0438\u044f \u043d\u0430\u0447\u0438\u043d\u0430\u044f \u0441 \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u043d\u043e\u0439 \u043f\u043e <math><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/formulas\/71a\/5d1\/4e0\/71a5d14e0bdadc22261b7cfe5b347321.svg\" alt=\"$W\u2019_{ij}$\" data-tex=\"inline\"><\/math><\/p>\n<p>  <\/p>\n<p><math>$inline$\\begin{equation} \\frac{\\partial\\mathcal{L}}{\\partial W&#8217;_{ij}} = \\sum_{k=1}^V\\frac{\\partial\\mathcal{L}}{\\partial u_k}\\frac{\\partial u_k}{\\partial W&#8217;_{ij}} = \\frac{\\partial\\mathcal{L}}{\\partial u_j}\\frac{\\partial u_j}{\\partial W&#8217;_{ij}} = (-\\delta_{jj^*} + y_j) \\left(\\sum_{k=1}^V W_{ki}\\overline{x}_k\\right) \\end{equation} \\&gt; (15)$inline$<\/math><\/p>\n<p>  <\/p>\n<p>\u0422\u0435\u043f\u0435\u0440\u044c \u0437\u0430\u043f\u0438\u0448\u0435\u043c \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u043d\u0443\u044e \u043f\u043e <math><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/formulas\/c45\/ecb\/c5d\/c45ecbc5d3762c210932eab819d72fb4.svg\" alt=\"$W_{ij}$\" data-tex=\"inline\"><\/math>:<\/p>\n<p>  <\/p>\n<p><math>$$display$$\\begin{equation} \\frac{\\partial\\mathcal{L}}{\\partial W_{ij}} = \\sum_{k=1}^V\\frac{\\partial\\mathcal{L}}{\\partial u_k}\\frac{\\partial}{\\partial W_{ij}}\\left(\\frac{1}{C}\\sum_{m=1}^N\\sum_{l=1}^V W&#8217;_{mk}\\sum_{c=1}^C W_{lm}x_l^{(c)}\\right)=\\frac{1}{C}\\sum_{k=1}^V\\sum_{c=1}^C(-\\delta_{kk^*} + y_k)W&#8217;_{jk}x_i^{(c)} . \\end{equation} \\&gt;(16)$$display$$<\/math><\/p>\n<p>  <\/p>\n<p>\u041f\u043e\u0434\u0432\u0435\u0434\u044f \u0438\u0442\u043e\u0433 \u0438\u043c\u0435\u0435\u043c \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u0435:<\/p>\n<p>  <\/p>\n<p><math>$$display$$\\begin{equation} \\bbox[white,5px,border:2px dotted red]{ \\frac{\\partial\\mathcal{L}}{\\partial W&#8217;_{ij}} = (-\\delta_{jj^*} + y_j) \\left(\\sum_{k=1}^V W_{ki}\\overline{x}_k\\right) } \\label{eq:backprop1_multi} \\end{equation} \\&gt;(17)$$display$$<\/math><\/p>\n<p>  <\/p>\n<p>\u0438<\/p>\n<p>  <\/p>\n<p><math>$$display$$\\begin{equation} \\bbox[white,5px,border:2px dotted red]{ \\frac{\\partial\\mathcal{L}}{\\partial W_{ij}} = \\sum_{k=1}^V(-\\delta_{kk^*} + y_k)W&#8217;_{jk}\\overline{x}_i . } \\label{eq:backprop2_multi} \\end{equation} \\&gt; (18)$$display$$<\/math><\/p>\n<p>  <\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">\u0412\u0435\u043a\u0442\u043e\u0440\u0438\u0437\u0430\u0446\u0438\u044f<\/b><\/p>\n<div class=\"spoiler_text\">\n<p>\u041f\u0435\u0440\u0435\u043f\u0438\u0448\u0435\u043c \u0443\u0440\u0430\u0432\u043d\u0435\u043d\u0438\u044f (17) \u0438 (18) \u0432 \u0437\u0430\u043f\u0438\u0441\u0438 \u0434\u043b\u044f \u0432\u0435\u043a\u0442\u043e\u0440\u043e\u0432.<br \/>  \u0423\u0440\u0430\u0432\u043d\u0435\u043d\u0438\u0435 (17) \u043f\u0440\u0438\u043c\u0435\u0442 \u0432\u0438\u0434:<\/p>\n<p>  <\/p>\n<p><math>$$display$$\\begin{equation} \\bbox[white,5px,border:2px dotted red]{ \\frac{\\partial\\mathcal{L}}{\\partial W&#8217;} = (W^T\\overline{\\textbf{x}}) \\otimes \\textbf{e} } \\end{equation} \\&gt;(19)$$display$$<\/math><\/p>\n<p>  <\/p>\n<p>\u0414\u043b\u044f \u0443\u0440\u0430\u0432\u043d\u0435\u043d\u0438\u044f (18):<\/p>\n<p>  <\/p>\n<p><math>$$display$$\\begin{equation} \\bbox[white,5px,border:2px dotted red]{ \\frac{\\partial \\mathcal{L}}{\\partial W} =\\overline{\\textbf{x}}\\otimes(W&#8217;\\textbf{e}) } \\end{equation} \\&gt;(20)$$display$$<\/math><\/p>\n<p>  <\/p>\n<p>\u0415\u0449\u0435 \u0440\u0430\u0437, \u043e\u0431\u0440\u0430\u0442\u0438\u0442\u0435 \u0432\u043d\u0438\u043c\u0430\u043d\u0438\u0435 \u0447\u0442\u043e \u0443\u0440\u0430\u0432\u043d\u0435\u043d\u0438\u044f \u0438\u0434\u0435\u043d\u0442\u0438\u0447\u043d\u044b \u0443\u0440\u0430\u0432\u043d\u0435\u043d\u0438\u044f\u043c \u0432 \u043c\u043e\u0434\u0435\u043b\u0438 CBOW \u0434\u043b\u044f \u043a\u043e\u043d\u0442\u0435\u043a\u0441\u0442\u0430 \u0438\u0437 \u043e\u0434\u043d\u043e\u0433\u043e \u0441\u043b\u043e\u0432\u0430.<br \/>  \u041e\u043f\u0435\u0440\u0430\u0442\u043e\u0440 \u2297 \u043e\u0431\u043e\u0437\u043d\u0430\u0447\u0430\u0435\u0442 \u0432\u0435\u043a\u0442\u043e\u0440\u043d\u043e\u0435 \u043f\u0440\u043e\u0438\u0437\u0432\u0435\u0434\u0435\u043d\u0438\u0435.<\/p>\n<\/div>\n<\/div>\n<p>  <\/p>\n<h3 id=\"5-algoritm-obratnogo-rasprostraneniya-dlya-modeli-skip-gram\">5. \u0410\u043b\u0433\u043e\u0440\u0438\u0442\u043c \u043e\u0431\u0440\u0430\u0442\u043d\u043e\u0433\u043e \u0440\u0430\u0441\u043f\u0440\u043e\u0441\u0442\u0440\u0430\u043d\u0435\u043d\u0438\u044f \u0434\u043b\u044f \u043c\u043e\u0434\u0435\u043b\u0438 Skip-gram<\/h3>\n<p>  <\/p>\n<p>\u0414\u0430\u043d\u043d\u0430\u044f \u043c\u043e\u0434\u0435\u043b\u044c \u043f\u043e \u0441\u0443\u0442\u0438 \u043e\u0431\u0440\u0430\u0442\u043d\u0430 \u043c\u043e\u0434\u0435\u043b\u0438 CBOW, \u043d\u0430 \u0432\u0445\u043e\u0434 \u043f\u043e\u0434\u0430\u0435\u0442\u0441\u044f \u0446\u0435\u043d\u0442\u0440\u0430\u043b\u044c\u043d\u043e\u0435 \u0441\u043b\u043e\u0432\u043e, \u043d\u0430 \u0432\u044b\u0445\u043e\u0434\u0435 \u043f\u0440\u0435\u0434\u0441\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u0435\u0433\u043e \u043a\u043e\u043d\u0442\u0435\u043a\u0441\u0442. \u041f\u043e\u043b\u0443\u0447\u0435\u043d\u043d\u0430\u044f \u043d\u0435\u0439\u0440\u043e\u0441\u0435\u0442\u044c \u0432\u044b\u0433\u043b\u044f\u0434\u0438\u0442 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c:<\/p>\n<p>  <\/p>\n<p><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/webt\/dr\/lr\/je\/drlrjeb_tg_sjdvyc3ii6pq7vqi.png\"><br \/>  <em>\u0420\u0438\u0441\u0443\u043d\u043e\u043a 5.\u0422\u043e\u043f\u043e\u043b\u043e\u0433\u0438\u044f Skip-gram \u043c\u043e\u0434\u0435\u043b\u0438.<\/em><\/p>\n<p>  <\/p>\n<p>\u0423\u0440\u0430\u0432\u043d\u0435\u043d\u0438\u044f skip-gram \u043c\u043e\u0434\u0435\u043b\u0438 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0435:<\/p>\n<p>  <\/p>\n<p><math><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/formulas\/f7d\/851\/3ac\/f7d8513ac5ef4ec604b27fad0cfeef15.svg\" alt=\"$\\begin{eqnarray*} \\textbf{h} = &amp; W^T\\textbf{x} \\hspace{9.4cm} \\\\ \\textbf{u}_c= &amp; W'^T\\textbf{h}=W'^TW^T\\textbf{x} \\hspace{4cm} c=1, \\dots, C \\hspace{0.7cm}\\\\ \\textbf{y}_c = &amp; \\ \\ \\mathbb{S}\\textrm{oftmax}(\\textbf{u})= \\mathbb{S}\\textrm{oftmax}(W'^TW^T\\textbf{x}) \\hspace{2cm} c=1, \\dots, C \\end{eqnarray*}$\" data-tex=\"display\"><\/math><\/p>\n<p>  <\/p>\n<p>\u041e\u0431\u0440\u0430\u0442\u0438\u0442\u0435 \u0432\u043d\u0438\u043c\u0430\u043d\u0438\u0435 \u0447\u0442\u043e \u0432\u044b\u0445\u043e\u0434\u043d\u044b\u0435 \u0432\u0435\u043a\u0442\u043e\u0440\u0430 (\u043a\u0430\u043a \u0438 \u0432\u0435\u043a\u0442\u043e\u0440 <math><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/formulas\/564\/dad\/e71\/564dade711e605f6ab3a9b26b82a9602.svg\" alt=\"$\\textbf{u}_c$\" data-tex=\"inline\"><\/math>) \u0438\u0434\u0435\u043d\u0442\u0438\u0447\u043d\u044b, <math><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/formulas\/26c\/83d\/f33\/26c83df331c441169918851b89de862d.svg\" alt=\"$\\mathbf{y}_1=\\mathbf{y}_2\\dots= \\mathbf{y}_C$\" data-tex=\"inline\"><\/math>. \u0424\u0443\u043d\u043a\u0446\u0438\u044f \u043f\u043e\u0442\u0435\u0440\u044c \u0432\u044b\u0433\u043b\u044f\u0434\u0438\u0442 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c:<\/p>\n<p>  <\/p>\n<p><math><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/formulas\/8dd\/2e8\/cfe\/8dd2e8cfe0680fcd01847f96509c6125.svg\" alt=\"$\\begin{eqnarray*} \\mathcal{L} = -\\log \\mathbb{P}(w_{c,1}, w_{c,2}, \\dots, w_{c,C}|w_o)=-\\log \\prod_{c=1}^C \\mathbb{P}(w_{c,i}|w_o) \\\\ = -\\log \\prod_{c=1}^C \\frac{\\exp(u_{c,j^*})}{\\sum_{j=1}^V \\exp(u_{c,j})} =-\\sum_{c=1}^C u_{c,j^*} + \\sum_{c=1}^C \\log \\sum_{j=1}^V \\exp(u_{c,j}) \\end{eqnarray*}$\" data-tex=\"display\"><\/math><\/p>\n<p>  <\/p>\n<p>\u0414\u043b\u044f \u043c\u043e\u0434\u0435\u043b\u0438 skip-gram \u0444\u0443\u043d\u043a\u0446\u0438\u044f \u043f\u043e\u0442\u0435\u0440\u044c \u0437\u0430\u0432\u0438\u0441\u0438\u0442 \u043e\u0442 <math><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/formulas\/55e\/e31\/9a5\/55ee319a5d231a08364d88ee8b7e43a0.svg\" alt=\"$C\\times V$\" data-tex=\"inline\"><\/math> \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0445<br \/>  \u0447\u0435\u0440\u0435\u0437:<\/p>\n<p>  <\/p>\n<p><math>$$display$$\\begin{equation*} \\mathcal{L} = \\mathcal{L}(\\mathbf{u_1}(W,W&#8217;), \\mathbf{u_2}(W,W&#8217;), \\dots, \\mathbf{u_C}(W,W&#8217;))\\\\=\\mathcal{L}(u_{1,1}(W,W&#8217;), u_{1,2}(W,W&#8217;), \\dots, u_{C,V}(W,W&#8217;)) \\end{equation*}$$display$$<\/math><\/p>\n<p>  <\/p>\n<p>\u0421\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0435\u043d\u043d\u043e \u043f\u0440\u0430\u0432\u0438\u043b\u043e \u0446\u0435\u043f\u043e\u0447\u043a\u0438 \u0432\u044b\u0433\u043b\u044f\u0434\u0438\u0442 \u0442\u0430\u043a:<\/p>\n<p>  <\/p>\n<p><math>$$display$$\\begin{equation*} \\frac{\\partial\\mathcal{L}}{\\partial W&#8217;_{ij}} = \\sum_{k=1}^V\\sum_{c=1}^C\\frac{\\partial\\mathcal{L}}{\\partial u_{c,k}}\\frac{\\partial u_{c,k}}{\\partial W&#8217;_{ij}} \\end{equation*}$$display$$<\/math><\/p>\n<p>  <\/p>\n<p>\u0438<\/p>\n<p>  <\/p>\n<p><math>$$display$$\\begin{equation*} \\frac{\\partial\\mathcal{L}}{\\partial W_{ij}} = \\sum_{k=1}^V\\sum_{c=1}^C\\frac{\\partial\\mathcal{L}}{\\partial u_{c,k}}\\frac{\\partial u_{c,k}}{\\partial W_{ij}}\\ . \\end{equation*}$$display$$<\/math><\/p>\n<p>  <\/p>\n<p>\u041f\u043e\u0441\u0447\u0438\u0442\u0430\u0435\u043c <math><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/formulas\/d5d\/e1c\/d0d\/d5de1cd0dfda3fcaa1b61583ea7b4e22.svg\" alt=\"$\\partial \\mathcal{L}\/\\partial u_{c,j}$\" data-tex=\"inline\"><\/math>, \u043f\u043e\u043b\u0443\u0447\u0438\u043c:<\/p>\n<p>  <\/p>\n<p><math>$$display$$\\begin{equation*} \\frac{\\partial\\mathcal{L}}{\\partial u_{c,j}} = -\\delta_{jj_c^*} + y_{c,j} := e_{c,j} \\end{equation*}$$display$$<\/math><\/p>\n<p>  <\/p>\n<p>\u0410\u043d\u0430\u043b\u043e\u0433\u0438\u0447\u043d\u043e \u043c\u043e\u0434\u0435\u043b\u0438 CBOW \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u043c:<\/p>\n<p>  <\/p>\n<p><math>$$display$$\\begin{equation*} \\frac{\\partial\\mathcal{L}}{\\partial W&#8217;_{ij}} = \\sum_{k=1}^V\\sum_{c=1}^C\\frac{\\partial\\mathcal{L}}{\\partial u_{c,k}}\\frac{\\partial u_{c,k}}{\\partial W&#8217;_{ij}} = \\sum_{c=1}^C\\frac{\\partial\\mathcal{L}}{\\partial u_{c,j}}\\frac{\\partial u_{c,j}}{\\partial W&#8217;_{ij}} = \\sum_{c=1}^C(-\\delta_{jj_c^*} + y_{c,j}) \\left(\\sum_{k=1}^V W_{ki}x_k\\right) \\end{equation*}$$display$$<\/math><\/p>\n<p>  <\/p>\n<p>\u041f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u043d\u0430\u044f \u043f\u043e <math><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/formulas\/c45\/ecb\/c5d\/c45ecbc5d3762c210932eab819d72fb4.svg\" alt=\"$W_{ij}$\" data-tex=\"inline\"><\/math> \u0441\u0430\u043c\u0430\u044f \u0441\u043b\u043e\u0436\u043d\u0430\u044f, \u043d\u043e \u0432\u044b\u043f\u043e\u043b\u043d\u0438\u043c\u0430\u044f:<\/p>\n<p>  <\/p>\n<p><math>$$display$$\\begin{equation*} \\frac{\\partial\\mathcal{L}}{\\partial W_{ij}} = \\sum_{k=1}^V\\sum_{c=1}^C\\frac{\\partial\\mathcal{L}}{\\partial u_{c,k}}\\frac{\\partial}{\\partial W_{ij}}\\left(\\sum_{m=1}^N\\sum_{l=1}^V W&#8217;_{mk} W_{lm}x_l\\right)=\\sum_{k=1}^V\\sum_{c=1}^C (-\\delta_{kk_c^*} + y_{c,k})W&#8217;_{jk}x_i . \\end{equation*}$$display$$<\/math><\/p>\n<p>  <\/p>\n<p>\u041f\u043e\u0434\u0432\u0435\u0434\u044f \u0438\u0442\u043e\u0433, \u0434\u043b\u044f \u043c\u043e\u0434\u0435\u043b\u0438 skip-gram \u043c\u044b \u0438\u043c\u0435\u0435\u043c:<\/p>\n<p>  <\/p>\n<p><math>$$display$$\\begin{equation} \\bbox[white,5px,border:2px dotted red]{ \\frac{\\partial\\mathcal{L}}{\\partial W&#8217;_{ij}} = \\sum_{c=1}^C(-\\delta_{jj_c^*} + y_{c,j}) \\left(\\sum_{k=1}^V W_{ki}x_k\\right) } \\label{eq:backprop1_skip} \\end{equation} \\&gt;(21)$$display$$<\/math><\/p>\n<p>  <\/p>\n<p>\u0438 <\/p>\n<p>  <\/p>\n<p><math>$$display$$\\begin{equation} \\bbox[white,5px,border:2px dotted red]{ \\frac{\\partial\\mathcal{L}}{\\partial W_{ij}} = \\sum_{k=1}^V\\sum_{c=1}^C (-\\delta_{kk_c^*} + y_{c,k})W&#8217;_{jk}x_i . } \\label{eq:backprop2_skip} \\end{equation} \\&gt;(22)$$display$$<\/math><\/p>\n<p>  <\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">\u0412\u0435\u043a\u0442\u043e\u0440\u0438\u0437\u0430\u0446\u0438\u044f<\/b><\/p>\n<div class=\"spoiler_text\">\n<p>\u0412\u0435\u043a\u0442\u043e\u0440\u0438\u0437\u043e\u0432\u0430\u043d\u043d\u0430\u044f \u0432\u0435\u0440\u0441\u0438\u044f \u0443\u0440\u0430\u0432\u043d\u0435\u043d\u0438\u044f (21):<\/p>\n<p>  <\/p>\n<p><math>$$display$$\\begin{equation} \\bbox[white,5px,border:2px dotted red]{ \\frac{\\partial\\mathcal{L}}{\\partial W&#8217;} = (W^T\\textbf{x}) \\otimes \\sum_{c=1}^C\\textbf{e}_c } \\end{equation} \\&gt;(23)$$display$$<\/math><\/p>\n<p>  <\/p>\n<p>\u0423\u0440\u0430\u0432\u043d\u0435\u043d\u0438\u0435 (22):<\/p>\n<p>  <\/p>\n<p><math>$$display$$\\begin{equation} \\bbox[white,5px,border:2px dotted red]{ \\frac{\\partial \\mathcal{L}}{\\partial W} = \\textbf{x}\\otimes\\left(W&#8217;\\sum_{c=1}^C\\textbf{e}_c\\right) } \\end{equation} \\&gt;(24)$$display$$<\/math><\/p>\n<\/div>\n<\/div>\n<p>  <\/p>\n<h3 id=\"6-chto-dalshe\">6. \u0427\u0442\u043e \u0434\u0430\u043b\u044c\u0448\u0435<\/h3>\n<p>  <\/p>\n<p>\u041c\u044b \u043f\u043e\u0434\u0440\u043e\u0431\u043d\u043e \u0440\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0435\u043b\u0438 \u043a\u0430\u043a \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c \u043e\u0431\u0440\u0430\u0442\u043d\u043e\u0433\u043e \u0440\u0430\u0441\u043f\u0440\u043e\u0441\u0442\u0440\u0430\u043d\u0435\u043d\u0438\u044f \u0432 \u0441\u043b\u0443\u0447\u0430\u0435 word2vec. \u041e\u0434\u043d\u0430\u043a\u043e \u0440\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0435\u043d\u043d\u0430\u044f \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f \u043d\u0435\u044d\u0444\u0444\u0435\u043a\u0442\u0438\u0432\u043d\u0430 \u0434\u043b\u044f \u0431\u043e\u043b\u044c\u0448\u0438\u0445 \u0442\u0435\u043a\u0441\u0442\u043e\u0432\u044b\u0445 \u043a\u043e\u0440\u043f\u0443\u0441\u043e\u0432. \u0412 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b\u044c\u043d\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0435 [2] \u043f\u0440\u0438\u043c\u0435\u043d\u044f\u044e\u0442\u0441\u044f \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0442\u0440\u044e\u043a\u0438 \u0434\u043b\u044f \u043f\u0440\u0435\u043e\u0434\u043e\u043b\u0435\u043d\u0438\u044f \u044d\u0442\u0438\u0445 \u043f\u0440\u043e\u0431\u043b\u0435\u043c (\u0438\u0435\u0440\u0430\u0440\u0445\u0438\u0447\u0435\u0441\u043a\u0438\u0439 softmax, negative sampling), \u043e\u0434\u043d\u0430\u043a\u043e \u044f \u043d\u0435 \u0431\u0443\u0434\u0443 \u043d\u0430 \u043d\u0438\u0445 \u043e\u0441\u0442\u0430\u043d\u0430\u0432\u043b\u0438\u0432\u0430\u0442\u044c\u0441\u044f \u043f\u043e\u0434\u0440\u043e\u0431\u043d\u043e. \u0412\u044b \u043c\u043e\u0436\u0435\u0442\u0435 \u043d\u0430\u0439\u0442\u0438 \u043f\u043e\u0434\u0440\u043e\u0431\u043d\u043e\u0435 \u043e\u043f\u0438\u0441\u0430\u043d\u0438\u0435 \u043f\u043e \u0441\u0441\u044b\u043b\u043a\u0435 [1].<\/p>\n<p>  <\/p>\n<p>\u041d\u0435\u0441\u043c\u043e\u0442\u0440\u044f \u043d\u0430 \u0432\u044b\u0447\u0438\u0441\u043b\u0438\u0442\u0435\u043b\u044c\u043d\u0443\u044e \u043d\u0435\u044d\u0444\u0444\u0435\u043a\u0442\u0438\u0432\u043d\u043e\u0441\u0442\u044c \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u043e\u043f\u0438\u0441\u0430\u043d\u043d\u043e\u0439 \u0437\u0434\u0435\u0441\u044c, \u043e\u043d\u0430 \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u0442 \u0432\u0441\u0451 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e\u0435 \u0434\u043b\u044f \u043e\u0431\u0443\u0447\u0435\u043d\u0438\u044f \u043d\u0435\u0439\u0440\u043e\u043d\u043d\u044b\u0445 \u0441\u0435\u0442\u0435\u0439 word2vec.<\/p>\n<p>  <\/p>\n<p>\u0421\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u043c \u0448\u0430\u0433\u043e\u043c \u0431\u0443\u0434\u0435\u0442 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f \u044d\u0442\u0438\u0445 \u0443\u0440\u0430\u0432\u043d\u0435\u043d\u0438\u0439 \u043d\u0430 \u0432\u0430\u0448\u0435\u043c \u043b\u044e\u0431\u0438\u043c\u043e\u043c \u044f\u0437\u044b\u043a\u0435 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f. \u0415\u0441\u043b\u0438 \u0432\u0430\u043c \u043d\u0440\u0430\u0432\u0438\u0442\u0441\u044f Python, \u044f \u0443\u0436\u0435 \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u043b \u044d\u0442\u0438 \u0443\u0440\u0430\u0432\u043d\u0435\u043d\u0438\u044f \u0432 \u043c\u043e\u0435\u043c <a href=\"http:\/\/www.claudiobellei.com\/2018\/01\/07\/backprop-word2vec-python\/\" rel=\"nofollow\">\u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u043c \u043f\u043e\u0441\u0442\u0435<\/a>. <\/p>\n<p>  <\/p>\n<p>\u041d\u0430\u0434\u0435\u044e\u0441\u044c \u0443\u0432\u0438\u0434\u0435\u0442\u044c \u0432\u0430\u0441 \u0442\u0430\u043c!<\/p>\n<p>  <\/p>\n<h3 id=\"dopolnitelnye-ssylki\">\u0414\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u0435 \u0441\u0441\u044b\u043b\u043a\u0438<\/h3>\n<p>  <\/p>\n<p>[1] X. Rong, <a href=\"https:\/\/arxiv.org\/abs\/1411.2738\" rel=\"nofollow\">word2vec Parameter Learning Explained<\/a>, arXiv:1411.2738 (2014).<br \/>  [2] T. Mikolov, K. Chen, G. Corrado, J. Dean, <a href=\"https:\/\/arxiv.org\/abs\/1301.3781\" rel=\"nofollow\">Efficient Estimation of Word Representations in Vector Space<\/a>, arXiv:1301.3781 (2013).<\/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\/post\/496186\/\"> https:\/\/habr.com\/ru\/post\/496186\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"\n<div class=\"post__text post__text-html post__text_v1\" id=\"post-content-body\" data-io-article-url=\"https:\/\/habr.com\/ru\/post\/496186\/\">\n<p>\u041f\u043e\u0441\u043a\u043e\u043b\u044c\u043a\u0443 \u044f \u0441\u0442\u043e\u043b\u043a\u043d\u0443\u043b\u0441\u044f \u0441 \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0435\u043d\u043d\u044b\u043c\u0438 \u0437\u0430\u0442\u0440\u0443\u0434\u043d\u0435\u043d\u0438\u044f\u043c\u0438 \u0432 \u043f\u043e\u0438\u0441\u043a\u0430\u0445 \u043e\u0431\u044a\u044f\u0441\u043d\u0435\u043d\u0438\u044f \u043c\u0435\u0445\u0430\u043d\u0438\u0437\u043c\u0430 \u043e\u0431\u0440\u0430\u0442\u043d\u043e\u0433\u043e \u0440\u0430\u0441\u043f\u0440\u043e\u0441\u0442\u0440\u0430\u043d\u0435\u043d\u0438\u044f \u043e\u0448\u0438\u0431\u043a\u0438, \u043a\u043e\u0442\u043e\u0440\u043e\u0435 \u043c\u043d\u0435 \u043f\u043e\u043d\u0440\u0430\u0432\u0438\u043b\u043e\u0441\u044c \u0431\u044b, \u044f \u0440\u0435\u0448\u0438\u043b \u043d\u0430\u043f\u0438\u0441\u0430\u0442\u044c \u0441\u043e\u0431\u0441\u0442\u0432\u0435\u043d\u043d\u044b\u0439 \u043f\u043e\u0441\u0442 \u043e\u0431 \u043e\u0431\u0440\u0430\u0442\u043d\u043e\u043c \u0440\u0430\u0441\u043f\u0440\u043e\u0441\u0442\u0440\u0430\u043d\u0435\u043d\u0438\u0438 \u043e\u0448\u0438\u0431\u043a\u0438 \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u0432 \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c Word2Vec. \u041c\u043e\u044f \u0446\u0435\u043b\u044c, \u2014 \u043e\u0431\u044a\u044f\u0441\u043d\u0438\u0442\u044c \u0441\u0443\u0449\u043d\u043e\u0441\u0442\u044c \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u0430, \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044f \u043f\u0440\u043e\u0441\u0442\u0443\u044e, \u043d\u043e \u043d\u0435\u0442\u0440\u0438\u0432\u0438\u0430\u043b\u044c\u043d\u0443\u044e \u043d\u0435\u0439\u0440\u043e\u0441\u0435\u0442\u044c. \u041a\u0440\u043e\u043c\u0435 \u0442\u043e\u0433\u043e, word2vec \u0441\u0442\u0430\u043b \u043d\u0430\u0441\u0442\u043e\u043b\u044c\u043a\u043e \u043f\u043e\u043f\u0443\u043b\u044f\u0440\u043d\u044b\u043c \u0432 NLP \u0441\u043e\u043e\u0431\u0449\u0435\u0441\u0442\u0432\u0435, \u0447\u0442\u043e \u0431\u0443\u0434\u0435\u0442 \u043f\u043e\u043b\u0435\u0437\u043d\u043e \u0441\u043e\u0441\u0440\u0435\u0434\u043e\u0442\u043e\u0447\u0438\u0442\u044c\u0441\u044f \u043d\u0430 \u043d\u0435\u043c.<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[],"tags":[],"class_list":["post-301535","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/301535","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=301535"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/301535\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=301535"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=301535"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=301535"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}