{"id":51229,"date":"2025-08-10T19:24:29","date_gmt":"2025-08-10T11:24:29","guid":{"rendered":"https:\/\/www.wsisp.com\/helps\/51229.html"},"modified":"2025-08-10T19:24:29","modified_gmt":"2025-08-10T11:24:29","slug":"codegen%ef%bc%9a%e9%9d%a2%e5%90%91%e5%a4%9a%e8%bd%ae%e7%a8%8b%e5%ba%8f%e5%90%88%e6%88%90%e7%9a%84%e5%bc%80%e6%ba%90%e4%bb%a3%e7%a0%81%e5%a4%a7%e8%af%ad%e8%a8%80%e6%a8%a1%e5%9e%8b","status":"publish","type":"post","link":"https:\/\/www.wsisp.com\/helps\/51229.html","title":{"rendered":"CodeGen\uff1a\u9762\u5411\u591a\u8f6e\u7a0b\u5e8f\u5408\u6210\u7684\u5f00\u6e90\u4ee3\u7801\u5927\u8bed\u8a00\u6a21\u578b"},"content":{"rendered":"<p>\u672c\u6587\u7531\u300c\u5927\u5343AI\u52a9\u624b\u300d\u539f\u521b\u53d1\u5e03&#xff0c;\u4e13\u6ce8\u7528\u771f\u8bdd\u8bb2AI&#xff0c;\u56de\u5f52\u6280\u672f\u672c\u8d28\u3002\u62d2\u7edd\u795e\u8bdd\u6216\u5996\u9b54\u5316\u3002\u641c\u7d22\u300c\u5927\u5343AI\u52a9\u624b\u300d\u5173\u6ce8\u6211&#xff0c;\u4e00\u8d77\u6495\u6389\u8fc7\u5ea6\u5305\u88c5&#xff0c;\u5b66\u4e60\u771f\u5b9e\u7684AI\u6280\u672f&#xff01;<\/p>\n<h5>1. \u80cc\u666f\u4e0e\u6838\u5fc3\u8d21\u732e<\/h5>\n<p>\u7a0b\u5e8f\u5408\u6210&#xff08;Program Synthesis&#xff09; \u7684\u76ee\u6807\u662f\u6839\u636e\u7528\u6237\u610f\u56fe&#xff08;\u81ea\u7136\u8bed\u8a00\u63cf\u8ff0\u3001\u8f93\u5165\u8f93\u51fa\u793a\u4f8b\u7b49&#xff09;\u81ea\u52a8\u751f\u6210\u53ef\u6267\u884c\u4ee3\u7801\u3002\u4f20\u7edf\u65b9\u6cd5\u9762\u4e34\u4e24\u5927\u6311\u6218&#xff1a;<\/p>\n<ul>\n<li>\u641c\u7d22\u7a7a\u95f4\u7206\u70b8&#xff1a;\u901a\u7528\u7f16\u7a0b\u8bed\u8a00&#xff08;\u5982Python&#xff09;\u7684\u8868\u8fbe\u5f0f\u7ec4\u5408\u7a7a\u95f4\u5de8\u5927&#xff0c;\u96be\u4ee5\u9ad8\u6548\u904d\u5386&#xff1b;<\/li>\n<li>\u610f\u56fe\u6b67\u4e49&#xff1a;\u81ea\u7136\u8bed\u8a00\u63cf\u8ff0\u7684\u4e0d\u7cbe\u786e\u6027\u5bfc\u81f4\u751f\u6210\u4ee3\u7801\u504f\u79bb\u7528\u6237\u771f\u5b9e\u9700\u6c42\u3002<\/li>\n<\/ul>\n<p>CodeGen \u7531 Salesforce Research \u4e8e 2022 \u5e74\u63d0\u51fa&#xff0c;\u901a\u8fc7 \u591a\u8f6e\u7a0b\u5e8f\u5408\u6210\u8303\u5f0f \u89e3\u51b3\u4e0a\u8ff0\u95ee\u9898&#xff1a;<\/p>\n<ul>\n<li>\u5f00\u6e90\u6a21\u578b\u5bb6\u65cf&#xff1a;\u53d1\u5e03\u53c2\u6570\u91cf\u4e3a 350M\/2.7B\/6.1B\/16.1B \u7684\u81ea\u56de\u5f52 Transformer \u6a21\u578b&#xff0c;\u652f\u6301\u81ea\u7136\u8bed\u8a00\u4e0e\u4ee3\u7801\u6df7\u5408\u751f\u6210&#xff1b;<\/li>\n<li>\u591a\u8f6e\u4ea4\u4e92\u521b\u65b0&#xff1a;\u7528\u6237\u53ef\u9010\u6b65\u7528\u81ea\u7136\u8bed\u8a00\u63cf\u8ff0\u5b50\u4efb\u52a1&#xff0c;\u6a21\u578b\u5206\u6b65\u751f\u6210\u5b50\u7a0b\u5e8f\u5e76\u7ec4\u5408&#xff08;\u5982\u5148\u5b9a\u4e49\u51fd\u6570\u6846\u67b6&#xff0c;\u518d\u586b\u5145\u903b\u8f91&#xff09;&#xff1b;<\/li>\n<li>\u5f00\u6e90\u751f\u6001&#xff1a;\u516c\u5f00\u8bad\u7ec3\u5e93 JAXFORMER \u53ca\u6a21\u578b\u6743\u91cd&#xff0c;\u9996\u6b21\u63d0\u4f9b\u4e0e OpenAI Codex \u7ade\u4e89\u7684\u5f00\u6e90\u66ff\u4ee3\u65b9\u6848\u3002<\/li>\n<\/ul>\n<p>\u672c\u6587\u7531\u300c\u5927\u5343AI\u52a9\u624b\u300d\u539f\u521b\u53d1\u5e03&#xff0c;\u4e13\u6ce8\u7528\u771f\u8bdd\u8bb2AI&#xff0c;\u56de\u5f52\u6280\u672f\u672c\u8d28\u3002\u62d2\u7edd\u795e\u8bdd\u6216\u5996\u9b54\u5316\u3002\u641c\u7d22\u300c\u5927\u5343AI\u52a9\u624b\u300d\u5173\u6ce8\u6211&#xff0c;\u4e00\u8d77\u6495\u6389\u8fc7\u5ea6\u5305\u88c5&#xff0c;\u5b66\u4e60\u771f\u5b9e\u7684AI\u6280\u672f&#xff01;<\/p>\n<p>\u5f80\u671f\u6587\u7ae0\u63a8\u8350:<\/p>\n<ul>\n<li>20.\u675f\u641c\u7d22&#xff08;Beam Search&#xff09;&#xff1a;\u539f\u7406\u3001\u6f14\u8fdb\u4e0e\u6311\u6218<\/li>\n<li>19.RAGFoundry&#xff1a;\u9762\u5411\u68c0\u7d22\u589e\u5f3a\u751f\u6210\u7684\u6a21\u5757\u5316\u589e\u5f3a\u6846\u67b6<\/li>\n<li>18.TyDi QA&#xff1a;\u9762\u5411\u8bed\u8a00\u7c7b\u578b\u591a\u6837\u6027\u7684\u4fe1\u606f\u68c0\u7d22\u95ee\u7b54\u57fa\u51c6<\/li>\n<li>17.BBH\u8be6\u89e3:\u9762\u5411\u5927\u6a21\u578b\u7684\u9ad8\u9636\u63a8\u7406\u8bc4\u4f30\u57fa\u51c6\u4e0e\u6570\u636e\u96c6\u5206\u6790<\/li>\n<li>16.RepoCoder&#xff1a;\u4ed3\u5e93\u7ea7\u4ee3\u7801\u8865\u5168\u7684\u8fed\u4ee3\u68c0\u7d22\u751f\u6210\u6846\u67b6\u89e3\u6790\u4e0e\u5e94\u7528\u524d\u6cbf<\/li>\n<li>15.RAGAS&#xff1a;\u68c0\u7d22\u589e\u5f3a\u751f\u6210\u7cfb\u7edf\u7684\u65e0\u53c2\u8003\u8bc4\u4f30\u6846\u67b6\u4e0e\u6280\u672f\u89e3\u6790<\/li>\n<li>14.Self-RAG&#xff1a;\u57fa\u4e8e\u81ea\u6211\u53cd\u601d\u7684\u68c0\u7d22\u589e\u5f3a\u751f\u6210\u6846\u67b6\u6280\u672f\u89e3\u6790<\/li>\n<li>13.DocBench&#xff1a;\u9762\u5411\u5927\u6a21\u578b\u6587\u6863\u9605\u8bfb\u7cfb\u7edf\u7684\u8bc4\u4f30\u57fa\u51c6\u4e0e\u6570\u636e\u96c6\u5206\u6790<\/li>\n<li>12.\u54f2\u5b66\u4e2d\u7684\u4e3b\u4f53\u6027&#xff1a;\u5386\u53f2\u6f14\u8fdb\u3001\u7406\u8bba\u8303\u5f0f\u4e0e\u5f53\u4ee3\u91cd\u6784<\/li>\n<li>11.FLAN-T5&#xff1a;\u5927\u89c4\u6a21\u6307\u4ee4\u5fae\u8c03\u7684\u7edf\u4e00\u8bed\u8a00\u6a21\u578b\u6846\u67b6<\/li>\n<li>10.Do-Calculus&#xff1a;\u56e0\u679c\u63a8\u65ad\u7684\u6f14\u7b97\u57fa\u7840\u4e0e\u8de8\u9886\u57df\u5e94\u7528<\/li>\n<li>9.\u540c\u8d28\u65e0\u5411\u52a0\u6743\u56fe&#xff1a;\u7406\u8bba\u57fa\u7840\u3001\u7b97\u6cd5\u6f14\u8fdb\u4e0e\u5e94\u7528\u524d\u6cbf<\/li>\n<li>8.\u5927\u6a21\u578b\u667a\u80fd\u4f53(Agent)\u6280\u672f\u5168\u666f&#xff1a;\u67b6\u6784\u6f14\u8fdb\u3001\u534f\u4f5c\u8303\u5f0f\u4e0e\u5e94\u7528\u524d\u6cbf<\/li>\n<li>7.GraphRAG&#xff1a;\u57fa\u4e8e\u77e5\u8bc6\u56fe\u8c31\u7684\u68c0\u7d22\u589e\u5f3a\u751f\u6210\u6280\u672f\u89e3\u6790<\/li>\n<li>6.\u673a\u5668\u5b66\u4e60\u6d88\u878d\u5b9e\u9a8c&#xff1a;\u65b9\u6cd5\u8bba\u6f14\u8fdb\u3001\u8de8\u9886\u57df\u5e94\u7528\u4e0e\u524d\u6cbf\u8d8b\u52bf<\/li>\n<li>5.Agentic RAG&#xff1a;\u81ea\u4e3b\u68c0\u7d22\u589e\u5f3a\u751f\u6210\u7684\u8303\u5f0f\u6f14\u8fdb\u4e0e\u6280\u672f\u7a81\u7834<\/li>\n<li>4.FEVER\u6570\u636e\u96c6&#xff1a;\u4e8b\u5b9e\u9a8c\u8bc1\u4efb\u52a1\u7684\u5927\u89c4\u6a21\u57fa\u51c6\u4e0e\u8bc4\u4f30\u6846\u67b6<\/li>\n<li>3.\u566a\u58f0\u5bf9\u6bd4\u4f30\u8ba1&#xff08;NCE&#xff09;&#xff1a;\u539f\u7406\u3001\u6f14\u8fdb\u4e0e\u8de8\u9886\u57df\u5e94\u7528<\/li>\n<li>2.\u5bf9\u6bd4\u5b66\u4e60&#xff1a;\u539f\u7406\u6f14\u8fdb\u3001\u6280\u672f\u7a81\u7834\u4e0e\u8de8\u9886\u57df\u5e94\u7528\u5168\u666f<\/li>\n<li>1.\u63a9\u7801\u8bed\u8a00\u6a21\u578b(MLM)\u6280\u672f\u89e3\u6790&#xff1a;\u7406\u8bba\u57fa\u7840\u3001\u6f14\u8fdb\u8109\u7edc\u4e0e\u5e94\u7528\u521b\u65b0<\/li>\n<\/ul>\n<h5>2. \u6280\u672f\u67b6\u6784\u8be6\u89e3<\/h5>\n<h6>2.1 \u4e09\u9636\u6bb5\u8bad\u7ec3\u7b56\u7565<\/h6>\n<p>CodeGen \u91c7\u7528\u6e10\u8fdb\u5f0f\u8bad\u7ec3\u63d0\u5347\u4ee3\u7801\u7406\u89e3\u80fd\u529b&#xff1a;<\/p>\n<table>\n<tr>\u8bad\u7ec3\u9636\u6bb5\u6570\u636e\u96c6\u6570\u636e\u89c4\u6a21\u5173\u952e\u7279\u6027<\/tr>\n<tbody>\n<tr>\n<td>CodeGen-NL<\/td>\n<td>THEPILE<\/td>\n<td>825GB \u82f1\u6587\u6587\u672c<\/td>\n<td>\u81ea\u7136\u8bed\u8a00\u57fa\u7840\u80fd\u529b&#xff08;\u542b7.6%\u4ee3\u7801&#xff09;<\/td>\n<\/tr>\n<tr>\n<td>CodeGen-Multi<\/td>\n<td>BIGQUERY<\/td>\n<td>1192\u4ebftoken&#xff08;6\u79cd\u8bed\u8a00&#xff09;<\/td>\n<td>\u591a\u8bed\u8a00\u4ee3\u7801\u6cdb\u5316&#xff08;C&#043;&#043;\/Java\/Python\u7b49&#xff09;<\/td>\n<\/tr>\n<tr>\n<td>CodeGen-Mono<\/td>\n<td>BIGPYTHON<\/td>\n<td>\u7eafPython\u4ee3\u7801<\/td>\n<td>Python\u4e13\u9879\u4f18\u5316&#xff0c;\u6027\u80fd\u903c\u8fd1Codex<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<h6>2.2 \u6a21\u578b\u7ed3\u6784<\/h6>\n<ul>\n<li>\u81ea\u56de\u5f52\u89e3\u7801&#xff1a;\u57fa\u4e8e Transformer \u7684\u56e0\u679c\u8bed\u8a00\u5efa\u6a21&#xff0c;\u6309 <span class=\"katex--inline\"><span class=\"katex\"><span class=\"katex-mathml\">\n<p>         P<\/p>\n<p>         (<\/p>\n<p>          x<\/p>\n<p>          t<\/p>\n<p>         \u2223<\/p>\n<p>          x<\/p>\n<p>           &lt;<\/p>\n<p>           t<\/p>\n<p>         )<\/p>\n<p>        P(x_t \\\\mid x_{&lt;t})<\/p>\n<p>     <\/span><span class=\"katex-html\"><span class=\"base\"><span class=\"strut\" style=\"height: 1em;vertical-align: -0.25em\"><\/span><span class=\"mord mathnormal\" style=\"margin-right: 0.1389em\">P<\/span><span class=\"mopen\">(<\/span><span class=\"mord\"><span class=\"mord mathnormal\">x<\/span><span class=\"msupsub\"><span class=\"vlist-t vlist-t2\"><span class=\"vlist-r\"><span class=\"vlist\" style=\"height: 0.2806em\"><span class=\"\" style=\"top: -2.55em;margin-left: 0em;margin-right: 0.05em\"><span class=\"pstrut\" style=\"height: 2.7em\"><\/span><span class=\"sizing reset-size6 size3 mtight\"><span class=\"mord mathnormal mtight\">t<\/span><\/span><\/span><\/span><span class=\"vlist-s\">\u200b<\/span><\/span><span class=\"vlist-r\"><span class=\"vlist\" style=\"height: 0.15em\"><span class=\"\"><\/span><\/span><\/span><\/span><\/span><\/span><span class=\"mspace\" style=\"margin-right: 0.2778em\"><\/span><span class=\"mrel\">\u2223<\/span><span class=\"mspace\" style=\"margin-right: 0.2778em\"><\/span><\/span><span class=\"base\"><span class=\"strut\" style=\"height: 1em;vertical-align: -0.25em\"><\/span><span class=\"mord\"><span class=\"mord mathnormal\">x<\/span><span class=\"msupsub\"><span class=\"vlist-t vlist-t2\"><span class=\"vlist-r\"><span class=\"vlist\" style=\"height: 0.2806em\"><span class=\"\" style=\"top: -2.55em;margin-left: 0em;margin-right: 0.05em\"><span class=\"pstrut\" style=\"height: 2.7em\"><\/span><span class=\"sizing reset-size6 size3 mtight\"><span class=\"mord mtight\"><span class=\"mrel mtight\">&lt;<\/span><span class=\"mord mathnormal mtight\">t<\/span><\/span><\/span><\/span><\/span><span class=\"vlist-s\">\u200b<\/span><\/span><span class=\"vlist-r\"><span class=\"vlist\" style=\"height: 0.1774em\"><span class=\"\"><\/span><\/span><\/span><\/span><\/span><\/span><span class=\"mclose\">)<\/span><\/span><\/span><\/span><\/span> \u751f\u6210\u4ee3\u7801&#xff1b;<\/li>\n<li>\u4f4d\u7f6e\u7f16\u7801\u4f18\u5316&#xff1a;RoPE&#xff08;Rotary Position Embedding&#xff09;\u652f\u6301\u957f\u4e0a\u4e0b\u6587\u4f9d\u8d56&#xff1b;<\/li>\n<li>\u52a8\u6001\u6279\u5904\u7406&#xff1a;\u5229\u7528 TPU-v4 \u786c\u4ef6\u5e76\u884c\u52a0\u901f\u8bad\u7ec3\u3002<\/li>\n<\/ul>\n<hr \/>\n<h5>3. \u591a\u8f6e\u7a0b\u5e8f\u5408\u6210\u521b\u65b0<\/h5>\n<h6>3.1 \u6838\u5fc3\u8bbe\u8ba1\u52a8\u673a<\/h6>\n<ul>\n<li>\u610f\u56fe\u5206\u89e3&#xff1a;\u590d\u6742\u4efb\u52a1\u62c6\u89e3\u4e3a\u5b50\u95ee\u9898&#xff08;\u5982\u201c\u90ae\u4ef6\u5904\u7406\u201d\u5206\u89e3\u4e3a\u201c\u63d0\u53d6\u7528\u6237\u540d\u201d&#043;\u201c\u9a8c\u8bc1\u57df\u540d\u201d&#xff09;&#xff0c;\u964d\u4f4e\u6a21\u578b\u8ba4\u77e5\u8d1f\u8f7d&#xff1b;<\/li>\n<li>\u5f31\u76d1\u7763\u5b66\u4e60&#xff1a;\u5229\u7528\u4ee3\u7801\u4e2d\u81ea\u7136\u8bed\u8a00\u6ce8\u91ca\u4e0e\u4ee3\u7801\u5757\u7684\u5929\u7136\u914d\u5bf9\u5173\u7cfb&#xff0c;\u6784\u5efa\u9690\u5f0f\u76d1\u7763\u4fe1\u53f7\u3002<\/li>\n<\/ul>\n<h6>3.2 \u591a\u8f6e\u7f16\u7a0b\u57fa\u51c6&#xff08;MTPB&#xff09;<\/h6>\n<ul>\n<li>\u6784\u9020\u539f\u5219&#xff1a;\n<ul>\n<li>\u5305\u542b 115 \u4e2a\u591a\u6837\u5316\u95ee\u9898&#xff0c;\u8986\u76d6\u6570\u5b66\u3001\u5b57\u7b26\u4e32\u5904\u7406\u3001\u7b97\u6cd5\u7b49&#xff1b;<\/li>\n<li>\u6bcf\u4e2a\u95ee\u9898\u9700\u81f3\u5c11 3 \u8f6e\u4ea4\u4e92\u5b8c\u6210&#xff0c;\u4e14\u5355\u8f6e\u65e0\u6cd5\u72ec\u7acb\u89e3\u51b3&#xff1b;<\/li>\n<\/ul>\n<\/li>\n<li>\u8bc4\u4f30\u7ed3\u679c&#xff1a;<br \/>\n<table>\n<tr>\u6a21\u578b\u5355\u8f6e\u901a\u8fc7\u7387\u591a\u8f6e\u901a\u8fc7\u7387\u63d0\u5347<\/tr>\n<tbody>\n<tr>\n<td>CodeGen-Mono-16B<\/td>\n<td>42.1%<\/td>\n<td>52.3%<\/td>\n<td>&#043;10.2%<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>\u591a\u8f6e\u6a21\u5f0f\u4e0b\u6a21\u578b\u56f0\u60d1\u5ea6\u663e\u8457\u964d\u4f4e&#xff0c;\u8bc1\u660e\u610f\u56fe\u7406\u89e3\u66f4\u7cbe\u51c6\u3002<\/p>\n<\/li>\n<\/ul>\n<hr \/>\n<h5>4. \u6027\u80fd\u8bc4\u4f30\u4e0e\u6743\u5a01\u5bf9\u6bd4<\/h5>\n<h6>4.1 HumanEval \u57fa\u51c6\u8868\u73b0<\/h6>\n<table>\n<tr>\u6a21\u578b\u53c2\u6570\u89c4\u6a21Pass&#064;1 (Python)<\/tr>\n<tbody>\n<tr>\n<td>GPT-NEO-2.7B<\/td>\n<td>2.7B<\/td>\n<td>12.4%<\/td>\n<\/tr>\n<tr>\n<td>CodeGen-Multi-16B<\/td>\n<td>16.1B<\/td>\n<td>29.8%<\/td>\n<\/tr>\n<tr>\n<td>CodeGen-Mono-16B<\/td>\n<td>16.1B<\/td>\n<td>33.5%<\/td>\n<\/tr>\n<tr>\n<td>OpenAI Codex<\/td>\n<td>12B<\/td>\n<td>36.3%<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>CodeGen-Mono \u5728\u5f00\u6e90\u6a21\u578b\u4e2d\u8fbe\u5230 SOTA&#xff0c;\u63a5\u8fd1 Codex \u6c34\u5e73\u3002<\/p>\n<h6>4.2 \u4e25\u683c\u8bc4\u4f30\u6846\u67b6 EvalPlus \u9a8c\u8bc1<\/h6>\n<ul>\n<li>\u539f\u59cb HumanEval \u6d4b\u8bd5\u7528\u4f8b\u4e0d\u8db3&#xff08;\u5e73\u5747\u4ec5 3 \u4e2a\/\u4efb\u52a1&#xff09;&#xff0c;\u53ef\u80fd\u9ad8\u4f30\u6a21\u578b\u6027\u80fd&#xff1b;<\/li>\n<li>EvalPlus \u901a\u8fc7\u81ea\u52a8\u5316\u6d4b\u8bd5\u751f\u6210\u5c06\u7528\u4f8b\u6269\u5145 81 \u500d&#xff0c;CodeGen \u901a\u8fc7\u7387\u4e0b\u964d 13.6\u201315.3%&#xff0c;\u66b4\u9732\u8fb9\u754c\u6848\u4f8b\u5904\u7406\u7f3a\u9677\u3002<\/li>\n<\/ul>\n<hr \/>\n<h5>5. \u5e94\u7528\u573a\u666f\u4e0e\u5f00\u6e90\u5b9e\u8df5<\/h5>\n<h6>5.1 \u5178\u578b\u5e94\u7528<\/h6>\n<ul>\n<li>IDE \u667a\u80fd\u8865\u5168&#xff1a;\u6839\u636e\u51fd\u6570\u6ce8\u91ca\u751f\u6210\u5b8c\u6574\u4ee3\u7801\u7247\u6bb5&#xff1b;<\/li>\n<li>\u6559\u80b2\u5de5\u5177&#xff1a;\u5b66\u751f\u5206\u6b65\u63cf\u8ff0\u9700\u6c42&#xff0c;\u6a21\u578b\u751f\u6210\u53ef\u8fd0\u884c\u793a\u4f8b\u3002<\/li>\n<\/ul>\n<h6>5.2 \u5feb\u901f\u90e8\u7f72\u793a\u4f8b<\/h6>\n<p><span class=\"token keyword\">from<\/span> transformers <span class=\"token keyword\">import<\/span> AutoTokenizer<span class=\"token punctuation\">,<\/span> AutoModelForCausalLM<\/p>\n<p><span class=\"token comment\"># \u52a0\u8f7d\u591a\u8bed\u8a0016B\u6a21\u578b<\/span><br \/>\ntokenizer <span class=\"token operator\">&#061;<\/span> AutoTokenizer<span class=\"token punctuation\">.<\/span>from_pretrained<span class=\"token punctuation\">(<\/span><span class=\"token string\">&#034;Salesforce\/codegen-16B-multi&#034;<\/span><span class=\"token punctuation\">)<\/span><br \/>\nmodel <span class=\"token operator\">&#061;<\/span> AutoModelForCausalLM<span class=\"token punctuation\">.<\/span>from_pretrained<span class=\"token punctuation\">(<\/span><span class=\"token string\">&#034;Salesforce\/codegen-16B-multi&#034;<\/span><span class=\"token punctuation\">)<\/span><\/p>\n<p><span class=\"token comment\"># \u591a\u8f6e\u63d0\u793a\u793a\u4f8b<\/span><br \/>\nprompt <span class=\"token operator\">&#061;<\/span> <span class=\"token triple-quoted-string string\">&#034;&#034;&#034;<br \/>\n# Round 1: \u5b9a\u4e49\u4e00\u4e2a\u51fd\u6570&#xff0c;\u8ba1\u7b97\u5217\u8868\u5e73\u5747\u503c<br \/>\ndef average(nums):<br \/>\n# Round 2: \u5904\u7406\u7a7a\u5217\u8868\u5f02\u5e38<br \/>\n&#034;&#034;&#034;<\/span><\/p>\n<p>inputs <span class=\"token operator\">&#061;<\/span> tokenizer<span class=\"token punctuation\">(<\/span>prompt<span class=\"token punctuation\">,<\/span> return_tensors<span class=\"token operator\">&#061;<\/span><span class=\"token string\">&#034;pt&#034;<\/span><span class=\"token punctuation\">)<\/span><br \/>\noutputs <span class=\"token operator\">&#061;<\/span> model<span class=\"token punctuation\">.<\/span>generate<span class=\"token punctuation\">(<\/span><span class=\"token operator\">**<\/span>inputs<span class=\"token punctuation\">,<\/span> max_length<span class=\"token operator\">&#061;<\/span><span class=\"token number\">256<\/span><span class=\"token punctuation\">)<\/span><br \/>\n<span class=\"token keyword\">print<\/span><span class=\"token punctuation\">(<\/span>tokenizer<span class=\"token punctuation\">.<\/span>decode<span class=\"token punctuation\">(<\/span>outputs<span class=\"token punctuation\">[<\/span><span class=\"token number\">0<\/span><span class=\"token punctuation\">]<\/span><span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">)<\/span><\/p>\n<p>\u8f93\u51fa\u8865\u5168\u5f02\u5e38\u5904\u7406\u903b\u8f91&#xff1a;if len(nums)&#061;&#061;0: return 0<\/p>\n<hr \/>\n<h5>6. \u7814\u7a76\u6f14\u8fdb\u4e0e\u6311\u6218<\/h5>\n<ul>\n<li>\u6269\u6563\u6a21\u578b\u6311\u6218\u8005&#xff1a;\u82f9\u679c DiffuCoder&#xff08;2025&#xff09;\u91c7\u7528\u975e\u81ea\u56de\u5f52\u6269\u6563\u751f\u6210&#xff0c;\u652f\u6301\u975e\u987a\u5e8f\u4ee3\u7801\u586b\u5145&#xff0c;\u5728 EvalPlus \u4e0a\u6027\u80fd\u63d0\u5347 4.4%&#xff1b;<\/li>\n<li>\u63a8\u7406\u8fc7\u7a0b\u4f18\u5316&#xff1a;Posterior-GRPO&#xff08;2025&#xff09;\u901a\u8fc7\u5f3a\u5316\u5b66\u4e60\u5bf9\u9f50\u4ee3\u7801\u6b63\u786e\u6027\u4e0e\u63a8\u7406\u903b\u8f91\u4e25\u8c28\u6027&#xff0c;\u8fdb\u4e00\u6b65\u63d0\u5347\u751f\u6210\u8d28\u91cf&#xff1b;<\/li>\n<li>\u6838\u5fc3\u5c40\u9650&#xff1a;\n<ul>\n<li>\u591a\u8f6e\u4f9d\u8d56\u4eba\u5de5\u5206\u89e3\u610f\u56fe&#xff0c;\u81ea\u52a8\u4efb\u52a1\u62c6\u89e3\u4ecd\u5f85\u7814\u7a76&#xff1b;<\/li>\n<li>\u4f4e\u8d44\u6e90\u8bed\u8a00\u4ee3\u7801\u751f\u6210\u6027\u80fd\u8f83\u5f31&#xff08;\u5982\u65af\u74e6\u5e0c\u91cc\u8bed\u63d0\u793a&#xff09;\u3002<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<hr \/>\n<h4>&#x1f4da; \u539f\u59cb\u8bba\u6587<\/h4>\n<p>Nijkamp, E., Pang, B., Hayashi, H., Tu, L., Wang, H., Zhou, Y., Savarese, S., &amp; Xiong, C. (2022). A Conversational Paradigm for Program Synthesis. arXiv preprint arXiv:2203.13474. \u8bba\u6587\u5730\u5740: https:\/\/arxiv.org\/abs\/2203.13474 \u4ee3\u7801\u4ed3\u5e93: https:\/\/github.com\/salesforce\/CodeGen<\/p>\n<h4>&#x1f48e; \u603b\u7ed3<\/h4>\n<p>CodeGen \u901a\u8fc7 \u591a\u8f6e\u7a0b\u5e8f\u5408\u6210\u8303\u5f0f \u4e0e \u5f00\u6e90\u6a21\u578b\u5bb6\u65cf&#xff0c;\u63a8\u52a8\u4e86\u4ee3\u7801\u751f\u6210\u6280\u672f\u7684\u6c11\u4e3b\u5316\u3002\u5176\u6838\u5fc3\u4ef7\u503c\u5728\u4e8e&#xff1a;<\/p>\n<li>\u5de5\u7a0b\u5b9e\u7528\u6027&#xff1a;\u652f\u6301\u81ea\u7136\u8bed\u8a00\u4ea4\u4e92\u7684\u6e10\u8fdb\u5f0f\u4ee3\u7801\u751f\u6210&#xff0c;\u964d\u4f4e\u5f00\u53d1\u95e8\u69db&#xff1b;<\/li>\n<li>\u6027\u80fd\u7a81\u7834&#xff1a;CodeGen-Mono-16B \u5728 HumanEval \u4e0a\u903c\u8fd1\u95ed\u6e90 Codex&#xff0c;\u9a8c\u8bc1\u5f00\u6e90\u6a21\u578b\u7684\u7ade\u4e89\u529b&#xff1b;<\/li>\n<li>\u7814\u7a76\u542f\u53d1\u6027&#xff1a;MTPB \u57fa\u51c6\u4e0e\u591a\u8f6e\u673a\u5236\u50ac\u751f\u540e\u7eed\u5de5\u4f5c&#xff08;\u5982 DiffuCoder \u7684\u975e\u81ea\u56de\u5f52\u751f\u6210\u3001P-GRPO \u7684\u63a8\u7406\u8fc7\u7a0b\u4f18\u5316&#xff09;\u3002<\/li>\n<p>\u968f\u7740\u4e25\u683c\u8bc4\u4f30\u6846\u67b6&#xff08;\u5982 EvalPlus&#xff09;\u7684\u666e\u53ca\u4e0e\u65b0\u578b\u67b6\u6784\u7684\u6d8c\u73b0&#xff0c;CodeGen \u7684\u8bbe\u8ba1\u7406\u5ff5\u4ecd\u5c06\u6301\u7eed\u5f71\u54cd\u4ee3\u7801\u751f\u6210\u9886\u57df\u7684\u6f14\u8fdb &#x1f527;\u3002<\/p>\n<p>\u672c\u6587\u7531\u300c\u5927\u5343AI\u52a9\u624b\u300d\u539f\u521b\u53d1\u5e03&#xff0c;\u4e13\u6ce8\u7528\u771f\u8bdd\u8bb2AI&#xff0c;\u56de\u5f52\u6280\u672f\u672c\u8d28\u3002\u62d2\u7edd\u795e\u8bdd\u6216\u5996\u9b54\u5316\u3002\u641c\u7d22\u300c\u5927\u5343AI\u52a9\u624b\u300d\u5173\u6ce8\u6211&#xff0c;\u4e00\u8d77\u6495\u6389\u8fc7\u5ea6\u5305\u88c5&#xff0c;\u5b66\u4e60\u771f\u5b9e\u7684AI\u6280\u672f&#xff01;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u6587\u7ae0\u6d4f\u89c8\u9605\u8bfb131\u6b21\uff0c\u70b9\u8d5e5\u6b21\uff0c\u6536\u85cf6\u6b21\u3002CodeGen \u901a\u8fc7\u3002<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[5055,5056,5058,75,81,50,5057,224,51],"topic":[],"class_list":["post-51229","post","type-post","status-publish","format-standard","hentry","category-server","tag-other","tag-codegen","tag-codex","tag-llm","tag-python","tag-50","tag-5057","tag-224","tag-51"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v20.3 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>CodeGen\uff1a\u9762\u5411\u591a\u8f6e\u7a0b\u5e8f\u5408\u6210\u7684\u5f00\u6e90\u4ee3\u7801\u5927\u8bed\u8a00\u6a21\u578b - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.wsisp.com\/helps\/51229.html\" \/>\n<meta property=\"og:locale\" content=\"zh_CN\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"CodeGen\uff1a\u9762\u5411\u591a\u8f6e\u7a0b\u5e8f\u5408\u6210\u7684\u5f00\u6e90\u4ee3\u7801\u5927\u8bed\u8a00\u6a21\u578b - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\" \/>\n<meta property=\"og:description\" content=\"\u6587\u7ae0\u6d4f\u89c8\u9605\u8bfb131\u6b21\uff0c\u70b9\u8d5e5\u6b21\uff0c\u6536\u85cf6\u6b21\u3002CodeGen \u901a\u8fc7\u3002\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.wsisp.com\/helps\/51229.html\" \/>\n<meta property=\"og:site_name\" content=\"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\" \/>\n<meta property=\"article:published_time\" content=\"2025-08-10T11:24:29+00:00\" \/>\n<meta name=\"author\" content=\"admin\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"\u4f5c\u8005\" \/>\n\t<meta name=\"twitter:data1\" content=\"admin\" \/>\n\t<meta name=\"twitter:label2\" content=\"\u9884\u8ba1\u9605\u8bfb\u65f6\u95f4\" \/>\n\t<meta name=\"twitter:data2\" content=\"2 \u5206\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/51229.html\",\"url\":\"https:\/\/www.wsisp.com\/helps\/51229.html\",\"name\":\"CodeGen\uff1a\u9762\u5411\u591a\u8f6e\u7a0b\u5e8f\u5408\u6210\u7684\u5f00\u6e90\u4ee3\u7801\u5927\u8bed\u8a00\u6a21\u578b - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\",\"isPartOf\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/#website\"},\"datePublished\":\"2025-08-10T11:24:29+00:00\",\"dateModified\":\"2025-08-10T11:24:29+00:00\",\"author\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41\"},\"breadcrumb\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/51229.html#breadcrumb\"},\"inLanguage\":\"zh-Hans\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.wsisp.com\/helps\/51229.html\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/51229.html#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"\u9996\u9875\",\"item\":\"https:\/\/www.wsisp.com\/helps\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"CodeGen\uff1a\u9762\u5411\u591a\u8f6e\u7a0b\u5e8f\u5408\u6210\u7684\u5f00\u6e90\u4ee3\u7801\u5927\u8bed\u8a00\u6a21\u578b\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/#website\",\"url\":\"https:\/\/www.wsisp.com\/helps\/\",\"name\":\"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\",\"description\":\"\u9999\u6e2f\u670d\u52a1\u5668_\u9999\u6e2f\u4e91\u670d\u52a1\u5668\u8d44\u8baf_\u670d\u52a1\u5668\u5e2e\u52a9\u6587\u6863_\u670d\u52a1\u5668\u6559\u7a0b\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/www.wsisp.com\/helps\/?s={search_term_string}\"},\"query-input\":\"required name=search_term_string\"}],\"inLanguage\":\"zh-Hans\"},{\"@type\":\"Person\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41\",\"name\":\"admin\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"zh-Hans\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery\",\"contentUrl\":\"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery\",\"caption\":\"admin\"},\"sameAs\":[\"http:\/\/wp.wsisp.com\"],\"url\":\"https:\/\/www.wsisp.com\/helps\/author\/admin\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"CodeGen\uff1a\u9762\u5411\u591a\u8f6e\u7a0b\u5e8f\u5408\u6210\u7684\u5f00\u6e90\u4ee3\u7801\u5927\u8bed\u8a00\u6a21\u578b - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.wsisp.com\/helps\/51229.html","og_locale":"zh_CN","og_type":"article","og_title":"CodeGen\uff1a\u9762\u5411\u591a\u8f6e\u7a0b\u5e8f\u5408\u6210\u7684\u5f00\u6e90\u4ee3\u7801\u5927\u8bed\u8a00\u6a21\u578b - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","og_description":"\u6587\u7ae0\u6d4f\u89c8\u9605\u8bfb131\u6b21\uff0c\u70b9\u8d5e5\u6b21\uff0c\u6536\u85cf6\u6b21\u3002CodeGen \u901a\u8fc7\u3002","og_url":"https:\/\/www.wsisp.com\/helps\/51229.html","og_site_name":"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","article_published_time":"2025-08-10T11:24:29+00:00","author":"admin","twitter_card":"summary_large_image","twitter_misc":{"\u4f5c\u8005":"admin","\u9884\u8ba1\u9605\u8bfb\u65f6\u95f4":"2 \u5206"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/www.wsisp.com\/helps\/51229.html","url":"https:\/\/www.wsisp.com\/helps\/51229.html","name":"CodeGen\uff1a\u9762\u5411\u591a\u8f6e\u7a0b\u5e8f\u5408\u6210\u7684\u5f00\u6e90\u4ee3\u7801\u5927\u8bed\u8a00\u6a21\u578b - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","isPartOf":{"@id":"https:\/\/www.wsisp.com\/helps\/#website"},"datePublished":"2025-08-10T11:24:29+00:00","dateModified":"2025-08-10T11:24:29+00:00","author":{"@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41"},"breadcrumb":{"@id":"https:\/\/www.wsisp.com\/helps\/51229.html#breadcrumb"},"inLanguage":"zh-Hans","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.wsisp.com\/helps\/51229.html"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.wsisp.com\/helps\/51229.html#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"\u9996\u9875","item":"https:\/\/www.wsisp.com\/helps"},{"@type":"ListItem","position":2,"name":"CodeGen\uff1a\u9762\u5411\u591a\u8f6e\u7a0b\u5e8f\u5408\u6210\u7684\u5f00\u6e90\u4ee3\u7801\u5927\u8bed\u8a00\u6a21\u578b"}]},{"@type":"WebSite","@id":"https:\/\/www.wsisp.com\/helps\/#website","url":"https:\/\/www.wsisp.com\/helps\/","name":"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","description":"\u9999\u6e2f\u670d\u52a1\u5668_\u9999\u6e2f\u4e91\u670d\u52a1\u5668\u8d44\u8baf_\u670d\u52a1\u5668\u5e2e\u52a9\u6587\u6863_\u670d\u52a1\u5668\u6559\u7a0b","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.wsisp.com\/helps\/?s={search_term_string}"},"query-input":"required name=search_term_string"}],"inLanguage":"zh-Hans"},{"@type":"Person","@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41","name":"admin","image":{"@type":"ImageObject","inLanguage":"zh-Hans","@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/image\/","url":"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery","contentUrl":"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery","caption":"admin"},"sameAs":["http:\/\/wp.wsisp.com"],"url":"https:\/\/www.wsisp.com\/helps\/author\/admin"}]}},"_links":{"self":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts\/51229","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/comments?post=51229"}],"version-history":[{"count":0,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts\/51229\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/media?parent=51229"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/categories?post=51229"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/tags?post=51229"},{"taxonomy":"topic","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/topic?post=51229"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}