{"id":1834,"date":"2025-02-18T10:06:09","date_gmt":"2025-02-18T02:06:09","guid":{"rendered":"https:\/\/www.forillusion.com\/?p=1834"},"modified":"2025-02-18T10:06:10","modified_gmt":"2025-02-18T02:06:10","slug":"6-1-lang-model","status":"publish","type":"post","link":"https:\/\/www.forillusion.com\/index.php\/6-1-lang-model\/","title":{"rendered":"6.1 \u8bed\u8a00\u6a21\u578b"},"content":{"rendered":"\n<p><div class=\"has-toc have-toc\"><\/div><\/p>\n\n\n\n<p>\u628a\u4e00\u6bb5\u81ea\u7136\u8bed\u8a00\u6587\u672c\u770b\u4f5c\u4e00\u6bb5\u79bb\u6563\u7684\u65f6\u95f4\u5e8f\u5217\u3002\u5047\u8bbe\u4e00\u6bb5\u957f\u5ea6\u4e3a$T$\u7684\u6587\u672c\u4e2d\u7684\u8bcd\u4f9d\u6b21\u4e3a$w_1, w_2, \\ldots, w_T$\uff0c\u90a3\u4e48\u5728\u79bb\u6563\u7684\u65f6\u95f4\u5e8f\u5217\u4e2d\uff0c$w_t$\uff08$1 \\leq t \\leq T$\uff09\u53ef\u770b\u4f5c\u5728\u65f6\u95f4\u6b65\uff08time step\uff09$t$\u7684\u8f93\u51fa\u6216\u6807\u7b7e\u3002\u7ed9\u5b9a\u4e00\u4e2a\u957f\u5ea6\u4e3a$T$\u7684\u8bcd\u7684\u5e8f\u5217$w_1, w_2, \\ldots, w_T$\uff0c\u8bed\u8a00\u6a21\u578b\u5c06\u8ba1\u7b97\u8be5\u5e8f\u5217\u7684\u6982\u7387\uff1a<\/p>\n\n\n\n<p>$$<br>P(w_1, w_2, \\ldots, w_T).<br>$$<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">\u8bed\u8a00\u6a21\u578b\u7684\u8ba1\u7b97<\/h2>\n\n\n\n<p>\u5047\u8bbe\u5e8f\u5217$w_1, w_2, \\ldots, w_T$\u4e2d\u7684\u6bcf\u4e2a\u8bcd\u662f\u4f9d\u6b21\u751f\u6210\u7684\uff0c\u6709<\/p>\n\n\n\n<p>$$<br>P(w_1, w_2, \\ldots, w_T) = \\prod_{t=1}^T P(w_t \\mid w_1, \\ldots, w_{t-1}).<br>$$<\/p>\n\n\n\n<p>\u4f8b\u5982\uff0c\u4e00\u6bb5\u542b\u67094\u4e2a\u8bcd\u7684\u6587\u672c\u5e8f\u5217\u7684\u6982\u7387<\/p>\n\n\n\n<p>$$<br>P(w_1, w_2, w_3, w_4) = P(w_1) P(w_2 \\mid w_1) P(w_3 \\mid w_1, w_2) P(w_4 \\mid w_1, w_2, w_3).<br>$$<\/p>\n\n\n\n<p>\u4e3a\u4e86\u8ba1\u7b97\u8bed\u8a00\u6a21\u578b\uff0c\u9700\u8981\u8ba1\u7b97\u8bcd\u7684\u6982\u7387\uff0c\u4ee5\u53ca\u4e00\u4e2a\u8bcd\u5728\u7ed9\u5b9a\u524d\u51e0\u4e2a\u8bcd\u7684\u60c5\u51b5\u4e0b\u7684\u6761\u4ef6\u6982\u7387\uff0c\u5373\u8bed\u8a00\u6a21\u578b\u53c2\u6570\u3002\u8bbe\u8bad\u7ec3\u6570\u636e\u96c6\u4e3a\u4e00\u4e2a\u5927\u578b\u6587\u672c\u8bed\u6599\u5e93\u3002\u8bcd\u7684\u6982\u7387\u53ef\u4ee5\u901a\u8fc7\u8be5\u8bcd\u5728\u8bad\u7ec3\u6570\u636e\u96c6\u4e2d\u7684\u76f8\u5bf9\u8bcd\u9891\u6765\u8ba1\u7b97\u3002\u4f8b\u5982\uff0c$P(w_1)$\u53ef\u4ee5\u8ba1\u7b97\u4e3a$w_1$\u5728\u8bad\u7ec3\u6570\u636e\u96c6\u4e2d\u7684\u8bcd\u9891\uff08\u8bcd\u51fa\u73b0\u7684\u6b21\u6570\uff09\u4e0e\u8bad\u7ec3\u6570\u636e\u96c6\u7684\u603b\u8bcd\u6570\u4e4b\u6bd4\u3002\u56e0\u6b64\uff0c\u6839\u636e\u6761\u4ef6\u6982\u7387\u5b9a\u4e49\uff0c\u4e00\u4e2a\u8bcd\u5728\u7ed9\u5b9a\u524d\u51e0\u4e2a\u8bcd\u7684\u60c5\u51b5\u4e0b\u7684\u6761\u4ef6\u6982\u7387\u4e5f\u53ef\u4ee5\u901a\u8fc7\u8bad\u7ec3\u6570\u636e\u96c6\u4e2d\u7684\u76f8\u5bf9\u8bcd\u9891\u8ba1\u7b97\u3002\u4f8b\u5982\uff0c$P(w_2 \\mid w_1)$\u53ef\u4ee5\u8ba1\u7b97\u4e3a$w_1, w_2$\u4e24\u8bcd\u76f8\u90bb\u7684\u9891\u7387\u4e0e$w_1$\u8bcd\u9891\u7684\u6bd4\u503c\uff0c\u56e0\u4e3a\u8be5\u6bd4\u503c\u5373$P(w_1, w_2)$\u4e0e$P(w_1)$\u4e4b\u6bd4\uff1b\u800c$P(w_3 \\mid w_1, w_2)$\u540c\u7406\u53ef\u4ee5\u8ba1\u7b97\u4e3a$w_1$\u3001$w_2$\u548c$w_3$\u4e09\u8bcd\u76f8\u90bb\u7684\u9891\u7387\u4e0e$w_1$\u548c$w_2$\u4e24\u8bcd\u76f8\u90bb\u7684\u9891\u7387\u7684\u6bd4\u503c\u3002\u4ee5\u6b64\u7c7b\u63a8\u3002<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">$n$\u5143\u8bed\u6cd5<\/h2>\n\n\n\n<p>\u5f53\u5e8f\u5217\u957f\u5ea6\u589e\u52a0\u65f6\uff0c\u8ba1\u7b97\u548c\u5b58\u50a8\u591a\u4e2a\u8bcd\u5171\u540c\u51fa\u73b0\u7684\u6982\u7387\u7684\u590d\u6742\u5ea6\u4f1a\u5448\u6307\u6570\u7ea7\u589e\u52a0\u3002$n$\u5143\u8bed\u6cd5\u901a\u8fc7\u9a6c\u5c14\u53ef\u592b\u5047\u8bbe\u7b80\u5316\u4e86\u8bed\u8a00\u6a21\u578b\u7684\u8ba1\u7b97\u3002\u9a6c\u5c14\u53ef\u592b\u5047\u8bbe\u662f\u6307\u4e00\u4e2a\u8bcd\u7684\u51fa\u73b0\u53ea\u4e0e\u524d\u9762$n$\u4e2a\u8bcd\u76f8\u5173\uff0c\u5373$n$\u9636\u9a6c\u5c14\u53ef\u592b\u94fe\uff08Markov chain of order $n$\uff09\u3002\u5982\u679c$n=1$\uff0c\u90a3\u4e48\u6709$P(w_3 \\mid w_1, w_2) = P(w_3 \\mid w_2)$\u3002\u5982\u679c\u57fa\u4e8e$n-1$\u9636\u9a6c\u5c14\u53ef\u592b\u94fe\uff0c\u53ef\u4ee5\u5c06\u8bed\u8a00\u6a21\u578b\u6539\u5199\u4e3a<\/p>\n\n\n\n<p>$$<br>P(w_1, w_2, \\ldots, w_T) \\approx \\prod_{t=1}^T P(w_t \\mid w_{t-(n-1)}, \\ldots, w_{t-1}) .<br>$$<\/p>\n\n\n\n<p>\u4ee5\u4e0a\u4e5f\u53eb$n$\u5143\u8bed\u6cd5\uff08$n$-grams\uff09\u3002\u5b83\u662f\u57fa\u4e8e$n - 1$\u9636\u9a6c\u5c14\u53ef\u592b\u94fe\u7684\u6982\u7387\u8bed\u8a00\u6a21\u578b\u3002\u5f53$n$\u5206\u522b\u4e3a1\u30012\u548c3\u65f6\uff0c\u5c06\u5176\u5206\u522b\u79f0\u4f5c\u4e00\u5143\u8bed\u6cd5\uff08unigram\uff09\u3001\u4e8c\u5143\u8bed\u6cd5\uff08bigram\uff09\u548c\u4e09\u5143\u8bed\u6cd5\uff08trigram\uff09\u3002\u4f8b\u5982\uff0c\u957f\u5ea6\u4e3a4\u7684\u5e8f\u5217$w_1, w_2, w_3, w_4$\u5728\u4e00\u5143\u8bed\u6cd5\u3001\u4e8c\u5143\u8bed\u6cd5\u548c\u4e09\u5143\u8bed\u6cd5\u4e2d\u7684\u6982\u7387\u5206\u522b\u4e3a<\/p>\n\n\n\n<p>$$<br>\\begin{aligned}<br>P(w_1, w_2, w_3, w_4) &amp;= P(w_1) P(w_2) P(w_3) P(w_4) ,\\<br>P(w_1, w_2, w_3, w_4) &amp;= P(w_1) P(w_2 \\mid w_1) P(w_3 \\mid w_2) P(w_4 \\mid w_3) ,\\<br>P(w_1, w_2, w_3, w_4) &amp;= P(w_1) P(w_2 \\mid w_1) P(w_3 \\mid w_1, w_2) P(w_4 \\mid w_2, w_3) .<br>\\end{aligned}<br>$$<\/p>\n\n\n\n<p>\u5f53$n$\u8f83\u5c0f\u65f6\uff0c$n$\u5143\u8bed\u6cd5\u5f80\u5f80\u5e76\u4e0d\u51c6\u786e\u3002\u5f53$n$\u8f83\u5927\u65f6\uff0c$n$\u5143\u8bed\u6cd5\u9700\u8981\u8ba1\u7b97\u5e76\u5b58\u50a8\u5927\u91cf\u7684\u8bcd\u9891\u548c\u591a\u8bcd\u76f8\u90bb\u9891\u7387\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u628a\u4e00\u6bb5\u81ea\u7136\u8bed\u8a00\u6587\u672c\u770b\u4f5c\u4e00\u6bb5\u79bb\u6563\u7684\u65f6\u95f4\u5e8f\u5217\u3002\u5047\u8bbe\u4e00\u6bb5\u957f\u5ea6\u4e3a$T$\u7684\u6587\u672c\u4e2d\u7684\u8bcd\u4f9d\u6b21\u4e3a$w_1, w_2, \\ldots, w_T$\uff0c\u90a3 &#8230;<\/p>","protected":false},"author":1,"featured_media":1835,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[46,3],"tags":[45,44,12,22],"class_list":["post-1834","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-46","category-3","tag-45","tag-44","tag-12","tag-22"],"_links":{"self":[{"href":"https:\/\/www.forillusion.com\/index.php\/wp-json\/wp\/v2\/posts\/1834","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.forillusion.com\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.forillusion.com\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.forillusion.com\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.forillusion.com\/index.php\/wp-json\/wp\/v2\/comments?post=1834"}],"version-history":[{"count":1,"href":"https:\/\/www.forillusion.com\/index.php\/wp-json\/wp\/v2\/posts\/1834\/revisions"}],"predecessor-version":[{"id":1839,"href":"https:\/\/www.forillusion.com\/index.php\/wp-json\/wp\/v2\/posts\/1834\/revisions\/1839"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.forillusion.com\/index.php\/wp-json\/wp\/v2\/media\/1835"}],"wp:attachment":[{"href":"https:\/\/www.forillusion.com\/index.php\/wp-json\/wp\/v2\/media?parent=1834"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.forillusion.com\/index.php\/wp-json\/wp\/v2\/categories?post=1834"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.forillusion.com\/index.php\/wp-json\/wp\/v2\/tags?post=1834"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}