{"id":23712,"date":"2024-12-26T10:42:54","date_gmt":"2024-12-26T02:42:54","guid":{"rendered":"https:\/\/aif.amtbbs.org\/?p=23712"},"modified":"2024-12-26T10:42:54","modified_gmt":"2024-12-26T02:42:54","slug":"turboattention%ef%bc%9a%e5%9f%ba%e4%ba%8e%e5%a4%9a%e9%a1%b9%e5%bc%8f%e8%bf%91%e4%bc%bc%e5%92%8c%e6%b8%90%e8%bf%9b%e5%bc%8f%e9%87%8f%e5%8c%96%e7%9a%84%e9%ab%98%e6%95%88%e6%b3%a8%e6%84%8f%e5%8a%9b","status":"publish","type":"post","link":"https:\/\/aif.amtbbs.org\/index.php\/2024\/12\/26\/23712\/","title":{"rendered":"TurboAttention\uff1a\u57fa\u4e8e\u591a\u9879\u5f0f\u8fd1\u4f3c\u548c\u6e10\u8fdb\u5f0f\u91cf\u5316\u7684\u9ad8\u6548\u6ce8\u610f\u529b\u673a\u5236\u4f18\u5316\u65b9\u6848\uff0c\u964d\u4f4eLLM\u8ba1\u7b97\u6210\u672c70%"},"content":{"rendered":"<div><img data-dominant-color=\"a3bddf\" data-has-transparency=\"false\" style=\"--dominant-color: #a3bddf;\" loading=\"lazy\" decoding=\"async\" class=\"not-transparent alignnone size-full wp-image-23714\" src=\"https:\/\/aiforumimage.oss-cn-shanghai.aliyuncs.com\/wp-content\/uploads\/2024\/12\/9c6c7703-d70d-4f59-b078-703fff008b40-300x167-1.png\" width=\"300\" height=\"167\" alt=\"\" srcset=\"https:\/\/aiforumimage.oss-cn-shanghai.aliyuncs.com\/wp-content\/uploads\/2024\/12\/9c6c7703-d70d-4f59-b078-703fff008b40-300x167-1.png 300w, https:\/\/aiforumimage.oss-cn-shanghai.aliyuncs.com\/wp-content\/uploads\/2024\/12\/9c6c7703-d70d-4f59-b078-703fff008b40-300x167-1-150x84.png 150w\" sizes=\"auto, (max-width: 300px) 100vw, 300px\" \/><\/div>\n<div><\/div>\n<div class=\"article-desc\">\u968f\u7740\u5927\u578b\u8bed\u8a00\u6a21\u578b(LLMs)\u5728AI\u5e94\u7528\u9886\u57df\u6301\u7eed\u53d1\u5c55\uff0c\u5176\u8ba1\u7b97\u6210\u672c\u4e5f\u5448\u73b0\u663e\u8457\u4e0a\u5347\u8d8b\u52bf\u3002\u6570\u636e\u5206\u6790\u8868\u660e\uff0cGPT-4\u7684\u8fd0\u884c\u6210\u672c\u7ea6\u4e3a700\u7f8e\u5143\/\u5c0f\u65f6\uff0c2023\u5e74\u5404\u4f01\u4e1a\u5728LLM\u63a8\u7406\u65b9\u9762\u7684\u603b\u652f\u51fa\u8d85\u8fc750\u4ebf\u7f8e\u5143\u3002<\/div>\n<div id=\"postspictures\" class=\"article-content\">\n<div id=\"container\" class=\"container am-engine\" data-v-1d7a5742=\"\" data-element=\"root\">\n<p>\u968f\u7740\u5927\u578b\u8bed\u8a00\u6a21\u578b(LLMs)\u5728AI\u5e94\u7528\u9886\u57df\u6301\u7eed\u53d1\u5c55\uff0c\u5176\u8ba1\u7b97\u6210\u672c\u4e5f\u5448\u73b0\u663e\u8457\u4e0a\u5347\u8d8b\u52bf\u3002\u6570\u636e\u5206\u6790\u8868\u660e\uff0cGPT-4\u7684\u8fd0\u884c\u6210\u672c\u7ea6\u4e3a700\u7f8e\u5143\/\u5c0f\u65f6\uff0c2023\u5e74\u5404\u4f01\u4e1a\u5728LLM\u63a8\u7406\u65b9\u9762\u7684\u603b\u652f\u51fa\u8d85\u8fc750\u4ebf\u7f8e\u5143\u3002\u8fd9\u4e00\u6311\u6218\u7684\u6838\u5fc3\u5728\u4e8e\u6ce8\u610f\u529b\u673a\u5236\u2014\u2014\u8be5\u673a\u5236\u4f5c\u4e3a\u6a21\u578b\u5904\u7406\u548c\u5173\u8054\u4fe1\u606f\u7684\u8ba1\u7b97\u6838\u5fc3\uff0c\u540c\u65f6\u4e5f\u6784\u6210\u4e86\u4e3b\u8981\u7684\u6027\u80fd\u74f6\u9888\u3002<\/p>\n<p>TurboAttention\u63d0\u51fa\u4e86\u4e00\u79cd\u5168\u65b0\u7684LLM\u4fe1\u606f\u5904\u7406\u65b9\u6cd5\u3002\u8be5\u65b9\u6cd5\u901a\u8fc7\u4e00\u7cfb\u5217\u4f18\u5316\u624b\u6bb5\u66ff\u4ee3\u4e86\u4f20\u7edf\u7684\u4e8c\u6b21\u590d\u6742\u5ea6\u6ce8\u610f\u529b\u673a\u5236\uff0c\u5305\u62ec\u7a00\u758f\u591a\u9879\u5f0f\u8f6f\u6700\u5927\u503c\u8fd1\u4f3c\u548c\u9ad8\u6548\u91cf\u5316\u6280\u672f\u3002\u521d\u6b65\u5b9e\u73b0\u7ed3\u679c\u663e\u793a\uff0c\u8be5\u65b9\u6cd5\u53ef\u5b9e\u73b070%\u7684\u8ba1\u7b97\u6210\u672c\u964d\u4f4e\uff0c\u540c\u65f6\u4fdd\u630198%\u7684\u6a21\u578b\u7cbe\u5ea6\u3002<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/s5.51cto.com\/oss\/202412\/25\/365b8cf280c2e74ab400623fcbd97b2e928f8e.webp\" data-type=\"block\" \/><\/p>\n<p>\u5bf9\u4e8e\u89c4\u6a21\u90e8\u7f72LLM\u7684\u7ec4\u7ec7\u800c\u8a00\uff0c\u8fd9\u4e0d\u4ec5\u662f\u6027\u80fd\u7684\u63d0\u5347\uff0c\u66f4\u662f\u4e00\u9879\u53ef\u663e\u8457\u964d\u4f4e\u8fd0\u8425\u6210\u672c\u5e76\u4f18\u5316\u54cd\u5e94\u65f6\u95f4\u7684\u6280\u672f\u7a81\u7834\u3002<\/p>\n<p>\u672c\u6587\u5c06\u4ece\u6280\u672f\u5c42\u9762\u6df1\u5165\u63a2\u8ba8TurboAttention\u5982\u4f55\u5b9e\u73b0\u6548\u7387\u63d0\u5347\uff0c\u5206\u6790\u5176\u67b6\u6784\u521b\u65b0\u3002<\/p>\n<h2>1\u3001\u6ce8\u610f\u529b\u673a\u5236\u539f\u7406<\/h2>\n<p>\u5728\u6df1\u5165\u5206\u6790TurboAttention\u4e4b\u524d\uff0c\u9996\u5148\u9700\u8981\u7406\u89e3\u6ce8\u610f\u529b\u673a\u5236\u7684\u57fa\u672c\u539f\u7406\uff0c\u7279\u522b\u662f\u5176\u9ad8\u6548\u6027\u4e0e\u8ba1\u7b97\u5bc6\u96c6\u6027\u7684\u53cc\u91cd\u7279\u6027\u3002<\/p>\n<h3>\u6ce8\u610f\u529b\u673a\u5236\u5b9a\u4e49<\/h3>\n<p>\u5728\u6df1\u5ea6\u5b66\u4e60\u9886\u57df\uff0c<strong>\u6ce8\u610f\u529b\u673a\u5236<\/strong>\u662f\u4e00\u79cd\u4f7f\u6a21\u578b\u80fd\u591f\u52a8\u6001\u5173\u6ce8\u8f93\u5165\u6570\u636e\u4e0d\u540c\u90e8\u5206\u7684\u6280\u672f\u65b9\u6cd5\u3002\u533a\u522b\u4e8e\u5bf9\u6240\u6709\u8bcd\u5143\u6216\u5143\u7d20\u8d4b\u4e88\u76f8\u540c\u7684\u6743\u91cd\uff0c\u6ce8\u610f\u529b\u673a\u5236\u5141\u8bb8\u7f51\u7edc\u91cd\u70b9\u5173\u6ce8\u7279\u5b9a\u8bcd\u5143\u3002\u8fd9\u4e00\u7279\u6027\u5728\u5e8f\u5217\u5904\u7406\u4efb\u52a1\u4e2d\u5c24\u5176\u91cd\u8981\uff0c\u5982\u8bed\u8a00\u5efa\u6a21\u4e2d\u53e5\u5b50\u524d\u90e8\u5206\u7684\u8bcd\u5bf9\u540e\u7eed\u8bcd\u7684\u5f71\u54cd\u3002<\/p>\n<h3>\u6ce8\u610f\u529b\u673a\u5236\u7c7b\u578b<\/h3>\n<p><strong>\u81ea\u6ce8\u610f\u529b<\/strong>\uff1a\u8ba1\u7b97\u540c\u4e00\u5e8f\u5217\u5185\u90e8\u7684\u6ce8\u610f\u529b\u5f97\u5206\u3002\u4f8b\u5982\uff0c\u5728\u53e5\u5b50\u5904\u7406\u4e2d\uff0c\u6a21\u578b\u8ba1\u7b97\u6bcf\u4e2a\u8bcd\u4e0e\u540c\u4e00\u53e5\u5b50\u4e2d\u5176\u4ed6\u8bcd\u7684\u5173\u8054\u5ea6\uff0c\u4ee5\u83b7\u53d6\u4e0a\u4e0b\u6587\u5173\u7cfb\u3002<\/p>\n<p><strong>\u4ea4\u53c9\u6ce8\u610f\u529b<\/strong>\uff1a\u8ba1\u7b97\u4e0d\u540c\u5e8f\u5217\u95f4\u7684\u6ce8\u610f\u529b\u5f97\u5206\uff0c\u5178\u578b\u5e94\u7528\u5982\u795e\u7ecf\u673a\u5668\u7ffb\u8bd1\u7cfb\u7edf\u4e2d\u6e90\u8bed\u8a00\u4e0e\u76ee\u6807\u8bed\u8a00\u5e8f\u5217\u95f4\u7684\u5173\u8054\u8ba1\u7b97\u3002<\/p>\n<h3>\u8ba1\u7b97\u590d\u6742\u5ea6\u5206\u6790<\/h3>\n<p>\u4f20\u7edf\u6ce8\u610f\u529b\u673a\u5236\u9700\u8981\u5904\u7406\u5c3a\u5bf8\u4e3a\u7684\u77e9\u9635\u8ba1\u7b97\uff0c\u5176\u4e2d\u8868\u793a\u5e8f\u5217\u957f\u5ea6\u3002\u56e0\u6b64\u8ba1\u7b97\u590d\u6742\u5ea6\u4e3a\u3002\u5bf9\u4e8eLLM\u4e2d\u5e38\u89c1\u7684\u6570\u5343\u8bcd\u5143\u957f\u5e8f\u5217\uff0c\u8fd9\u79cd\u590d\u6742\u5ea6rapidly\u6784\u6210\u6027\u80fd\u74f6\u9888\u3002<\/p>\n<h3>\u9ad8\u6548\u6ce8\u610f\u529b\u673a\u5236\u7684\u5fc5\u8981\u6027<\/h3>\n<p>\u968f\u7740\u6a21\u578b\u89c4\u6a21\u4ece\u767e\u4e07\u6269\u5c55\u5230\u5341\u4ebf\u751a\u81f3\u4e07\u4ebf\u53c2\u6570\uff0c\u6ce8\u610f\u529b\u673a\u5236\u7684\u8ba1\u7b97\u74f6\u9888\u65e5\u76ca\u51f8\u663e\uff0c\u8fd9\u4e25\u91cd\u5236\u7ea6\u4e86\u5b9e\u65f6\u5904\u7406\u80fd\u529b\u5e76\u5bfc\u81f4\u8ba1\u7b97\u6210\u672c\u6500\u5347\u3002TurboAttention\u901a\u8fc7\u6574\u5408\u591a\u9879\u4f18\u5316\u7b56\u7565\u89e3\u51b3\u8fd9\u4e00\u95ee\u9898\uff0c\u5305\u62ec\u7a00\u758f\u5316\u5904\u7406\u3001\u591a\u9879\u5f0f\u8f6f\u6700\u5927\u503c\u8fd1\u4f3c\u548c\u5206\u7ea7\u91cf\u5316\u65b9\u6848\u3002<\/p>\n<h2>2\u3001TurboAttention\u6280\u672f\u67b6\u6784<\/h2>\n<p>TurboAttention\u63d0\u4f9b\u4e86\u4e00\u79cd\u5728\u5927\u89c4\u6a21Transformer\u6a21\u578b\u4e2d\u5b9e\u73b0\u6ce8\u610f\u529b\u673a\u5236\u8fd1\u4f3c\u7684\u6280\u672f\u65b9\u6848\uff0c\u5728\u8ba1\u7b97\u6548\u7387\u548c\u6a21\u578b\u6027\u80fd\u4e4b\u95f4\u8fbe\u5230\u5e73\u8861\u3002\u5176\u6838\u5fc3\u521b\u65b0\u70b9\u5305\u62ec\u4e24\u4e2a\u65b9\u9762\uff1a\u6ce8\u610f\u529b\u6743\u91cd\u7684\u8ba1\u7b97\u4f18\u5316\uff08\u91c7\u7528\u591a\u9879\u5f0f\u8fd1\u4f3c\u548c\u7a00\u758f\u9608\u503c\u5904\u7406\uff09\u4ee5\u53ca\u76f8\u5173\u6570\u636e\uff08\u67e5\u8be2\u3001\u952e\u548c\u503c\u77e9\u9635\uff09\u7684\u5b58\u50a8\u4f18\u5316\uff08\u91c7\u7528\u6e10\u8fdb\u5f0f\u91cf\u5316\u65b9\u6848\uff09\u3002<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/s5.51cto.com\/oss\/202412\/25\/5729fb392f2ae3536733508b11652dc1eb9a5d.webp\" data-type=\"block\" \/><\/p>\n<h3>\u6838\u5fc3\u6280\u672f\u7ec4\u4ef6<\/h3>\n<ul data-id=\"u738a58b-f478XDhU\">\n<li data-id=\"ld70c578-FbMikZAB\"><strong>\u7a00\u758f\u6ce8\u610f\u529b\u8ba1\u7b97<\/strong>\uff1a\u901a\u8fc7\u8bc6\u522b\u5e76\u4ec5\u4fdd\u7559\u5173\u952e\u8bcd\u5143\u5bf9\u7684\u65b9\u5f0f\uff0c\u5927\u5e45\u964d\u4f4e\u6ce8\u610f\u529b\u8ba1\u7b97\u91cf\u3002<\/li>\n<li data-id=\"ld70c578-J4dj4SmQ\"><strong>\u4f4e\u79e9\u77e9\u9635\u5206\u89e3<\/strong>\uff1a\u5728\u53ef\u884c\u60c5\u51b5\u4e0b\u5c06\u9ad8\u7ef4\u6ce8\u610f\u529b\u77e9\u9635\u5206\u89e3\u4e3a\u4f4e\u7ef4\u8868\u793a\uff0c\u4ee5\u51cf\u5c11\u77e9\u9635\u4e58\u6cd5\u8fd0\u7b97\u3002<\/li>\n<li data-id=\"ld70c578-MV6D9RUr\"><strong>\u6838\u51fd\u6570\u4f18\u5316<\/strong>\uff1a\u91c7\u7528\u6838\u51fd\u6570\u65b9\u6cd5\uff0c\u63d0\u4f9b\u6bd4\u4f20\u7edf\u77e9\u9635\u4e58\u6cd5\u66f4\u9ad8\u6548\u7684\u6ce8\u610f\u529b\u5206\u5e03\u4f30\u8ba1\u3002<\/li>\n<li data-id=\"ld70c578-rqvwJzuL\"><strong>\u591a\u9879\u5f0f\u8f6f\u6700\u5927\u503c\u8fd1\u4f3c(SAS)<\/strong>\uff1a\u4f7f\u7528\u591a\u9879\u5f0f\u51fd\u6570\u8fd1\u4f3c\u8f6f\u6700\u5927\u503c\u4e2d\u7684\u6307\u6570\u8fd0\u7b97\uff0c\u964d\u4f4e\u8ba1\u7b97\u5f00\u9500\u3002<\/li>\n<li data-id=\"ld70c578-eDWKVJzI\"><strong>\u6e10\u8fdb\u5f0f\u91cf\u5316(PQ)<\/strong>\uff1a\u5b9e\u73b0\u591a\u7ea7\u91cf\u5316\u7b56\u7565\uff08\u4eceINT8\u5230INT4\uff0c\u67d0\u4e9b\u60c5\u51b5\u4e0b\u53ef\u964d\u81f3INT2\uff09\uff0c\u4f18\u5316\u5e26\u5bbd\u548c\u5185\u5b58\u4f7f\u7528\u3002<\/li>\n<\/ul>\n<h3>\u6570\u5b66\u57fa\u7840<\/h3>\n<p>\u4f20\u7edf\u6ce8\u610f\u529b\u8fd0\u7b97\u7684\u6570\u5b66\u8868\u8fbe\u5f0f\u4e3a\uff1a<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/s7.51cto.com\/oss\/202412\/25\/b9258b19432d4357d2a273bb04a0ac3e2b59f7.webp\" data-type=\"block\" \/><\/p>\n<p>\u5176\u4e2d\uff08\u67e5\u8be2\u77e9\u9635\uff09\u3001\uff08\u952e\u77e9\u9635\uff09\u548c\uff08\u503c\u77e9\u9635\uff09\u7531\u8f93\u5165\u6570\u636e\u751f\u6210\uff0c\u8868\u793a\u952e\u5411\u91cf\u7ef4\u5ea6\u3002\u867d\u7136\u4fdd\u8bc1\u4e86\u6ce8\u610f\u529b\u6743\u91cd\u548c\u4e3a1\uff0c\u4f46\u6307\u6570\u8fd0\u7b97\u5e26\u6765\u4e86\u663e\u8457\u7684\u8ba1\u7b97\u5f00\u9500\u3002TurboAttention\u901a\u8fc7\u5f15\u5165\u7a00\u758f\u8ba1\u7b97\uff08\u4ec5\u8ba1\u7b97\u5fc5\u8981\u7684\u6ce8\u610f\u529b\u5206\u6570\uff09\u548c\u9ad8\u6548\u6307\u6570\u8fd1\u4f3c\u6765\u4f18\u5316\u8fd9\u4e00\u8fc7\u7a0b\u3002<\/p>\n<p>\u4ee5\u9ad8\u7cbe\u5ea6\uff08FP16\/FP32\uff09\u5b58\u50a8\u548c\u4f20\u8f93\u548c\u77e9\u9635\u4f1a\u5360\u7528\u5927\u91cf\u5185\u5b58\u3002\u6e10\u8fdb\u5f0f\u91cf\u5316\u901a\u8fc7\u5c06\u8fd9\u4e9b\u77e9\u9635\u8f6c\u6362\u4e3a\u4f4e\u4f4d\u6574\u6570\u8868\u793a\u6765\u89e3\u51b3\u6b64\u95ee\u9898\uff0c\u6709\u6548\u964d\u4f4e\u5185\u5b58\u548c\u8ba1\u7b97\u5f00\u9500\u3002<\/p>\n<h3>SAS\uff1a\u7a00\u758f\u6fc0\u6d3b\u8f6f\u6700\u5927\u503c\u6280\u672f<\/h3>\n<p>Transformer\u6a21\u578b\u4e2d\u6ce8\u610f\u529b\u673a\u5236\u7684\u4e00\u4e2a\u5173\u952e\u6027\u80fd\u74f6\u9888\u662f<strong>\u8f6f\u6700\u5927\u503c<\/strong>\u51fd\u6570\u3002\u4f20\u7edf\u8f6f\u6700\u5927\u503c\u8ba1\u7b97\u9700\u8981\u6267\u884c\u6307\u6570\u8fd0\u7b97\u548c\u9664\u6cd5\u8fd0\u7b97\uff0c\u8fd9\u5728\u5904\u7406\u5927\u89c4\u6a21\u77e9\u9635\u65f6\u4f1a\u4ea7\u751f\u663e\u8457\u7684\u6d6e\u70b9\u8fd0\u7b97\u5f00\u9500\u3002<\/p>\n<h4>\u591a\u9879\u5f0f\u8fd1\u4f3c\u8f6f\u6700\u5927\u503c<\/h4>\n<p>SAS\uff08\u7a00\u758f\u6fc0\u6d3b\u8f6f\u6700\u5927\u503c\uff09\u6280\u672f\u8bc1\u660e\u4e86\u5728\u5b9e\u9645\u5e94\u7528\u8303\u56f4\u5185\u53ef\u4ee5\u4f7f\u7528\u4f4e\u6b21\u591a\u9879\u5f0f\u8fdb\u884c\u6709\u6548\u8fd1\u4f3c\u3002\u5177\u4f53\u5b9a\u4e49\u5982\u4e0b\uff1a<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/s4.51cto.com\/oss\/202412\/25\/b4823b873695aacdc3a885468d93ff43c80a86.webp\" data-type=\"block\" \/><\/p>\n<p>\u8be5\u516c\u5f0f\u5c06\u8ba1\u7b97\u5206\u4e3a\u6574\u6570\u90e8\u5206\u548c\u5c0f\u6570\u90e8\u5206\uff08\u548c\uff09\uff0c\u5bf9\u5176\u4e2d\u4e00\u90e8\u5206\u4f7f\u7528\u67e5\u627e\u8868(LUT)\uff0c\u53e6\u4e00\u90e8\u5206\u4f7f\u7528\u591a\u9879\u5f0f\uff08\uff09\u8ba1\u7b97\u3002<\/p>\n<p>\u5178\u578b\u7684\u4e09\u6b21\u591a\u9879\u5f0f\u62df\u5408\uff08\u901a\u8fc7\u6700\u5c0f\u4e8c\u4e58\u6cd5\u6c42\u89e3\uff09\u5f62\u5f0f\u5982\u4e0b\uff1a<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/s8.51cto.com\/oss\/202412\/25\/133c1b7318172a629eb457bcd9094fe93a147b.webp\" data-type=\"block\" \/><\/p>\n<p>\u901a\u8fc7\u5c06\u591a\u9879\u5f0f\u6b21\u6570\u9650\u5236\u57282\u62163\u5e76\u5c06\u53d6\u503c\u8303\u56f4\u63a7\u5236\u5728\u5185\uff0cSAS\u65b9\u6cd5\u76f8\u6bd4\u6d6e\u70b9\u6307\u6570\u8fd0\u7b97\u5b9e\u73b0\u4e86\u663e\u8457\u7684\u6027\u80fd\u63d0\u5347\u3002<\/p>\n<p>\u5728GPU\u5f20\u91cf\u6838\u5fc3\u7b49\u786c\u4ef6\u4e0a\uff0c\u8fd9\u4e9b\u591a\u9879\u5f0f\u8fd0\u7b97\u53ef\u4ee5\u901a\u8fc7FP16\u53cb\u597d\u7684\u65b9\u5f0f\u6267\u884c\uff0c\u8fdb\u4e00\u6b65\u63d0\u9ad8\u8ba1\u7b97\u541e\u5410\u91cf\u3002<\/p>\n<h4>\u8f6f\u6700\u5927\u503c\u540e\u7a00\u758f\u5316\u5904\u7406<\/h4>\n<p>\u8f83\u5927\u7684&#8221;\u4e3b\u5bfc&#8221;\u6ce8\u610f\u529b\u5206\u6570\u5f80\u5f80\u4f1a\u63a9\u76d6\u8f83\u5c0f\u7684\u5206\u6570\u3002\u5728\u5e94\u7528\u591a\u9879\u5f0f\u6307\u6570\u8fd1\u4f3c\u540e\uff0cSAS\u53ef\u5c06\u4f4e\u4e8e\u9608\u503c\u7684\u5206\u6570\u7f6e\u96f6\uff0c\u5b9e\u73b0\u4ec5\u5173\u6ce8\u6700\u76f8\u5173\u8bcd\u5143\u4ea4\u4e92\u7684\u76ee\u6807\u3002\u8fd9\u79cd\u65b9\u6cd5\u751f\u6210<strong>\u7a00\u758f<\/strong>\u7ed3\u679c\uff0c\u4ece\u800c\u964d\u4f4e\u5185\u5b58\u548c\u8ba1\u7b97\u5f00\u9500\u3002<\/p>\n<h3>\u6e10\u8fdb\u5f0f\u91cf\u5316\u6280\u672f\uff08PQ\uff09<\/h3>\n<p>SAS\u6280\u672f\u89e3\u51b3\u4e86\u8f6f\u6700\u5927\u503c\u7684\u8ba1\u7b97\u6548\u7387\u95ee\u9898\uff0c\u800c\u91cf\u5316\u6280\u672f\u5219\u9488\u5bf9\u5927\u89c4\u6a21\u6a21\u578b\u7684\u5185\u5b58\u5e26\u5bbd\u7ea6\u675f\u63d0\u4f9b\u89e3\u51b3\u65b9\u6848\u3002\u4f20\u7edf\u6574\u6570\u91cf\u5316\u65b9\u6cd5\u5df2\u5728\u6743\u91cd\u548c\u6fc0\u6d3b\u503c\u5904\u7406\u4e2d\u8bc1\u660e\u5176\u6709\u6548\u6027\uff0c\u4f46\u5728\u5e94\u7528\u6ce8\u610f\u529b\u673a\u5236\u65f6\uff0c\u5927\u591a\u6570\u65b9\u6cd5\u4ecd\u9700\u8981\u5bf9\u67e5\u8be2(Q)\u3001\u952e(K)\u548c\u503c(V)\u77e9\u9635\u8fdb\u884c\u90e8\u5206\u53cd\u91cf\u5316\u64cd\u4f5c\u3002<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/s6.51cto.com\/oss\/202412\/25\/482ba5e896898736406475a9c873b0d471d59d.webp\" data-type=\"block\" \/><\/p>\n<p>\u6e10\u8fdb\u5f0f\u91cf\u5316(PQ)\u6280\u672f\u6e90\u81ea\u8fd1\u671f\u7814\u7a76\u5de5\u4f5c\uff08\u5982Lin\u7b49\u4eba2024\u5e74\u63d0\u51fa\u7684Qserve\uff09\uff0c\u91c7\u7528\u4e24\u7ea7\u5904\u7406\u65b9\u6848\uff1a<\/p>\n<h4>\u7b2c\u4e00\u7ea7\uff1a\u5bf9\u79f0INT8\u91cf\u5316<\/h4>\n<p>\u5c06\u539f\u59cbFP16\u6216FP32\u6570\u503c\u6620\u5c04\u81f3\u96f6\u70b9\u4e3a\u7684INT8\u533a\u95f4\uff0c\u4ee5\u907f\u514d\u77e9\u9635\u4e58\u6cd5\u4e2d\u7684\u989d\u5916\u8ba1\u7b97\u5f00\u9500\u3002\u8be5\u9636\u6bb5\u540c\u65f6\u4fdd\u5b58\u6bd4\u4f8b\u56e0\u5b50\uff08\u6d6e\u70b9\u503c\uff09\u548c\u91cf\u5316\u540e\u7684\u6574\u6570\u6570\u636e\u3002<\/p>\n<h4>\u7b2c\u4e8c\u7ea7\uff1a\u975e\u5bf9\u79f0INT4\u91cf\u5316<\/h4>\n<p>\u5c06INT8\u8868\u793a\u8fdb\u4e00\u6b65\u538b\u7f29\u81f3INT4\u7cbe\u5ea6\uff0c\u9700\u8981\u5f15\u5165\u96f6\u70b9\u3002\u867d\u7136\u975e\u5bf9\u79f0\u91cf\u5316\u5728\u4e58\u6cd5\u8fd0\u7b97\u4e2d\u5f15\u5165\u4e86\u989d\u5916\u9879\uff0c\u4f46\u7531\u4e8e\u5927\u90e8\u5206\u6570\u636e\u4ee5\u538b\u7f29\u683c\u5f0f\u5904\u7406\uff0c\u4ec5\u5728\u5fc5\u8981\u65f6\u8fdb\u884c\u90e8\u5206\u5c55\u5f00\uff0c\u56e0\u6b64\u603b\u4f53\u5f00\u9500\u5f97\u5230\u6709\u6548\u63a7\u5236\u3002<\/p>\n<p>\u6e10\u8fdb\u5f0f\u91cf\u5316\u7684\u6570\u5b66\u8868\u8fbe\u5f0f\u4e3a\uff1a<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/s6.51cto.com\/oss\/202412\/25\/d48a8e824988eab178a35161fce91bb8c39c04.webp\" data-type=\"block\" \/><\/p>\n<p>\u5176\u4e2d\u548c\u5728INT8\u548cINT4\u9636\u6bb5\u53ef\u91c7\u7528\u4e0d\u540c\u503c\u3002\u6700\u7ec8\u7684\u6574\u6570\u63a8\u7406\u8ba1\u7b97\u516c\u5f0f\uff08\u57fa\u4e8esnippet\u4e2d\u7684\u7b49\u5f0f7\u548c8\u63a8\u5bfc\uff09\u4e3a\uff1a<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/s8.51cto.com\/oss\/202412\/25\/82672f8106aa77776940180f80a83a2d409c96.webp\" data-type=\"block\" \/><\/p>\n<p>\u5176\u4e2d\u548c\u8868\u793a\u90e8\u5206\u89e3\u538b\u4f46\u4ecd\u4fdd\u6301\u4f4e\u4f4d\u8868\u793a\u7684\u6570\u636e\u3002\u8fd9\u4e00\u7cfb\u5217\u64cd\u4f5c\u786e\u4fdd\u4e86\u6d6e\u70b9\u8fd0\u7b97\u5f00\u9500\u6700\u5c0f\u5316\uff0c\u540c\u65f6\u5b9e\u73b0\u663e\u8457\u7684\u5185\u5b58\u8282\u7701\u3002<\/p>\n<h3>\u6ce8\u610f\u529b\u5934\u4f18\u5148\u7ea7\u5dee\u5f02\u5316\u5904\u7406<\/h3>\n<p>\u91cf\u5316\u8fc7\u7a0b\u4e2d\u7684\u4e00\u4e2a\u91cd\u8981\u53d1\u73b0\u662f\uff0c\u4e0d\u540c\u6ce8\u610f\u529b\u5934\u5bf9\u7cbe\u5ea6\u635f\u5931\u7684\u654f\u611f\u5ea6\u5b58\u5728\u663e\u8457\u5dee\u5f02\u3002\u6765\u81eaPhi3-mini\u548cLLaMA3-8B\u6a21\u578b\u7684\u5b9e\u9a8c\u89c2\u5bdf\u8868\u660e\uff0c\u67e5\u8be2\u548c\u952e\u77e9\u9635\u4e2d\u67d0\u4e9b\u6ce8\u610f\u529b\u5934\u7684\u901a\u9053\u5177\u6709\u8f83\u5927\u5e45\u503c\uff0c\u8fc7\u5ea6\u538b\u7f29\u8fd9\u4e9b\u5934\u4f1a\u5bfc\u81f4\u6a21\u578b\u6027\u80fd\u4e0b\u964d\u3002<\/p>\n<p>\u4e3a\u89e3\u51b3\u8fd9\u4e00\u95ee\u9898\uff0cTurboAttention\u5f15\u5165\u4e86\u6ce8\u610f\u529b\u5934\u4f18\u5148\u7ea7\u8ba1\u7b97\u673a\u5236\uff1a<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/s9.51cto.com\/oss\/202412\/25\/81171ec58a952aa33da765d2f53e9e90168521.webp\" data-type=\"block\" \/><\/p>\n<p>\u5176\u4e2d\u8868\u793a\u5934\u4e2d\u901a\u9053\u7684\u6700\u5927\u503c\u4e0e\u6700\u5c0f\u503c\u4e4b\u5dee\uff0c\u4e3a\u8fd9\u4e9b\u5dee\u503c\u7684\u6807\u51c6\u5dee\u3002\u4f18\u5148\u7ea7<strong>\u8f83\u9ad8<\/strong>\u7684\u5934\u5bf9\u4f4e\u4f4d\u91cf\u5316\u66f4\u4e3a\u654f\u611f\uff0c\u56e0\u6b64\u4fdd\u6301INT4\u7cbe\u5ea6\uff0c\u800c\u4f4e\u4f18\u5148\u7ea7\u5934\u53ef\u8fdb\u4e00\u6b65\u538b\u7f29\u81f3INT2\u3002\u5177\u4f53\u5b9e\u73b0\u4e3a\uff1a<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/s5.51cto.com\/oss\/202412\/25\/293f04e37afad742beb594924d32d56110c5ce.webp\" data-type=\"block\" \/><\/p>\n<p>\u901a\u8fc7\u8fd9\u79cd\u65b9\u5f0f\uff0c\u5c11\u91cf\u5934\uff08\u7531\u53c2\u6570\u5b9a\u4e49\uff09\u63a5\u53d7\u66f4\u6fc0\u8fdb\u7684\u538b\u7f29\uff0c\u4f46\u6a21\u578b\u6574\u4f53\u6027\u80fd\u5f97\u4ee5\u4fdd\u6301\u3002\u8fd9\u79cd\u7cbe\u7ec6\u5316\u7684\u91cf\u5316\u7b56\u7565\u76f8\u6bd4\u7edf\u4e00\u91cf\u5316\u65b9\u6848\u83b7\u5f97\u4e86\u66f4\u597d\u7684\u538b\u7f29\u6548\u679c\u3002<\/p>\n<h2>3\u3001TurboAttention\u5b9e\u73b0\u67b6\u6784<\/h2>\n<p><img decoding=\"async\" src=\"https:\/\/s6.51cto.com\/oss\/202412\/25\/09405b060398af29d56121b775282ad947366e.webp\" data-type=\"block\" \/><\/p>\n<p>TurboAttention\u7684\u5b9e\u73b0\u6d89\u53ca\u591a\u4e2a\u6838\u5fc3\u6a21\u5757\uff1a\u57fa\u4e8e\u591a\u9879\u5f0f\u7684\u8f6f\u6700\u5927\u503c\u8fd1\u4f3c\u6a21\u5757\u548cQ\u3001K\u3001V\u77e9\u9635\u7684\u6e10\u8fdb\u5f0f\u91cf\u5316\u5904\u7406\u6a21\u5757\u3002\u4e0b\u9762\u63d0\u4f9b\u57fa\u4e8ePyTorch\u7684\u5b9e\u73b0\u793a\u4f8b\u3002<\/p>\n<p>TurboAttention\u7684\u5b9e\u73b0\u6d89\u53ca\u591a\u4e2a\u6838\u5fc3\u6a21\u5757\uff1a\u57fa\u4e8e\u591a\u9879\u5f0f\u7684\u8f6f\u6700\u5927\u503c\u8fd1\u4f3c\u6a21\u5757\u548cQ\u3001K\u3001V\u77e9\u9635\u7684\u6e10\u8fdb\u5f0f\u91cf\u5316\u5904\u7406\u6a21\u5757\u3002\u4e0b\u9762\u63d0\u4f9b\u57fa\u4e8ePyTorch\u7684\u5b9e\u73b0\u793a\u4f8b\u3002<\/p>\n<p><strong>\u8bf4\u660e\uff1a<\/strong>\u00a0\u793a\u4f8b\u4ee3\u7801\u96c6\u6210\u4e86\u7a00\u758f\u6ce8\u610f\u529b\u3001\u591a\u9879\u5f0f\u6307\u6570\u8fd1\u4f3c\u548c\u90e8\u5206\u91cf\u5316\u7b49\u6838\u5fc3\u601d\u60f3\u3002\u4e3a\u4fdd\u6301\u4ee3\u7801\u53ef\u8bfb\u6027\uff0c\u67d0\u4e9b\u5b9e\u73b0\u7ec6\u8282\uff08\u5982\u591a\u9879\u5f0f\u8fd1\u4f3c\u7684\u5177\u4f53\u5b9e\u73b0\uff09\u8fdb\u884c\u4e86\u9002\u5f53\u7b80\u5316\u3002<\/p>\n<div>\n<div class=\"hljs-cto\">\n<div class=\"hljs-cto\"><button class=\"copy_btn disable\" data-clipboard-target=\"#code_id_0\">\u590d\u5236<\/button><\/p>\n<div class=\"code-toolbar\">\n<pre class=\"has-pre-numbering language-plain\" tabindex=\"0\"><code class=\"language-plain\">import torch  \r\n import torch.nn as nn  \r\n import torch.nn.functional as F  \r\n import math  \r\n   \r\n class TurboAttention(nn.Module):  \r\n     def __init__(self, embed_dim, num_heads, sparse_ratio=0.1):  \r\n         super(TurboAttention, self).__init__()  \r\n         self.embed_dim = embed_dim  \r\n         self.num_heads = num_heads  \r\n         self.sparse_ratio = sparse_ratio  \r\n         self.head_dim = embed_dim \/\/ num_heads  \r\n   \r\n         assert (  \r\n             self.head_dim * num_heads == embed_dim  \r\n        ), \"\u5d4c\u5165\u7ef4\u5ea6\u5fc5\u987b\u80fd\u88ab\u6ce8\u610f\u529b\u5934\u6570\u6574\u9664\"  \r\n           \r\n         # \u5b9a\u4e49\u7ebf\u6027\u6295\u5f71\u5c42  \r\n         self.q_proj = nn.Linear(embed_dim, embed_dim)  \r\n         self.k_proj = nn.Linear(embed_dim, embed_dim)  \r\n         self.v_proj = nn.Linear(embed_dim, embed_dim)  \r\n           \r\n         # \u5b9a\u4e49\u8f93\u51fa\u6295\u5f71\u5c42  \r\n         self.out_proj = nn.Linear(embed_dim, embed_dim)  \r\n           \r\n         # \u5b9a\u4e49e^-x\u8fd1\u4f3c\u7684\u591a\u9879\u5f0f\u7cfb\u6570 (SAS)  \r\n         # P(x) = a3*x^3 + a2*x^2 + a1*x + a0  \r\n         self.poly_a3 = -0.1025  \r\n         self.poly_a2 = 0.4626  \r\n         self.poly_a1 = -0.9922  \r\n         self.poly_a0 = 0.9996  \r\n   \r\n     def forward(self, x):  \r\n         batch_size, seq_length, embed_dim = x.size()  \r\n           \r\n         # \u7b2c1\u6b65\uff1a\u6267\u884c\u7ebf\u6027\u6295\u5f71\u5e76\u53ef\u9009\u8fdb\u884c\u91cf\u5316  \r\n         Q_fp = self.q_proj(x)  \r\n         K_fp = self.k_proj(x)  \r\n         V_fp = self.v_proj(x)  \r\n           \r\n         # \u6ce8\uff1a\u6b64\u5904\u7701\u7565\u6e10\u8fdb\u5f0f\u91cf\u5316\u5b9e\u73b0\u4ee3\u7801  \r\n         # \u5b9e\u9645\u5e94\u7528\u4e2d\u9700\u8981\u5c06Q\u3001K\u3001V\u91cf\u5316\u4e3a\u4f4e\u4f4d\u683c\u5f0f  \r\n         # \u5e76\u5728\u9700\u8981\u65f6\u8fdb\u884c\u90e8\u5206\u53cd\u91cf\u5316\u4ee5\u652f\u6301\u77e9\u9635\u4e58\u6cd5  \r\n           \r\n         # \u91cd\u6392\u5f20\u91cf\u4ee5\u652f\u6301\u591a\u5934\u6ce8\u610f\u529b\u8ba1\u7b97  \r\n         Q = Q_fp.view(batch_size, seq_length, self.num_heads, self.head_dim).transpose(1, 2)  \r\n         K = K_fp.view(batch_size, seq_length, self.num_heads, self.head_dim).transpose(1, 2)  \r\n         V = V_fp.view(batch_size, seq_length, self.num_heads, self.head_dim).transpose(1, 2)  \r\n           \r\n         # \u7b2c2\u6b65\uff1a\u8ba1\u7b97\u7f29\u653e\u70b9\u79ef\u6ce8\u610f\u529b  \r\n         # \u4f7f\u7528\u591a\u9879\u5f0f\u8fd1\u4f3c\u66ff\u4ee3\u6807\u51c6\u6307\u6570\u51fd\u6570  \r\n         scores = torch.matmul(Q, K.transpose(-2, -1)) \/ math.sqrt(self.head_dim)  \r\n           \r\n         # \u5c06\u6ce8\u610f\u529b\u5206\u6570\u9650\u5236\u5728[0, 1]\u8303\u56f4\u5185\u4ee5\u9002\u5e94\u591a\u9879\u5f0f\u8ba1\u7b97  \r\n         scores_clamped = torch.clamp(scores, 0, 1)  \r\n           \r\n         # \u4f7f\u7528\u591a\u9879\u5f0f\u8fd1\u4f3c\u8ba1\u7b97e^-x  \r\n         # softmax\u4e2d\u6839\u636e\u5206\u6570\u7b26\u53f7\u4f7f\u7528e^score\u6216e^-score  \r\n         # \u6b64\u5904\u5c55\u793ae^-x\u7684\u8fd1\u4f3c\u8ba1\u7b97  \r\n         exponent_approx = (  \r\n             self.poly_a3 * scores_clamped ** 3 +  \r\n             self.poly_a2 * scores_clamped ** 2 +  \r\n             self.poly_a1 * scores_clamped +  \r\n             self.poly_a0  \r\n        )  \r\n           \r\n         # \u7b2c3\u6b65\uff1a\u5b9e\u73b0top-k\u7a00\u758f\u5316  \r\n         top_k = max(1, int(seq_length * self.sparse_ratio))  \r\n         top_scores, _ = torch.topk(scores, top_k, dim=-1)  \r\n         threshold = top_scores[:, :, :, -1].unsqueeze(-1)  \r\n         mask = (scores &gt;= threshold)  \r\n           \r\n         # \u5c06\u591a\u9879\u5f0f\u8fd1\u4f3c\u7ed3\u679c\u8f6c\u6362\u4e3a\u5e26\u63a9\u7801\u7684\u6ce8\u610f\u529b\u5206\u5e03  \r\n         exponent_approx = exponent_approx.masked_fill(~mask, float('-inf'))  \r\n           \r\n         # \u7b2c4\u6b65\uff1a\u6267\u884csoftmax\u5f52\u4e00\u5316  \r\n         attn = F.softmax(exponent_approx, dim=-1)  \r\n           \r\n         # \u7b2c5\u6b65\uff1a\u5e94\u7528dropout\u8fdb\u884c\u6b63\u5219\u5316  \r\n         attn = F.dropout(attn, p=0.1, training=self.training)  \r\n           \r\n         # \u7b2c6\u6b65\uff1a\u8ba1\u7b97\u6ce8\u610f\u529b\u52a0\u6743\u548c  \r\n         context = torch.matmul(attn, V)  \r\n           \r\n         # \u6062\u590d\u539f\u59cb\u5f20\u91cf\u5f62\u72b6  \r\n         context = context.transpose(1, 2).contiguous().view(batch_size, seq_length, embed_dim)  \r\n         out = self.out_proj(context)  \r\n           \r\n         return out<\/code><\/pre>\n<ul id=\"code_id_0\" class=\"pre-numbering\">\n<li>1.<\/li>\n<li>2.<\/li>\n<li>3.<\/li>\n<li>4.<\/li>\n<li>5.<\/li>\n<li>6.<\/li>\n<li>7.<\/li>\n<li>8.<\/li>\n<li>9.<\/li>\n<li>10.<\/li>\n<li>11.<\/li>\n<li>12.<\/li>\n<li>13.<\/li>\n<li>14.<\/li>\n<li>15.<\/li>\n<li>16.<\/li>\n<li>17.<\/li>\n<li>18.<\/li>\n<li>19.<\/li>\n<li>20.<\/li>\n<li>21.<\/li>\n<li>22.<\/li>\n<li>23.<\/li>\n<li>24.<\/li>\n<li>25.<\/li>\n<li>26.<\/li>\n<li>27.<\/li>\n<li>28.<\/li>\n<li>29.<\/li>\n<li>30.<\/li>\n<li>31.<\/li>\n<li>32.<\/li>\n<li>33.<\/li>\n<li>34.<\/li>\n<li>35.<\/li>\n<li>36.<\/li>\n<li>37.<\/li>\n<li>38.<\/li>\n<li>39.<\/li>\n<li>40.<\/li>\n<li>41.<\/li>\n<li>42.<\/li>\n<li>43.<\/li>\n<li>44.<\/li>\n<li>45.<\/li>\n<li>46.<\/li>\n<li>47.<\/li>\n<li>48.<\/li>\n<li>49.<\/li>\n<li>50.<\/li>\n<li>51.<\/li>\n<li>52.<\/li>\n<li>53.<\/li>\n<li>54.<\/li>\n<li>55.<\/li>\n<li>56.<\/li>\n<li>57.<\/li>\n<li>58.<\/li>\n<li>59.<\/li>\n<li>60.<\/li>\n<li>61.<\/li>\n<li>62.<\/li>\n<li>63.<\/li>\n<li>64.<\/li>\n<li>65.<\/li>\n<li>66.<\/li>\n<li>67.<\/li>\n<li>68.<\/li>\n<li>69.<\/li>\n<li>70.<\/li>\n<li>71.<\/li>\n<li>72.<\/li>\n<li>73.<\/li>\n<li>74.<\/li>\n<li>75.<\/li>\n<li>76.<\/li>\n<li>77.<\/li>\n<li>78.<\/li>\n<li>79.<\/li>\n<li>80.<\/li>\n<li>81.<\/li>\n<li>82.<\/li>\n<li>83.<\/li>\n<li>84.<\/li>\n<li>85.<\/li>\n<li>86.<\/li>\n<li>87.<\/li>\n<li>88.<\/li>\n<li>89.<\/li>\n<\/ul>\n<div class=\"toolbar\"><\/div>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n<p>TurboAttention\u53ef\u901a\u8fc7\u66ff\u6362\u6807\u51c6\u591a\u5934\u6ce8\u610f\u529b\u6a21\u5757\uff08\u5982nn.MultiheadAttention\uff09\u7684\u65b9\u5f0f\u96c6\u6210\u5230PyTorch Transformer\u67b6\u6784\u4e2d\uff1a<\/p>\n<div>\n<div class=\"hljs-cto\">\n<div class=\"hljs-cto\"><button class=\"copy_btn disable\" data-clipboard-target=\"#code_id_1\">\u590d\u5236<\/button><\/p>\n<div class=\"code-toolbar\">\n<pre class=\"has-pre-numbering language-plain\" tabindex=\"0\"><code class=\"language-plain\">class TransformerBlock(nn.Module):  \r\n     def __init__(self, embed_dim, num_heads):  \r\n         super(TransformerBlock, self).__init__()  \r\n         self.attention = TurboAttention(embed_dim, num_heads)  \r\n         self.layer_norm1 = nn.LayerNorm(embed_dim)  \r\n         self.feed_forward = nn.Sequential(  \r\n             nn.Linear(embed_dim, embed_dim * 4),  \r\n             nn.ReLU(),  \r\n             nn.Linear(embed_dim * 4, embed_dim)  \r\n        )  \r\n         self.layer_norm2 = nn.LayerNorm(embed_dim)  \r\n   \r\n     def forward(self, x):  \r\n         # \u6ce8\u610f\u529b\u5c42\u8ba1\u7b97  \r\n         attn_out = self.attention(x)  \r\n         x = self.layer_norm1(x + attn_out)  \r\n   \r\n         # \u524d\u9988\u7f51\u7edc\u8ba1\u7b97  \r\n         ff_out = self.feed_forward(x)  \r\n         x = self.layer_norm2(x + ff_out)  \r\n   \r\n         return x<\/code><\/pre>\n<ul id=\"code_id_1\" class=\"pre-numbering\">\n<li>1.<\/li>\n<li>2.<\/li>\n<li>3.<\/li>\n<li>4.<\/li>\n<li>5.<\/li>\n<li>6.<\/li>\n<li>7.<\/li>\n<li>8.<\/li>\n<li>9.<\/li>\n<li>10.<\/li>\n<li>11.<\/li>\n<li>12.<\/li>\n<li>13.<\/li>\n<li>14.<\/li>\n<li>15.<\/li>\n<li>16.<\/li>\n<li>17.<\/li>\n<li>18.<\/li>\n<li>19.<\/li>\n<li>20.<\/li>\n<li>21.<\/li>\n<li>22.<\/li>\n<\/ul>\n<div class=\"toolbar\"><\/div>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n<h3>\u751f\u4ea7\u73af\u5883\u90e8\u7f72\u65b9\u6848<\/h3>\n<p>\u5728\u5de5\u7a0b\u5b9e\u8df5\u4e2d\uff0c\u9664\u7b97\u6cd5\u5b9e\u73b0\u5916\uff0cTurboAttention\u7684\u751f\u4ea7\u90e8\u7f72\u8fd8\u9700\u8981\u5b8c\u5584\u7684DevOps\u652f\u6301\u3002\u4e3b\u8981\u6280\u672f\u73af\u8282\u5305\u62ec\u5bb9\u5668\u5316\u7ba1\u7406\u3001\u670d\u52a1\u7f16\u6392\u548c\u5206\u5e03\u5f0f\u63a8\u7406\u5de5\u4f5c\u6d41\u8bbe\u8ba1\u3002<\/p>\n<h4>\u5bb9\u5668\u5316\u5b9e\u73b0<\/h4>\n<p>\u91c7\u7528Docker\u5b9e\u73b0\u73af\u5883\u4e00\u81f4\u6027\u7ba1\u7406\uff1a \u00a0 \u00a0# \u57fa\u7840\u955c\u50cf\u9009\u62e9 \u00a0 \u00a0 \u00a0FROM pytorch\/pytorch:1.12.1-cuda11.3-cudnn8-runtime<\/p>\n<div>\n<div class=\"hljs-cto\">\n<div class=\"hljs-cto\"><button class=\"copy_btn disable\" data-clipboard-target=\"#code_id_2\">\u590d\u5236<\/button><\/p>\n<div class=\"code-toolbar\">\n<pre class=\"has-pre-numbering language-plain\" tabindex=\"0\"><code class=\"language-plain\"># \u73af\u5883\u53d8\u91cf\u914d\u7f6e  \r\n ENV PYTHONDONTWRITEBYTECODE=1  \r\n ENV PYTHONUNBUFFERED=1  \r\n   \r\n # \u5de5\u4f5c\u76ee\u5f55\u8bbe\u7f6e  \r\n WORKDIR \/app  \r\n   \r\n # \u4f9d\u8d56\u9879\u5b89\u88c5  \r\n COPY requirements.txt .  \r\n RUN pip install --upgrade pip  \r\n RUN pip install -r requirements.txt  \r\n   \r\n # \u9879\u76ee\u6587\u4ef6\u590d\u5236  \r\n COPY . .  \r\n   \r\n # \u670d\u52a1\u542f\u52a8\u547d\u4ee4  \r\n CMD [\"python\", \"deploy_model.py\"]<\/code><\/pre>\n<ul id=\"code_id_2\" class=\"pre-numbering\">\n<li>1.<\/li>\n<li>2.<\/li>\n<li>3.<\/li>\n<li>4.<\/li>\n<li>5.<\/li>\n<li>6.<\/li>\n<li>7.<\/li>\n<li>8.<\/li>\n<li>9.<\/li>\n<li>10.<\/li>\n<li>11.<\/li>\n<li>12.<\/li>\n<li>13.<\/li>\n<li>14.<\/li>\n<li>15.<\/li>\n<li>16.<\/li>\n<li>17.<\/li>\n<\/ul>\n<div class=\"toolbar\"><\/div>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n<p>\u4f9d\u8d56\u914d\u7f6e\u6587\u4ef6requirements.txt\u5185\u5bb9\u793a\u4f8b\uff1a<\/p>\n<div>\n<div class=\"hljs-cto\">\n<div class=\"hljs-cto\"><button class=\"copy_btn disable\" data-clipboard-target=\"#code_id_3\">\u590d\u5236<\/button><\/p>\n<div class=\"code-toolbar\">\n<pre class=\"has-pre-numbering language-plain\" tabindex=\"0\"><code class=\"language-plain\">torch==1.12.1  \r\n    torchvisinotallow==0.13.1  \r\n    flask==2.0.3  \r\n    gunicorn==20.1.0<\/code><\/pre>\n<ul id=\"code_id_3\" class=\"pre-numbering\">\n<li>1.<\/li>\n<li>2.<\/li>\n<li>3.<\/li>\n<li>4.<\/li>\n<\/ul>\n<div class=\"toolbar\"><\/div>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n<h4>\u670d\u52a1\u7f16\u6392\u914d\u7f6e<\/h4>\n<p>\u4f7f\u7528Kubernetes\u5b9e\u73b0\u81ea\u52a8\u5316\u90e8\u7f72\u548c\u5f39\u6027\u4f38\u7f29\uff1a<\/p>\n<div>\n<div class=\"hljs-cto\">\n<div class=\"hljs-cto\"><button class=\"copy_btn disable\" data-clipboard-target=\"#code_id_4\">\u590d\u5236<\/button><\/p>\n<div class=\"code-toolbar\">\n<pre class=\"has-pre-numbering language-plain\" tabindex=\"0\"><code class=\"language-plain\">apiVersion: apps\/v1  \r\n     kind: Deployment  \r\n     metadata:  \r\n       name: turboattention-deployment  \r\n     spec:  \r\n       replicas: 3  \r\n       selector:  \r\n         matchLabels:  \r\n           app: turboattention  \r\n       template:  \r\n         metadata:  \r\n           labels:  \r\n             app: turboattention  \r\n         spec:  \r\n           containers:  \r\n           - name: turboattention-container  \r\n             image: your-docker-repo\/turboattention:latest  \r\n             ports:  \r\n             - containerPort: 8000  \r\n             resources:  \r\n               limits:  \r\n                 memory: \"2Gi\"  \r\n                 cpu: \"1\"  \r\n               requests:  \r\n                 memory: \"1Gi\"  \r\n                 cpu: \"0.5\"  \r\n     ---  \r\n     apiVersion: v1  \r\n     kind: Service  \r\n     metadata:  \r\n       name: turboattention-service  \r\n     spec:  \r\n       selector:  \r\n         app: turboattention  \r\n       ports:  \r\n         - protocol: TCP  \r\n           port: 80  \r\n           targetPort: 8000  \r\n       type: LoadBalancer<\/code><\/pre>\n<ul id=\"code_id_4\" class=\"pre-numbering\">\n<li>1.<\/li>\n<li>2.<\/li>\n<li>3.<\/li>\n<li>4.<\/li>\n<li>5.<\/li>\n<li>6.<\/li>\n<li>7.<\/li>\n<li>8.<\/li>\n<li>9.<\/li>\n<li>10.<\/li>\n<li>11.<\/li>\n<li>12.<\/li>\n<li>13.<\/li>\n<li>14.<\/li>\n<li>15.<\/li>\n<li>16.<\/li>\n<li>17.<\/li>\n<li>18.<\/li>\n<li>19.<\/li>\n<li>20.<\/li>\n<li>21.<\/li>\n<li>22.<\/li>\n<li>23.<\/li>\n<li>24.<\/li>\n<li>25.<\/li>\n<li>26.<\/li>\n<li>27.<\/li>\n<li>28.<\/li>\n<li>29.<\/li>\n<li>30.<\/li>\n<li>31.<\/li>\n<li>32.<\/li>\n<li>33.<\/li>\n<li>34.<\/li>\n<li>35.<\/li>\n<li>36.<\/li>\n<li>37.<\/li>\n<li>38.<\/li>\n<li>39.<\/li>\n<\/ul>\n<div class=\"toolbar\"><\/div>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n<h4>\u5de5\u4f5c\u6d41\u81ea\u52a8\u5316<\/h4>\n<p>\u57fa\u4e8eAirflow\u5b9e\u73b0\u6a21\u578b\u66f4\u65b0\u548c\u90e8\u7f72\u81ea\u52a8\u5316\uff1a<\/p>\n<div>\n<div class=\"hljs-cto\">\n<div class=\"hljs-cto\"><button class=\"copy_btn disable\" data-clipboard-target=\"#code_id_5\">\u590d\u5236<\/button><\/p>\n<div class=\"code-toolbar\">\n<pre class=\"has-pre-numbering language-plain\" tabindex=\"0\"><code class=\"language-plain\">from airflow import DAG  \r\n from airflow.operators.bash import BashOperator  \r\n from datetime import datetime  \r\n \r\n default_args = {  \r\n     'owner': 'airflow',  \r\n     'start_date': datetime(2023, 1, 1),  \r\n }  \r\n   \r\n with DAG('deploy_turboattention', default_args=default_args, schedule_interval='@daily') as dag:  \r\n     build_docker = BashOperator(  \r\n         task_id='build_docker_image',  \r\n         bash_command='docker build -t your-docker-repo\/turboattention:latest .'  \r\n    )  \r\n     push_docker = BashOperator(  \r\n         task_id='push_docker_image',  \r\n         bash_command='docker push your-docker-repo\/turboattention:latest'  \r\n    )  \r\n     update_kubernetes = BashOperator(  \r\n         task_id='update_kubernetes_deployment',  \r\n         bash_command='kubectl apply -f k8s-deployment.yaml'  \r\n    )  \r\n   \r\n     # \u5b9a\u4e49\u4efb\u52a1\u6267\u884c\u987a\u5e8f  \r\n     build_docker &gt;&gt; push_docker &gt;&gt; update_kubernetes# **\u6027\u80fd\u8bc4\u4f30\u65b9\u6cd5**<\/code><\/pre>\n<ul id=\"code_id_5\" class=\"pre-numbering\">\n<li>1.<\/li>\n<li>2.<\/li>\n<li>3.<\/li>\n<li>4.<\/li>\n<li>5.<\/li>\n<li>6.<\/li>\n<li>7.<\/li>\n<li>8.<\/li>\n<li>9.<\/li>\n<li>10.<\/li>\n<li>11.<\/li>\n<li>12.<\/li>\n<li>13.<\/li>\n<li>14.<\/li>\n<li>15.<\/li>\n<li>16.<\/li>\n<li>17.<\/li>\n<li>18.<\/li>\n<li>19.<\/li>\n<li>20.<\/li>\n<li>21.<\/li>\n<li>22.<\/li>\n<li>23.<\/li>\n<li>24.<\/li>\n<li>25.<\/li>\n<\/ul>\n<div class=\"toolbar\"><\/div>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n<p>TurboAttention\u7684\u6027\u80fd\u8bc4\u4f30\u9700\u8981\u4ece\u591a\u4e2a\u7ef4\u5ea6\u4e0e\u57fa\u51c6\u6ce8\u610f\u529b\u673a\u5236\u8fdb\u884c\u5bf9\u6bd4\uff0c\u5305\u62ec\u8ba1\u7b97\u901f\u5ea6\u3001\u7cbe\u5ea6\u3001\u5185\u5b58\u4f7f\u7528\u6548\u7387\u548c\u8fd0\u884c\u7a33\u5b9a\u6027\u7b49\u6307\u6807\u3002<\/p>\n<h2>4\u3001\u57fa\u51c6\u6d4b\u8bd5\u5b9e\u73b0<\/h2>\n<p>\u4ee5\u4e0b\u4ee3\u7801\u5c55\u793a\u4e86\u4e00\u79cd\u57fa\u4e8e\u5408\u6210\u6570\u636e\u7684\u6027\u80fd\u6d4b\u8bd5\u65b9\u6cd5\uff1a<\/p>\n<div>\n<div class=\"hljs-cto\">\n<div class=\"hljs-cto\"><button class=\"copy_btn disable\" data-clipboard-target=\"#code_id_6\">\u590d\u5236<\/button><\/p>\n<div class=\"code-toolbar\">\n<pre class=\"has-pre-numbering language-plain\" tabindex=\"0\"><code class=\"language-plain\">import time  \r\n  import torch  \r\n def benchmark_attention(attention_layer, x):  \r\n     start_time = time.time()  \r\n     for _ in range(100):  \r\n         output = attention_layer(x)  \r\n     end_time = time.time()  \r\n     avg_time = (end_time - start_time) \/ 100  \r\n     return avg_time  \r\n   \r\n # \u6784\u9020\u6d4b\u8bd5\u6570\u636e  \r\n batch_size = 32  \r\n seq_length = 512  \r\n embed_dim = 1024  \r\n x = torch.randn(batch_size, seq_length, embed_dim).cuda()  \r\n   \r\n # \u6807\u51c6\u6ce8\u610f\u529b\u673a\u5236\u6d4b\u8bd5  \r\n standard_attention = nn.MultiheadAttention(embed_dim, num_heads=8).cuda()  \r\n standard_time = benchmark_attention(standard_attention, x)  \r\n print(f\"\u6807\u51c6\u6ce8\u610f\u529b\u673a\u5236\u5e73\u5747\u6267\u884c\u65f6\u95f4\uff1a{standard_time:.6f}\u79d2\")  \r\n   \r\n # TurboAttention\u6d4b\u8bd5  \r\n turbo_attention = TurboAttention(embed_dim, num_heads=8, sparse_ratio=0.1).cuda()  \r\n turbo_time = benchmark_attention(turbo_attention, x)  \r\n print(f\"TurboAttention\u5e73\u5747\u6267\u884c\u65f6\u95f4\uff1a{turbo_time:.6f}\u79d2\")<\/code><\/pre>\n<ul id=\"code_id_6\" class=\"pre-numbering\">\n<li>1.<\/li>\n<li>2.<\/li>\n<li>3.<\/li>\n<li>4.<\/li>\n<li>5.<\/li>\n<li>6.<\/li>\n<li>7.<\/li>\n<li>8.<\/li>\n<li>9.<\/li>\n<li>10.<\/li>\n<li>11.<\/li>\n<li>12.<\/li>\n<li>13.<\/li>\n<li>14.<\/li>\n<li>15.<\/li>\n<li>16.<\/li>\n<li>17.<\/li>\n<li>18.<\/li>\n<li>19.<\/li>\n<li>20.<\/li>\n<li>21.<\/li>\n<li>22.<\/li>\n<li>23.<\/li>\n<li>24.<\/li>\n<li>25.<\/li>\n<\/ul>\n<div class=\"toolbar\"><\/div>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n<p>\u5b9e\u9a8c\u7ed3\u679c\u663e\u793a\uff0cTurboAttention\u53ef\u5b9e\u73b01.5\u52303\u500d\u7684\u63a8\u7406\u901f\u5ea6\u63d0\u5347\uff0c\u5177\u4f53\u63d0\u5347\u5e45\u5ea6\u53d6\u51b3\u4e8e\u591a\u4e2a\u5173\u952e\u53c2\u6570\u7684\u914d\u7f6e\uff0c\u5982sparse_ratio\uff08\u7a00\u758f\u7387\uff09\u3001\u8f6f\u6700\u5927\u503c\u8fd1\u4f3c\u7684\u591a\u9879\u5f0f\u6b21\u6570\u4ee5\u53ca\u6e10\u8fdb\u5f0f\u91cf\u5316\u7684\u4f4d\u6df1\u5ea6\u8bbe\u7f6e\u3002\u91cd\u8981\u7684\u662f\uff0c\u8fd9\u79cd\u663e\u8457\u7684\u6027\u80fd\u63d0\u5347\u4ec5\u5e26\u6765\u5f88\u5c0f\u7684\u7cbe\u5ea6\u635f\u5931\uff08\u6839\u636e\u5177\u4f53\u5e94\u7528\u573a\u666f\uff0c\u7edd\u5bf9\u7cbe\u5ea6\u4e0b\u964d\u901a\u5e38\u63a7\u5236\u57281-2%\u4ee5\u5185\uff09\u3002<\/p>\n<h2>5\u3001\u6280\u672f\u53d1\u5c55\u65b9\u5411<\/h2>\n<p>TurboAttention\u4e3a\u5927\u89c4\u6a21\u6a21\u578b\u4f18\u5316\u5f00\u8f9f\u4e86\u65b0\u7684\u7814\u7a76\u65b9\u5411\uff1a<\/p>\n<h4>\u81ea\u9002\u5e94\u7a00\u758f\u5316\u673a\u5236<\/h4>\n<p>\u5f00\u53d1\u57fa\u4e8e\u4e0a\u4e0b\u6587\u7684\u52a8\u6001\u7a00\u758f\u7387\u8c03\u6574\u673a\u5236\u3002\u5bf9\u4e8e\u590d\u6742\u5ea6\u8f83\u9ad8\u7684\u8f93\u5165\u533a\u57df\u964d\u4f4e\u7a00\u758f\u5ea6\uff0c\u800c\u5bf9\u7b80\u5355\u533a\u57df\u91c7\u7528\u66f4\u6fc0\u8fdb\u7684\u526a\u679d\u7b56\u7565\u3002<\/p>\n<h4>\u9ad8\u9636\u8fd1\u4f3c\u65b9\u6cd5<\/h4>\n<p>\u7814\u7a76\u5206\u6bb5\u591a\u9879\u5f0f\u6216\u6df7\u5408\u67e5\u8868\u65b9\u6848\uff0c\u5728\u4fdd\u6301\u8ba1\u7b97\u6548\u7387\u7684\u540c\u65f6\u63d0\u9ad8\u6307\u6570\u51fd\u6570\u8fd1\u4f3c\u7cbe\u5ea6\u3002<\/p>\n<h4>\u8de8\u6a21\u6001\u6ce8\u610f\u529b\u4f18\u5316<\/h4>\n<p>\u968f\u7740\u591a\u6a21\u6001\u6a21\u578b\u7684\u666e\u53ca\uff0c\u9488\u5bf9\u4e0d\u540c\u6a21\u6001\u7279\u5f81\u7684\u591a\u9879\u5f0f\u8fd1\u4f3c\u65b9\u6cd5\u9700\u8981\u8fdb\u4e00\u6b65\u4f18\u5316\u3002<\/p>\n<h4>\u786c\u4ef6\u534f\u540c\u8bbe\u8ba1<\/h4>\n<p>\u4e0b\u4e00\u4ee3GPU\u6216AI\u4e13\u7528\u52a0\u901f\u5668\u53ef\u8003\u8651\u5728\u786c\u4ef6\u5c42\u9762\u76f4\u63a5\u652f\u6301\u591a\u9879\u5f0f\u8fd1\u4f3c\u8ba1\u7b97\u548c\u591a\u7ea7\u91cf\u5316\u64cd\u4f5c\u3002<\/p>\n<h4>\u8bbe\u5907\u7aef\u5b66\u4e60\u4f18\u5316<\/h4>\n<p>\u5229\u7528\u6e10\u8fdb\u5f0f\u91cf\u5316\u5e26\u6765\u7684\u5185\u5b58\u6548\u7387\u63d0\u5347\uff0c\u63a2\u7d22\u5728\u8d44\u6e90\u53d7\u9650\u8bbe\u5907\u4e0a\u5b9e\u73b0\u6a21\u578b\u5fae\u8c03\u548c\u4e2a\u6027\u5316\u9002\u914d\u3002<\/p>\n<h2>\u603b\u7ed3<\/h2>\n<p><strong>TurboAttention<\/strong>\u5728\u5927\u578b\u8bed\u8a00\u548c\u89c6\u89c9\u6a21\u578b\u7684\u6ce8\u610f\u529b\u673a\u5236\u4f18\u5316\u65b9\u9762\u5b9e\u73b0\u4e86\u91cd\u8981\u7a81\u7834\uff0c\u5176\u6838\u5fc3\u521b\u65b0\u5305\u62ec\uff1a<\/p>\n<p>\u2022\u00a0<strong>\u7a00\u758f\u6fc0\u6d3b\u8f6f\u6700\u5927\u503c\uff08SAS\uff09<\/strong>\uff1a\u901a\u8fc7\u591a\u9879\u5f0f\u8fd1\u4f3c\u548c\u91cd\u8981\u6027\u7b5b\u9009\uff0c\u663e\u8457\u964d\u4f4e\u4e86\u6307\u6570\u8fd0\u7b97\u5f00\u9500\u3002<\/p>\n<p>\u2022\u00a0<strong>\u6e10\u8fdb\u5f0f\u91cf\u5316\uff08PQ\uff09<\/strong>\uff1a\u91c7\u7528\u4e24\u9636\u6bb5\u91cf\u5316\u7b56\u7565\uff08INT8\u81f3INT4\/INT2\uff09\uff0c\u5b9e\u73b0\u4e86\u6709\u6548\u7684\u7cbe\u5ea6-\u6027\u80fd\u5e73\u8861\u3002<\/p>\n<p>\u2022\u00a0<strong>\u5dee\u5f02\u5316\u91cf\u5316\u7b56\u7565<\/strong>\uff1a\u57fa\u4e8e\u654f\u611f\u5ea6\u5206\u6790\u7684\u9009\u62e9\u6027\u538b\u7f29\u65b9\u6848\uff0c\u786e\u4fdd\u5173\u952e\u6ce8\u610f\u529b\u5934\u7684\u6027\u80fd\u4e0d\u53d7\u5f71\u54cd\u3002<\/p>\n<p>TurboAttention\u901a\u8fc7\u8fd9\u4e9b\u6280\u672f\u521b\u65b0\u663e\u8457\u964d\u4f4e\u4e86\u8ba1\u7b97\u548c\u5185\u5b58\u5f00\u9500\uff0c\u540c\u65f6\u4fdd\u6301\u4e86\u6ce8\u610f\u529b\u673a\u5236\u6355\u83b7\u4e0a\u4e0b\u6587\u4f9d\u8d56\u5173\u7cfb\u7684\u6838\u5fc3\u80fd\u529b\u3002<\/p>\n<p>\u5728\u5de5\u7a0b\u5b9e\u8df5\u4e2d\uff0c\u901a\u8fc7\u73b0\u4ee3DevOps\u5de5\u5177\u94fe\uff08Docker\u3001Kubernetes\u3001Airflow\u7b49\uff09\u7684\u652f\u6301\uff0cTurboAttention\u53ef\u5b9e\u73b0\u5e73\u7a33\u7684\u751f\u4ea7\u73af\u5883\u90e8\u7f72\u3002\u968f\u7740\u673a\u5668\u5b66\u4e60\u6280\u672f\u7684\u6301\u7eed\u53d1\u5c55\uff0c\u8fd9\u7c7b\u9ad8\u6548\u6ce8\u610f\u529b\u673a\u5236\u5c06\u5728\u964d\u4f4e\u5927\u89c4\u6a21\u6a21\u578b\u90e8\u7f72\u6210\u672c\u65b9\u9762\u53d1\u6325\u91cd\u8981\u4f5c\u7528\u3002\u91c7\u7528\u8fd9\u4e9b\u4f18\u5316\u6280\u672f\u7684\u7ec4\u7ec7\u53ef\u5728\u4fdd\u6301\u6a21\u578b\u6027\u80fd\u7684\u540c\u65f6\uff0c\u663e\u8457\u964d\u4f4e\u786c\u4ef6\u6295\u5165\u548c\u80fd\u6e90\u6d88\u8017\u3002<\/p>\n<p>\u6587\u7ae0\u6765\u81ea\uff1a51CTO<\/p>\n<p>&nbsp;<\/p>\n<\/div>\n<\/div>\n<div class=\"pvc_clear\"><\/div>\n<p id=\"pvc_stats_23712\" class=\"pvc_stats total_only  \" data-element-id=\"23712\" style=\"\"><i class=\"pvc-stats-icon medium\" aria-hidden=\"true\"><svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" version=\"1.0\" viewBox=\"0 0 502 315\" preserveAspectRatio=\"xMidYMid meet\"><g transform=\"translate(0,332) scale(0.1,-0.1)\" fill=\"\" stroke=\"none\"><path d=\"M2394 3279 l-29 -30 -3 -207 c-2 -182 0 -211 15 -242 39 -76 157 -76 196 0 15 31 17 60 15 243 l-3 209 -33 29 c-26 23 -41 29 -80 29 -41 0 -53 -5 -78 -31z\"\/><path d=\"M3085 3251 c-45 -19 -58 -50 -96 -229 -47 -217 -49 -260 -13 -295 52 -53 146 -42 177 20 16 31 87 366 87 410 0 70 -86 122 -155 94z\"\/><path d=\"M1751 3234 c-13 -9 -29 -31 -37 -50 -12 -29 -10 -49 21 -204 19 -94 39 -189 45 -210 14 -50 54 -80 110 -80 34 0 48 6 76 34 21 21 34 44 34 59 0 14 -18 113 -40 219 -37 178 -43 195 -70 221 -36 32 -101 37 -139 11z\"\/><path d=\"M1163 3073 c-36 -7 -73 -59 -73 -102 0 -56 133 -378 171 -413 34 -32 83 -37 129 -13 70 36 67 87 -16 290 -86 209 -89 214 -129 231 -35 14 -42 15 -82 7z\"\/><path d=\"M3689 3066 c-15 -9 -33 -30 -42 -48 -48 -103 -147 -355 -147 -375 0 -98 131 -148 192 -74 13 15 57 108 97 206 80 196 84 226 37 273 -30 30 -99 39 -137 18z\"\/><path d=\"M583 2784 c-38 -19 -67 -74 -58 -113 9 -42 211 -354 242 -373 16 -10 45 -18 66 -18 51 0 107 52 107 100 0 39 -1 41 -124 234 -80 126 -108 162 -133 173 -41 17 -61 16 -100 -3z\"\/><path d=\"M4250 2784 c-14 -9 -74 -91 -133 -183 -95 -150 -107 -173 -107 -213 0 -55 33 -94 87 -104 67 -13 90 8 211 198 130 202 137 225 78 284 -27 27 -42 34 -72 34 -22 0 -50 -8 -64 -16z\"\/><path d=\"M2275 2693 c-553 -48 -1095 -270 -1585 -649 -135 -104 -459 -423 -483 -476 -23 -49 -22 -139 2 -186 73 -142 361 -457 571 -626 285 -228 642 -407 990 -497 242 -63 336 -73 660 -74 310 0 370 5 595 52 535 111 1045 392 1455 803 122 121 250 273 275 326 19 41 19 137 0 174 -41 79 -309 363 -465 492 -447 370 -946 591 -1479 653 -113 14 -422 18 -536 8z m395 -428 c171 -34 330 -124 456 -258 112 -119 167 -219 211 -378 27 -96 24 -300 -5 -401 -72 -255 -236 -447 -474 -557 -132 -62 -201 -76 -368 -76 -167 0 -236 14 -368 76 -213 98 -373 271 -451 485 -162 444 86 934 547 1084 153 49 292 57 452 25z m909 -232 c222 -123 408 -262 593 -441 76 -74 138 -139 138 -144 0 -16 -233 -242 -330 -319 -155 -123 -309 -223 -461 -299 l-81 -41 32 46 c18 26 49 83 70 128 143 306 141 649 -6 957 -25 52 -61 116 -79 142 l-34 47 45 -20 c26 -10 76 -36 113 -56z m-2057 25 c-40 -58 -105 -190 -130 -263 -110 -324 -59 -707 132 -981 25 -35 42 -64 37 -64 -19 0 -241 119 -326 174 -188 122 -406 314 -532 468 l-58 71 108 103 c185 178 428 349 672 473 66 33 121 60 123 61 2 0 -10 -19 -26 -42z\"\/><path d=\"M2375 1950 c-198 -44 -350 -190 -395 -379 -18 -76 -8 -221 19 -290 114 -284 457 -406 731 -260 98 52 188 154 231 260 27 69 37 214 19 290 -38 163 -166 304 -326 360 -67 23 -215 33 -279 19z\"\/><\/g><\/svg><\/i> <img loading=\"lazy\" decoding=\"async\" width=\"16\" height=\"16\" alt=\"Loading\" src=\"https:\/\/aif.amtbbs.org\/wp-content\/plugins\/page-views-count\/ajax-loader-2x.gif\" border=0 \/><\/p>\n<div class=\"pvc_clear\"><\/div>\n","protected":false},"excerpt":{"rendered":"<p>\u968f\u7740\u5927\u578b\u8bed\u8a00\u6a21\u578b(LLMs)\u5728AI\u5e94\u7528\u9886\u57df\u6301\u7eed\u53d1\u5c55\uff0c\u5176\u8ba1\u7b97\u6210\u672c\u4e5f\u5448\u73b0\u663e\u8457\u4e0a\u5347\u8d8b\u52bf\u3002\u6570\u636e\u5206\u6790\u8868\u660e\uff0cGPT-4\u7684\u8fd0 [&hellip;]<\/p>\n<div class=\"pvc_clear\"><\/div>\n<p id=\"pvc_stats_23712\" class=\"pvc_stats total_only  \" data-element-id=\"23712\" style=\"\"><i class=\"pvc-stats-icon medium\" aria-hidden=\"true\"><svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" version=\"1.0\" viewBox=\"0 0 502 315\" preserveAspectRatio=\"xMidYMid meet\"><g transform=\"translate(0,332) scale(0.1,-0.1)\" fill=\"\" stroke=\"none\"><path d=\"M2394 3279 l-29 -30 -3 -207 c-2 -182 0 -211 15 -242 39 -76 157 -76 196 0 15 31 17 60 15 243 l-3 209 -33 29 c-26 23 -41 29 -80 29 -41 0 -53 -5 -78 -31z\"\/><path d=\"M3085 3251 c-45 -19 -58 -50 -96 -229 -47 -217 -49 -260 -13 -295 52 -53 146 -42 177 20 16 31 87 366 87 410 0 70 -86 122 -155 94z\"\/><path d=\"M1751 3234 c-13 -9 -29 -31 -37 -50 -12 -29 -10 -49 21 -204 19 -94 39 -189 45 -210 14 -50 54 -80 110 -80 34 0 48 6 76 34 21 21 34 44 34 59 0 14 -18 113 -40 219 -37 178 -43 195 -70 221 -36 32 -101 37 -139 11z\"\/><path d=\"M1163 3073 c-36 -7 -73 -59 -73 -102 0 -56 133 -378 171 -413 34 -32 83 -37 129 -13 70 36 67 87 -16 290 -86 209 -89 214 -129 231 -35 14 -42 15 -82 7z\"\/><path d=\"M3689 3066 c-15 -9 -33 -30 -42 -48 -48 -103 -147 -355 -147 -375 0 -98 131 -148 192 -74 13 15 57 108 97 206 80 196 84 226 37 273 -30 30 -99 39 -137 18z\"\/><path d=\"M583 2784 c-38 -19 -67 -74 -58 -113 9 -42 211 -354 242 -373 16 -10 45 -18 66 -18 51 0 107 52 107 100 0 39 -1 41 -124 234 -80 126 -108 162 -133 173 -41 17 -61 16 -100 -3z\"\/><path d=\"M4250 2784 c-14 -9 -74 -91 -133 -183 -95 -150 -107 -173 -107 -213 0 -55 33 -94 87 -104 67 -13 90 8 211 198 130 202 137 225 78 284 -27 27 -42 34 -72 34 -22 0 -50 -8 -64 -16z\"\/><path d=\"M2275 2693 c-553 -48 -1095 -270 -1585 -649 -135 -104 -459 -423 -483 -476 -23 -49 -22 -139 2 -186 73 -142 361 -457 571 -626 285 -228 642 -407 990 -497 242 -63 336 -73 660 -74 310 0 370 5 595 52 535 111 1045 392 1455 803 122 121 250 273 275 326 19 41 19 137 0 174 -41 79 -309 363 -465 492 -447 370 -946 591 -1479 653 -113 14 -422 18 -536 8z m395 -428 c171 -34 330 -124 456 -258 112 -119 167 -219 211 -378 27 -96 24 -300 -5 -401 -72 -255 -236 -447 -474 -557 -132 -62 -201 -76 -368 -76 -167 0 -236 14 -368 76 -213 98 -373 271 -451 485 -162 444 86 934 547 1084 153 49 292 57 452 25z m909 -232 c222 -123 408 -262 593 -441 76 -74 138 -139 138 -144 0 -16 -233 -242 -330 -319 -155 -123 -309 -223 -461 -299 l-81 -41 32 46 c18 26 49 83 70 128 143 306 141 649 -6 957 -25 52 -61 116 -79 142 l-34 47 45 -20 c26 -10 76 -36 113 -56z m-2057 25 c-40 -58 -105 -190 -130 -263 -110 -324 -59 -707 132 -981 25 -35 42 -64 37 -64 -19 0 -241 119 -326 174 -188 122 -406 314 -532 468 l-58 71 108 103 c185 178 428 349 672 473 66 33 121 60 123 61 2 0 -10 -19 -26 -42z\"\/><path d=\"M2375 1950 c-198 -44 -350 -190 -395 -379 -18 -76 -8 -221 19 -290 114 -284 457 -406 731 -260 98 52 188 154 231 260 27 69 37 214 19 290 -38 163 -166 304 -326 360 -67 23 -215 33 -279 19z\"\/><\/g><\/svg><\/i> <img loading=\"lazy\" decoding=\"async\" width=\"16\" height=\"16\" alt=\"Loading\" src=\"https:\/\/aif.amtbbs.org\/wp-content\/plugins\/page-views-count\/ajax-loader-2x.gif\" border=0 \/><\/p>\n<div class=\"pvc_clear\"><\/div>\n","protected":false},"author":56,"featured_media":23714,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[23,20,80],"tags":[124,986,1052],"class_list":["post-23712","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-23","category-20","category-80","tag-ai","tag-llm","tag-1052"],"_links":{"self":[{"href":"https:\/\/aif.amtbbs.org\/index.php\/wp-json\/wp\/v2\/posts\/23712","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/aif.amtbbs.org\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/aif.amtbbs.org\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/aif.amtbbs.org\/index.php\/wp-json\/wp\/v2\/users\/56"}],"replies":[{"embeddable":true,"href":"https:\/\/aif.amtbbs.org\/index.php\/wp-json\/wp\/v2\/comments?post=23712"}],"version-history":[{"count":1,"href":"https:\/\/aif.amtbbs.org\/index.php\/wp-json\/wp\/v2\/posts\/23712\/revisions"}],"predecessor-version":[{"id":23715,"href":"https:\/\/aif.amtbbs.org\/index.php\/wp-json\/wp\/v2\/posts\/23712\/revisions\/23715"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/aif.amtbbs.org\/index.php\/wp-json\/wp\/v2\/media\/23714"}],"wp:attachment":[{"href":"https:\/\/aif.amtbbs.org\/index.php\/wp-json\/wp\/v2\/media?parent=23712"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/aif.amtbbs.org\/index.php\/wp-json\/wp\/v2\/categories?post=23712"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/aif.amtbbs.org\/index.php\/wp-json\/wp\/v2\/tags?post=23712"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}