{"id":9395,"date":"2025-06-06T10:06:30","date_gmt":"2025-06-06T02:06:30","guid":{"rendered":"\/?p=9395"},"modified":"2025-06-06T10:06:30","modified_gmt":"2025-06-06T02:06:30","slug":"llama-factory%e5%be%ae%e8%b0%83","status":"publish","type":"post","link":"\/?p=9395","title":{"rendered":"LLaMA Factory\u5fae\u8c03"},"content":{"rendered":"<h2>\u6982\u8ff0<\/h2>\n<p>\u5b98\u7f51\u6559\u7a0b\uff1a<a href=\"https:\/\/llamafactory.readthedocs.io\/zh-cn\/latest\/getting_started\/data_preparation.html#id4\">https:\/\/llamafactory.readthedocs.io\/zh-cn\/latest\/getting_started\/data_preparation.html#id4<\/a><\/p>\n<h2>\u5fae\u8c03\u7c7b\u578b<\/h2>\n<ul>\n<li><a href=\"https:\/\/llamafactory.readthedocs.io\/zh-cn\/latest\/getting_started\/data_preparation.html#id4\">\u6307\u4ee4\u76d1\u7763\u5fae\u8c03<\/a><\/li>\n<li><a href=\"https:\/\/llamafactory.readthedocs.io\/zh-cn\/latest\/getting_started\/data_preparation.html#id7\">\u9884\u8bad\u7ec3<\/a><\/li>\n<li><a href=\"https:\/\/llamafactory.readthedocs.io\/zh-cn\/latest\/getting_started\/data_preparation.html#id10\">\u504f\u597d\u8bad\u7ec3<\/a><\/li>\n<li><a href=\"https:\/\/llamafactory.readthedocs.io\/zh-cn\/latest\/getting_started\/data_preparation.html#kto\">KTO<\/a><\/li>\n<li><a href=\"https:\/\/llamafactory.readthedocs.io\/zh-cn\/latest\/getting_started\/data_preparation.html#id14\">\u591a\u6a21\u6001<\/a><\/li>\n<\/ul>\n<h3>1.\u6307\u4ee4\u76d1\u7763\u5fae\u8c03\u6570\u636e\u96c6<\/h3>\n<p><strong>\u6837\u4f8b\u6570\u636e\u96c6<\/strong>\uff1a <a href=\"https:\/\/github.com\/hiyouga\/LLaMA-Factory\/blob\/main\/data\/alpaca_zh_demo.json\/\">\u6307\u4ee4\u76d1\u7763\u5fae\u8c03\u6837\u4f8b\u6570\u636e\u96c6<\/a><\/p>\n<p>\u6307\u4ee4\u76d1\u7763\u5fae\u8c03(Instruct Tuning)\u901a\u8fc7\u8ba9\u6a21\u578b\u5b66\u4e60\u8be6\u7ec6\u7684\u6307\u4ee4\u4ee5\u53ca\u5bf9\u5e94\u7684\u56de\u7b54\u6765\u4f18\u5316\u6a21\u578b\u5728\u7279\u5b9a\u6307\u4ee4\u4e0b\u7684\u8868\u73b0\u3002<\/p>\n<p><code>instruction<\/code> \u5217\u5bf9\u5e94\u7684\u5185\u5bb9\u4e3a\u4eba\u7c7b\u6307\u4ee4\uff0c <code>input<\/code> \u5217\u5bf9\u5e94\u7684\u5185\u5bb9\u4e3a\u4eba\u7c7b\u8f93\u5165\uff0c <code>output<\/code> \u5217\u5bf9\u5e94\u7684\u5185\u5bb9\u4e3a\u6a21\u578b\u56de\u7b54\u3002\u4e0b\u9762\u662f\u4e00\u4e2a\u4f8b\u5b50<\/p>\n<pre><code class=\"language-json\">&quot;alpaca_zh_demo.json&quot;\n{\n  &quot;instruction&quot;: &quot;\u8ba1\u7b97\u8fd9\u4e9b\u7269\u54c1\u7684\u603b\u8d39\u7528\u3002 &quot;,\n  &quot;input&quot;: &quot;\u8f93\u5165\uff1a\u6c7d\u8f66 - $3000\uff0c\u8863\u670d - $100\uff0c\u4e66 - $20\u3002&quot;,\n  &quot;output&quot;: &quot;\u6c7d\u8f66\u3001\u8863\u670d\u548c\u4e66\u7684\u603b\u8d39\u7528\u4e3a $3000 + $100 + $20 = $3120\u3002&quot;\n},<\/code><\/pre>\n<p>\u5728\u8fdb\u884c\u6307\u4ee4\u76d1\u7763\u5fae\u8c03\u65f6\uff0c <code>instruction<\/code> \u5217\u5bf9\u5e94\u7684\u5185\u5bb9\u4f1a\u4e0e <code>input<\/code> \u5217\u5bf9\u5e94\u7684\u5185\u5bb9\u62fc\u63a5\u540e\u4f5c\u4e3a\u6700\u7ec8\u7684\u4eba\u7c7b\u8f93\u5165\uff0c\u5373\u4eba\u7c7b\u8f93\u5165\u4e3a <code>instruction\\ninput<\/code>\u3002\u800c <code>output<\/code> \u5217\u5bf9\u5e94\u7684\u5185\u5bb9\u4e3a\u6a21\u578b\u56de\u7b54\u3002 \u5728\u4e0a\u9762\u7684\u4f8b\u5b50\u4e2d\uff0c\u4eba\u7c7b\u7684\u6700\u7ec8\u8f93\u5165\u662f\uff1a<\/p>\n<pre><code>\u8ba1\u7b97\u8fd9\u4e9b\u7269\u54c1\u7684\u603b\u8d39\u7528\u3002\n\u8f93\u5165\uff1a\u6c7d\u8f66 - $3000\uff0c\u8863\u670d - $100\uff0c\u4e66 - $20\u3002<\/code><\/pre>\n<p>\u6a21\u578b\u7684\u56de\u7b54\u662f\uff1a<\/p>\n<pre><code>\u6c7d\u8f66\u3001\u8863\u670d\u548c\u4e66\u7684\u603b\u8d39\u7528\u4e3a $3000 + $100 + $20 = $3120\u3002<\/code><\/pre>\n<p>\u5982\u679c\u6307\u5b9a\uff0c <code>system<\/code> \u5217\u5bf9\u5e94\u7684\u5185\u5bb9\u5c06\u88ab\u4f5c\u4e3a\u7cfb\u7edf\u63d0\u793a\u8bcd\u3002<\/p>\n<p><code>history<\/code> \u5217\u662f\u7531\u591a\u4e2a\u5b57\u7b26\u4e32\u4e8c\u5143\u7ec4\u6784\u6210\u7684\u5217\u8868\uff0c\u5206\u522b\u4ee3\u8868\u5386\u53f2\u6d88\u606f\u4e2d\u6bcf\u8f6e\u5bf9\u8bdd\u7684\u6307\u4ee4\u548c\u56de\u7b54\u3002\u6ce8\u610f\u5728\u6307\u4ee4\u76d1\u7763\u5fae\u8c03\u65f6\uff0c\u5386\u53f2\u6d88\u606f\u4e2d\u7684\u56de\u7b54\u5185\u5bb9\u4e5f\u4f1a\u88ab\u7528\u4e8e\u6a21\u578b\u5b66\u4e60\u3002<\/p>\n<p>\u6307\u4ee4\u76d1\u7763\u5fae\u8c03\u6570\u636e\u96c6 <strong>\u683c\u5f0f\u8981\u6c42<\/strong> \u5982\u4e0b\uff1a<\/p>\n<pre><code class=\"language-json\">[\n  {\n    &quot;instruction&quot;: &quot;\u4eba\u7c7b\u6307\u4ee4\uff08\u5fc5\u586b\uff09&quot;,\n    &quot;input&quot;: &quot;\u4eba\u7c7b\u8f93\u5165\uff08\u9009\u586b\uff09&quot;,\n    &quot;output&quot;: &quot;\u6a21\u578b\u56de\u7b54\uff08\u5fc5\u586b\uff09&quot;,\n    &quot;system&quot;: &quot;\u7cfb\u7edf\u63d0\u793a\u8bcd\uff08\u9009\u586b\uff09&quot;,\n    &quot;history&quot;: [\n      [&quot;\u7b2c\u4e00\u8f6e\u6307\u4ee4\uff08\u9009\u586b\uff09&quot;, &quot;\u7b2c\u4e00\u8f6e\u56de\u7b54\uff08\u9009\u586b\uff09&quot;],\n      [&quot;\u7b2c\u4e8c\u8f6e\u6307\u4ee4\uff08\u9009\u586b\uff09&quot;, &quot;\u7b2c\u4e8c\u8f6e\u56de\u7b54\uff08\u9009\u586b\uff09&quot;]\n    ]\n  }\n]<\/code><\/pre>\n<p>\u4e0b\u9762\u63d0\u4f9b\u4e00\u4e2a alpaca \u683c\u5f0f <strong>\u591a\u8f6e<\/strong> \u5bf9\u8bdd\u7684\u4f8b\u5b50\uff0c\u5bf9\u4e8e\u5355\u8f6e\u5bf9\u8bdd\u53ea\u9700\u7701\u7565 <code>history<\/code> \u5217\u5373\u53ef\u3002<\/p>\n<pre><code class=\"language-json\">[\n  {\n    &quot;instruction&quot;: &quot;\u4eca\u5929\u7684\u5929\u6c14\u600e\u4e48\u6837\uff1f&quot;,\n    &quot;input&quot;: &quot;&quot;,\n    &quot;output&quot;: &quot;\u4eca\u5929\u7684\u5929\u6c14\u4e0d\u9519\uff0c\u662f\u6674\u5929\u3002&quot;,\n    &quot;history&quot;: [\n      [\n        &quot;\u4eca\u5929\u4f1a\u4e0b\u96e8\u5417\uff1f&quot;,\n        &quot;\u4eca\u5929\u4e0d\u4f1a\u4e0b\u96e8\uff0c\u662f\u4e2a\u597d\u5929\u6c14\u3002&quot;\n      ],\n      [\n        &quot;\u4eca\u5929\u9002\u5408\u51fa\u53bb\u73a9\u5417\uff1f&quot;,\n        &quot;\u975e\u5e38\u9002\u5408\uff0c\u7a7a\u6c14\u8d28\u91cf\u5f88\u597d\u3002&quot;\n      ]\n    ]\n  }\n]<\/code><\/pre>\n<p>\u5bf9\u4e8e\u4e0a\u8ff0\u683c\u5f0f\u7684\u6570\u636e\uff0c <code>dataset_info.json<\/code> \u4e2d\u7684 <strong>\u6570\u636e\u96c6\u63cf\u8ff0<\/strong> \u5e94\u4e3a\uff1a<\/p>\n<pre><code class=\"language-json\">&quot;\u6570\u636e\u96c6\u540d\u79f0&quot;: {\n  &quot;file_name&quot;: &quot;data.json&quot;,\n  &quot;columns&quot;: {\n    &quot;prompt&quot;: &quot;instruction&quot;,\n    &quot;query&quot;: &quot;input&quot;,\n    &quot;response&quot;: &quot;output&quot;,\n    &quot;system&quot;: &quot;system&quot;,\n    &quot;history&quot;: &quot;history&quot;\n  }\n}<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>\u6982\u8ff0 \u5b98\u7f51\u6559\u7a0b\uff1ahttps:\/\/llamafactory.readthedocs.io\/zh-cn\/latest\/getting_sta   \u2026 &#8230;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"ngg_post_thumbnail":0},"categories":[225],"tags":[],"_links":{"self":[{"href":"\/index.php?rest_route=\/wp\/v2\/posts\/9395"}],"collection":[{"href":"\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=9395"}],"version-history":[{"count":1,"href":"\/index.php?rest_route=\/wp\/v2\/posts\/9395\/revisions"}],"predecessor-version":[{"id":9396,"href":"\/index.php?rest_route=\/wp\/v2\/posts\/9395\/revisions\/9396"}],"wp:attachment":[{"href":"\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=9395"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=9395"},{"taxonomy":"post_tag","embeddable":true,"href":"\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=9395"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}