{"id":26011,"date":"2025-04-19T14:21:08","date_gmt":"2025-04-19T06:21:08","guid":{"rendered":"https:\/\/www.wsisp.com\/helps\/26011.html"},"modified":"2025-04-19T14:21:08","modified_gmt":"2025-04-19T06:21:08","slug":"%e5%9c%a8%e6%98%87%e8%85%be%e6%9c%8d%e5%8a%a1%e5%99%a8%e4%b8%8a%e4%bd%bf%e7%94%a8llama-factory%e5%af%b9baichuan2-13b%e6%a8%a1%e5%9e%8b%e8%bf%9b%e8%a1%8clora%e5%be%ae%e8%b0%83","status":"publish","type":"post","link":"https:\/\/www.wsisp.com\/helps\/26011.html","title":{"rendered":"\u5728\u6607\u817e\u670d\u52a1\u5668\u4e0a\u4f7f\u7528llama-factory\u5bf9baichuan2-13b\u6a21\u578b\u8fdb\u884clora\u5fae\u8c03"},"content":{"rendered":"<h3>\u4ec0\u4e48\u662flora\u5fae\u8c03<\/h3>\n<p>LoRA \u63d0\u51fa\u5728\u9884\u8bad\u7ec3\u6a21\u578b\u7684\u53c2\u6570\u77e9\u9635\u4e0a\u6dfb\u52a0\u4f4e\u79e9\u5206\u89e3\u77e9\u9635\u6765\u8fd1\u4f3c\u6bcf\u5c42\u7684\u53c2\u6570\u66f4\u65b0&#xff0c;\u4ece\u800c\u51cf\u5c11\u9002\u914d\u4e0b\u6e38\u4efb\u52a1\u6240\u9700\u8981\u8bad\u7ec3\u7684\u53c2\u6570\u3002<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/04\/20250419062106-680340d276018.png\" alt=\"\u5728\u8fd9\u91cc\u63d2\u5165\u56fe\u7247\u63cf\u8ff0\" \/><\/p>\n<h3>\u73af\u5883\u51c6\u5907<\/h3>\n<p>\u8fd9\u6b21\u4f7f\u7528\u5230\u7684\u5fae\u8c03\u6846\u67b6\u662fllama-factory\u3002\u8fd9\u4e2a\u6846\u67b6\u96c6\u6210\u4e86\u5bf9\u591a\u79cd\u6a21\u578b\u8fdb\u884c\u5404\u79cd\u8bad\u7ec3\u7684\u4ee3\u7801&#xff0c;\u5c11\u91cf\u4fee\u6539\u5c31\u53ef\u4f7f\u7528\u3002 \u6211\u662f\u5728\u6607\u817e\u4e0a\u4f7f\u7528docker\u5b89\u88c5\u7684&#xff0c;\u88c5 Ascend CANN Toolkit and Kernels\u5df2\u7ecf\u63d0\u524d\u88c5\u597d\u4e86&#xff0c;\u5982\u679c\u6ca1\u6709\u7684\u8bdd\u9700\u8981\u53e6\u5916\u5b89\u88c5 \u7136\u540e\u5b89\u88c5llama-factory&#xff1a;<\/p>\n<p><span class=\"token function\">git<\/span> clone https:\/\/gitee.com\/hiyouga\/LLaMA-Factory.git<br \/>\n<span class=\"token builtin class-name\">cd<\/span> LLaMA-Factory<br \/>\npip <span class=\"token function\">install<\/span> <span class=\"token parameter variable\">-e<\/span> <span class=\"token string\">&#039;.[torch-npu,metrics]&#039;<\/span><\/p>\n<p>\u8981\u662f\u7f3a\u4ec0\u4e48\u518dpi install \u6765\u5b89\u88c5\u3002<\/p>\n<h3>\u51c6\u5907\u6570\u636e<\/h3>\n<p>LLaMA Factory\u5de5\u7a0b\u76ee\u5f55\u7684data\u76ee\u5f55\u4e0b\u6709\u5df2\u7ecf\u6709\u5404\u79cd\u5b9e\u4f8b\u6570\u636e\u96c6\u4e86&#xff0c;\u4eff\u7167\u683c\u5f0f\u81ea\u5df1\u505a\u4e00\u4e2a\u5c31\u884c\u3002\u6bd4\u5982alpaca\u683c\u5f0f\u5982\u4e0b&#xff08;\u5fc5\u987b\u6709&#034;instruction&#034;\u3001&#034;output&#034;2\u4e2a\u5b57\u6bb5&#xff09;<\/p>\n<p><span class=\"token punctuation\">[<\/span><br \/>\n  <span class=\"token punctuation\">{<\/span><br \/>\n    <span class=\"token string-property property\">&#034;instruction&#034;<\/span><span class=\"token operator\">:<\/span> <span class=\"token string\">&#034;\u4eba\u7c7b\u6307\u4ee4&#xff08;\u5fc5\u586b&#xff09;&#034;<\/span><span class=\"token punctuation\">,<\/span><br \/>\n    <span class=\"token string-property property\">&#034;input&#034;<\/span><span class=\"token operator\">:<\/span> <span class=\"token string\">&#034;\u4eba\u7c7b\u8f93\u5165&#xff08;\u9009\u586b&#xff09;&#034;<\/span><span class=\"token punctuation\">,<\/span><br \/>\n    <span class=\"token string-property property\">&#034;output&#034;<\/span><span class=\"token operator\">:<\/span> <span class=\"token string\">&#034;\u6a21\u578b\u56de\u7b54&#xff08;\u5fc5\u586b&#xff09;&#034;<\/span><span class=\"token punctuation\">,<\/span><br \/>\n    <span class=\"token string-property property\">&#034;system&#034;<\/span><span class=\"token operator\">:<\/span> <span class=\"token string\">&#034;\u7cfb\u7edf\u63d0\u793a\u8bcd&#xff08;\u9009\u586b&#xff09;&#034;<\/span><span class=\"token punctuation\">,<\/span><br \/>\n    <span class=\"token string-property property\">&#034;history&#034;<\/span><span class=\"token operator\">:<\/span> <span class=\"token punctuation\">[<\/span><br \/>\n      <span class=\"token punctuation\">[<\/span><span class=\"token string\">&#034;\u7b2c\u4e00\u8f6e\u6307\u4ee4&#xff08;\u9009\u586b&#xff09;&#034;<\/span><span class=\"token punctuation\">,<\/span> <span class=\"token string\">&#034;\u7b2c\u4e00\u8f6e\u56de\u7b54&#xff08;\u9009\u586b&#xff09;&#034;<\/span><span class=\"token punctuation\">]<\/span><span class=\"token punctuation\">,<\/span><br \/>\n      <span class=\"token punctuation\">[<\/span><span class=\"token string\">&#034;\u7b2c\u4e8c\u8f6e\u6307\u4ee4&#xff08;\u9009\u586b&#xff09;&#034;<\/span><span class=\"token punctuation\">,<\/span> <span class=\"token string\">&#034;\u7b2c\u4e8c\u8f6e\u56de\u7b54&#xff08;\u9009\u586b&#xff09;&#034;<\/span><span class=\"token punctuation\">]<\/span><br \/>\n    <span class=\"token punctuation\">]<\/span><br \/>\n  <span class=\"token punctuation\">}<\/span><br \/>\n<span class=\"token punctuation\">]<\/span><\/p>\n<p>\u6bd4\u5982&#xff1a;<\/p>\n<p><span class=\"token punctuation\">[<\/span><br \/>\n  <span class=\"token punctuation\">{<\/span><br \/>\n    <span class=\"token string\">&#034;instruction&#034;<\/span><span class=\"token builtin class-name\">:<\/span> <span class=\"token string\">&#034;\u8bc6\u522b\u5e76\u89e3\u91ca\u7ed9\u5b9a\u5217\u8868\u4e2d\u7684\u4e24\u4e2a\u79d1\u5b66\u7406\u8bba&#xff1a;\u7ec6\u80de\u7406\u8bba\u548c\u65e5\u5fc3\u8bf4\u3002&#034;<\/span>,<br \/>\n    <span class=\"token string\">&#034;input&#034;<\/span><span class=\"token builtin class-name\">:<\/span> <span class=\"token string\">&#034;&#034;<\/span>,<br \/>\n    <span class=\"token string\">&#034;output&#034;<\/span><span class=\"token builtin class-name\">:<\/span> <span class=\"token string\">&#034;\u7ec6\u80de\u7406\u8bba\u662f\u751f\u7269\u79d1\u5b66\u7684\u4e00\u4e2a\u7406\u8bba&#xff0c;\u5b83\u8ba4\u4e3a\u6240\u6709\u751f\u547d\u4f53\u90fd\u662f\u7531\u5fae\u5c0f\u7684\u57fa\u672c\u5355\u5143\u2014\u2014\u7ec6\u80de\u6240\u6784\u6210\u3002\u8fd9\u662f\u751f\u7269\u5b66\u7684\u4e00\u4e2a\u57fa\u7840\u7406\u8bba&#xff0c;\u8ba4\u4e3a\u7ec6\u80de\u662f\u6240\u6709\u751f\u7269\u7684\u57fa\u672c\u7ed3\u6784\u548c\u529f\u80fd\u5355\u4f4d&#xff0c;\u6240\u6709\u7684\u751f\u7269\u90fd\u662f\u7531\u4e00\u4e2a\u6216\u591a\u4e2a\u7ec6\u80de\u7ec4\u6210&#xff0c;\u7ec6\u80de\u53ea\u80fd\u901a\u8fc7\u7ec6\u80de\u5206\u88c2\u4ea7\u751f\u65b0\u7684\u7ec6\u80de\u3002\u8fd9\u4e00\u7406\u8bba\u7531\u859b\u5b9a\u8c14\u3001\u65bd\u74e6\u5185\u548c\u96ea\u83b1\u4e8e1839\u5e74\u9996\u6b21\u63d0\u51fa\u3002<span class=\"token entity\" title=\"\\\\n\">\\\\n<\/span><span class=\"token entity\" title=\"\\\\n\">\\\\n<\/span>\u65e5\u5fc3\u8bf4\u662f\u6307\u592a\u9633\u662f\u592a\u9633\u7cfb\u7684\u4e2d\u5fc3&#xff0c;\u4e5f\u5c31\u662f\u8bf4&#xff0c;\u884c\u661f\u56f4\u7ed5\u592a\u9633\u65cb\u8f6c\u7684\u7406\u8bba\u3002\u8fd9\u4e2a\u7406\u8bba\u6253\u7834\u4e86\u4f20\u7edf\u7684\u5730\u5fc3\u8bf4\u89c2\u70b9&#xff0c;\u8ba4\u4e3a\u5730\u7403\u5e76\u4e0d\u662f\u5b87\u5b99\u7684\u4e2d\u5fc3\u3002\u65e5\u5fc3\u8bf4\u7684\u63d0\u51fa\u8005\u662f\u5c3c\u53e4\u62c9\u00b7\u54e5\u767d\u5c3c&#xff0c;\u4ed6\u572816\u4e16\u7eaa\u521d\u53d1\u8868\u4e86\u4ed6\u7684\u8457\u4f5c\u300a\u5929\u4f53\u8fd0\u884c\u8bba\u300b&#xff0c;\u9610\u8ff0\u4e86\u592a\u9633\u7cfb\u884c\u661f\u56f4\u7ed5\u592a\u9633\u8fd0\u884c\u7684\u6a21\u578b&#xff0c;\u4e3a\u5929\u6587\u5b66\u7684\u53d1\u5c55\u505a\u51fa\u4e86\u5de8\u5927\u8d21\u732e\u3002&#034;<\/span><br \/>\n  <span class=\"token punctuation\">}<\/span>,<br \/>\n  <span class=\"token punctuation\">{<\/span><br \/>\n    <span class=\"token string\">&#034;instruction&#034;<\/span><span class=\"token builtin class-name\">:<\/span> <span class=\"token string\">&#034;\u8f93\u5165\u4e09\u652f\u7bee\u7403\u961f\u7684\u540d\u79f0\u5e76\u751f\u6210\u4e00\u4e2a\u9002\u5f53\u7684\u53e3\u53f7\u3002&#034;<\/span>,<br \/>\n    <span class=\"token string\">&#034;input&#034;<\/span><span class=\"token builtin class-name\">:<\/span> <span class=\"token string\">&#034;\u8f93\u5165&#xff1a;\u4fc4\u514b\u62c9\u8377\u9a6c\u57ce\u96f7\u9706\u961f&#xff0c;\u829d\u52a0\u54e5\u516c\u725b\u961f&#xff0c;\u5e03\u9c81\u514b\u6797\u7f51\u961f\u3002&#034;<\/span>,<br \/>\n    <span class=\"token string\">&#034;output&#034;<\/span><span class=\"token builtin class-name\">:<\/span> <span class=\"token string\">&#034;\u8f93\u51fa&#xff1a; <span class=\"token entity\" title=\"\\\\&#034;\">\\\\&#034;<\/span>\u96f7\u9706&#xff0c;\u516c\u725b\u548c\u7f51\u961f&#xff1a;\u5404\u663e\u795e\u901a&#xff0c;\u89d2\u9010\u7fa4\u96c4!<span class=\"token entity\" title=\"\\\\&#034;\">\\\\&#034;<\/span>&#034;<\/span><br \/>\n  <span class=\"token punctuation\">}<\/span>,<br \/>\n  <span class=\"token punctuation\">{<\/span><br \/>\n    <span class=\"token string\">&#034;instruction&#034;<\/span><span class=\"token builtin class-name\">:<\/span> <span class=\"token string\">&#034;\u6bd4\u8f83\u4ee5\u4e0b\u4e24\u4f4d\u8457\u540d\u4eba\u7269&#xff0c;\u4f7f\u7528\u7279\u5f81\u5217\u8868\u5e76\u4ee5\u53e5\u5b50\u5f62\u5f0f\u63d0\u4f9b\u8f93\u51fa\u3002&#034;<\/span>,<br \/>\n    <span class=\"token string\">&#034;input&#034;<\/span><span class=\"token builtin class-name\">:<\/span> <span class=\"token string\">&#034;\u4eba\u72691&#xff1a;\u963f\u5c14\u4f2f\u7279\u00b7\u7231\u56e0\u65af\u5766<span class=\"token entity\" title=\"\\\\n\">\\\\n<\/span>\u4eba\u72692&#xff1a;\u65af\u8482\u82ac\u00b7\u970d\u91d1<span class=\"token entity\" title=\"\\\\n\">\\\\n<\/span>\u7279\u5f81&#xff1a;\u667a\u529b\u3001\u6559\u80b2\u3001\u5bf9\u4e16\u754c\u7684\u5f71\u54cd&#034;<\/span>,<br \/>\n    <span class=\"token string\">&#034;output&#034;<\/span><span class=\"token builtin class-name\">:<\/span> <span class=\"token string\">&#034;\u963f\u5c14\u4f2f\u7279\u00b7\u7231\u56e0\u65af\u5766\u548c\u65af\u8482\u82ac\u00b7\u970d\u91d1\u90fd\u662f\u62e5\u6709\u6781\u5176\u51fa\u8272\u667a\u529b\u7684\u4eba\u7269\u3002\u4e24\u4eba\u90fd\u53d6\u5f97\u8fc7\u975e\u5e38\u9ad8\u7684\u6559\u80b2\u6210\u5c31&#xff0c;\u4ed6\u4eec\u63a8\u8fdb\u4e86\u79d1\u5b66\u53d1\u5c55\u5e76\u5728\u4e16\u754c\u8303\u56f4\u5185\u4ea7\u751f\u4e86\u6df1\u8fdc\u7684\u5f71\u54cd\u3002\u7231\u56e0\u65af\u5766\u4ee5\u5176\u76f8\u5bf9\u8bba\u548c\u8d28\u80fd\u5173\u7cfb\u516c\u5f0f\u800c\u95fb\u540d&#xff0c;\u800c\u970d\u91d1\u4ee5\u5176\u5173\u4e8e\u9ed1\u6d1e\u548c\u5b87\u5b99\u7684\u53d1\u73b0\u800c\u8457\u79f0\u3002\u4e24\u4f4d\u79d1\u5b66\u5bb6\u90fd\u4ee5\u5176\u6df1\u539a\u7684\u5b66\u8bc6\u548c\u975e\u51e1\u7684\u8d21\u732e\u5f71\u54cd\u4e86\u4e16\u754c\u3002&#034;<\/span><br \/>\n  <span class=\"token punctuation\">}<\/span>,<br \/>\n  <span class=\"token punctuation\">{<\/span><br \/>\n    <span class=\"token string\">&#034;instruction&#034;<\/span><span class=\"token builtin class-name\">:<\/span> <span class=\"token string\">&#034;\u8bf7\u6839\u636e\u4ee5\u4e0b\u6587\u7ae0\u6784\u5efa\u4e00\u4e2a\u9700\u8981\u56de\u7b54\u7684\u95ee\u9898\u3002&#034;<\/span>,<br \/>\n    <span class=\"token string\">&#034;input&#034;<\/span><span class=\"token builtin class-name\">:<\/span> <span class=\"token string\">&#034;&#034;<\/span>,<br \/>\n    <span class=\"token string\">&#034;output&#034;<\/span><span class=\"token builtin class-name\">:<\/span> <span class=\"token string\">&#034;\u6211\u4e0d\u597d\u610f\u601d&#xff0c;\u60a8\u6ca1\u6709\u63d0\u4f9b\u4efb\u4f55\u4fe1\u606f\u6216\u6587\u7ae0\u6765\u4f9b\u6211\u6839\u636e\u5b83\u6784\u5efa\u95ee\u9898\u3002 \u8bf7\u63d0\u4f9b\u76f8\u5e94\u7684\u6587\u7ae0\u6216\u4fe1\u606f&#xff0c;\u4ee5\u4fbf\u6211\u80fd\u591f\u5e2e\u52a9\u60a8\u6784\u5efa\u95ee\u9898\u3002&#034;<\/span><br \/>\n  <span class=\"token punctuation\">}<\/span><br \/>\n<span class=\"token punctuation\">]<\/span><\/p>\n<p>\u5c06\u8bad\u7ec3\u6570\u636e\u96c6\u6587\u4ef6\u653e\u5230llama-factory\u5de5\u7a0b\u4e0b\u7684data\u76ee\u5f55\u4e0b&#xff0c;\u7136\u540e\u4fee\u6539data\/dataset_info.json\u6587\u4ef6&#xff0c;\u589e\u52a0\u6570\u636e\u96c6\u7684\u5165\u53e3\u548c\u76ee\u5f55&#xff0c;\u5982\u679c\u6211\u4eec\u5728data\u4e0b\u653e\u4e86\u4e00\u4e2aalpaca_zh_demo.json\u6587\u4ef6&#xff0c;\u5219\u8981\u589e\u52a0\u7684\u5185\u5bb9\u5982\u4e0b&#xff1a; <img decoding=\"async\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/04\/20250419062106-680340d29af8e.png\" alt=\"\u5728\u8fd9\u91cc\u63d2\u5165\u56fe\u7247\u63cf\u8ff0\" \/><\/p>\n<h3>\u4fee\u6539\u8bad\u7ec3\u4efb\u52a1\u7684\u914d\u7f6e\u6587\u4ef6<\/h3>\n<p>\u5728examples\\\\lora_multi_npu\\\\\u76ee\u5f55\u4e0b\u65b0\u5efa\u4e00\u4e2a\u914d\u7f6e\u6587\u4ef6&#xff08;\u53ef\u4ee5\u4ece\u5df2\u6709\u7684\u6587\u4ef6\u62f7\u8d1d\u8fc7\u53bb\u4fee\u6539&#xff09;\u3002\u6bd4\u5982 \u6211\u65b0\u5efa\u7684\u6587\u4ef6\u53ebbaichuan2_lora_sft_ds.yaml&#xff0c;\u5185\u5bb9\u5982\u4e0b&#xff1a;<\/p>\n<p><span class=\"token comment\">### model<\/span><br \/>\nmodel_name_or_path: \/home\/xxxx\/Baichuan2-13B-Chat\/<\/p>\n<p><span class=\"token comment\">#\/home\/mindformer_share\/baichuan-inc\/Baichuan2-13B-Chat\/<\/span><\/p>\n<p><span class=\"token comment\">### method<\/span><br \/>\nstage: sft<br \/>\ndo_train: <span class=\"token boolean\">true<\/span><br \/>\nfinetuning_type: lora<br \/>\nlora_target: all<\/p>\n<p><span class=\"token comment\">### ddp<\/span><br \/>\nddp_timeout: <span class=\"token number\">180000000<\/span><br \/>\ndeepspeed: examples\/deepspeed\/ds_z0_config.json<\/p>\n<p><span class=\"token comment\">### dataset<\/span><br \/>\ndataset: alpaca_zh_demo<br \/>\ntemplate: baichuan2<br \/>\ncutoff_len: <span class=\"token number\">1024<\/span><br \/>\nmax_samples: <span class=\"token number\">1000<\/span><br \/>\noverwrite_cache: <span class=\"token boolean\">true<\/span><br \/>\npreprocessing_num_workers: <span class=\"token number\">16<\/span><\/p>\n<p><span class=\"token comment\">### output<\/span><br \/>\noutput_dir: saves\/Baichuan2-13B-lora-checkpoint<br \/>\nlogging_steps: <span class=\"token number\">10<\/span><br \/>\nsave_steps: <span class=\"token number\">500<\/span><br \/>\nplot_loss: <span class=\"token boolean\">true<\/span><br \/>\noverwrite_output_dir: <span class=\"token boolean\">true<\/span><\/p>\n<p><span class=\"token comment\">### train<\/span><br \/>\nper_device_train_batch_size: <span class=\"token number\">1<\/span><br \/>\ngradient_accumulation_steps: <span class=\"token number\">2<\/span><br \/>\nlearning_rate: <span class=\"token number\">1<\/span>.0e-4<br \/>\nnum_train_epochs: <span class=\"token number\">5.0<\/span><br \/>\nlr_scheduler_type: cosine<br \/>\nwarmup_ratio: <span class=\"token number\">0.1<\/span><br \/>\nfp16: <span class=\"token boolean\">true<\/span><\/p>\n<p><span class=\"token comment\">### eval<\/span><br \/>\nval_size: <span class=\"token number\">0.1<\/span><br \/>\nper_device_eval_batch_size: <span class=\"token number\">1<\/span><br \/>\neval_strategy: steps<br \/>\neval_steps: <span class=\"token number\">500<\/span><\/p>\n<p>\u9700\u8981\u4fee\u6539\u7684\u51e0\u4e2a\u5b57\u6bb5\u5982\u4e0b&#xff1a;<\/p>\n<ul>\n<li>\u6a21\u578b\u76ee\u5f55&#xff1a;model_name_or_path<\/li>\n<li>\u8f93\u51fa\u76ee\u5f55&#xff1a;output_dir<\/li>\n<li>\u8bad\u7ec3\u8f6e\u6570&#xff1a;num_train_epochs<\/li>\n<li>\u4f7f\u7528\u7684\u6570\u636e\u96c6\u540d\u79f0&#xff08;\u4e5f\u5c31\u662f\u5728dataset_info.json\u589e\u52a0\u7684\u6570\u636e\u96c6\u5165\u53e3&#xff09;&#xff1a;dataset<\/li>\n<li>\u6a21\u578b\u67b6\u6784&#xff08;constants.py\u6587\u4ef6\u4e2d\u6709\u6240\u6709\u652f\u6301\u7684\u6a21\u578b\u67b6\u6784\u540d\u79f0&#xff09;&#xff1a;template<\/li>\n<\/ul>\n<p>\u5176\u5b83\u53c2\u6570\u53ef\u4ee5\u770b\u81ea\u5df1\u9700\u8981\u6765\u4fee\u6539\u3002<\/p>\n<h3>\u6267\u884c\u8bad\u7ec3\u547d\u4ee4<\/h3>\n<p>\u4e0a\u9762\u5df2\u7ecf\u51c6\u5907\u4e86\u6570\u636e\u96c6&#xff0c;\u4e5f\u65b0\u589e\u4e86\u8bad\u7ec3\u7684\u914d\u7f6e\u6587\u4ef6&#xff0c;\u4e0b\u9762\u5c31\u53ef\u4ee5\u6267\u884c\u8bad\u7ec3\u547d\u4ee4&#xff1a;<\/p>\n<p>ASCEND_RT_VISIBLE_DEVICES&#061;0<span class=\"token punctuation\">,<\/span>1<span class=\"token punctuation\">,<\/span>2<span class=\"token punctuation\">,<\/span>3 llamafactory-<span class=\"token function\">cli<\/span> train examples\/lora_multi_npu\/baichuan2_lora_sft_ds<span class=\"token punctuation\">.<\/span>yaml<\/p>\n<p>\u7528\u5230\u51e0\u5f20\u663e\u5361&#xff0c;\u5728ASCEND_RT_VISIBLE_DEVICES\u540e\u9762\u6307\u5b9a\u5c31\u597d\u4e86\u3002<\/p>\n<p>\u8bad\u7ec3\u6267\u884c\u5b8c\u6bd5&#xff0c;\u5728baichuan2_lora_sft_ds.yaml\u7684out\u914d\u7f6e\u7684\u76ee\u5f55\u4e0b\u56de\u751f\u6210\u8bad\u7ec3\u597d\u7684lora\u6a21\u578b&#xff1a; <img decoding=\"async\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/04\/20250419062106-680340d2bf5ed.png\" alt=\"\u5728\u8fd9\u91cc\u63d2\u5165\u56fe\u7247\u63cf\u8ff0\" \/><\/p>\n<h3>\u5982\u4f55\u4f7f\u7528lora\u8bad\u7ec3\u7684\u6a21\u578b<\/h3>\n<p>\u53c2\u8003\u6211\u524d\u9762\u4e00\u7bc7\u535a\u5ba2\u300a\u5728\u6607\u817e\u5f00\u53d1\u73af\u5883\u5408\u5e76baichuan2-13B\u6a21\u578b\u7684lora\u6587\u4ef6\u300b<\/p>\n<h3>\u95ee\u9898\u7eaa\u5f55<\/h3>\n<h4>\u95ee\u98981<\/h4>\n<h5>\u95ee\u9898\u65e5\u5fd7<\/h5>\n<p>    raise ValueError<span class=\"token punctuation\">(<\/span><span class=\"token string\">&#034;Tried to use <span class=\"token variable\"><span class=\"token variable\">&#096;<\/span>fp16<span class=\"token variable\">&#096;<\/span><\/span> but it is not supported on cpu&#034;<\/span><span class=\"token punctuation\">)<\/span><br \/>\nValueError: Tried to use <span class=\"token variable\"><span class=\"token variable\">&#096;<\/span>fp16<span class=\"token variable\">&#096;<\/span><\/span> but it is not supported on cpu<\/p>\n<h6>\u95ee\u9898\u539f\u56e0<\/h6>\n<p>\u6211\u53ea\u6620\u5c04\u4e86\u4e00\u5f20NPU&#xff0c;\u800c\u4e14\u5361\u53f7\u662f7&#xff08;\/dev\/davinci7&#xff09;,\u4f46\u662f\u542f\u52a8\u8bad\u7ec3\u7684ASCEND_RT_VISIBLE_DEVICES&#061;7&#xff0c;\u8fd9\u6837\u5c31\u4f1a\u6709\u95ee\u9898\u3002<\/p>\n<h5>\u89e3\u51b3\u529e\u6cd5<\/h5>\n<p>\u6539\u4e3a ASCEND_RT_VISIBLE_DEVICES&#061;0<\/p>\n<h4>\u95ee\u98982<\/h4>\n<h5>\u95ee\u9898\u65e5\u5fd7<\/h5>\n<p>AttributeError: <span class=\"token string\">&#039;PeftModelForCausalLM&#039;<\/span> object has no attribute <span class=\"token string\">&#039;save_checkpoint&#039;<\/span><\/p>\n<p>AttributeError: <span class=\"token string\">&#039;LoraModel&#039;<\/span> object has no attribute <span class=\"token string\">&#039;save_checkpoint&#039;<\/span><\/p>\n<p>AttributeError: <span class=\"token string\">&#039;BaichuanForCausalLM&#039;<\/span> object has no attribute <span class=\"token string\">&#039;save_checkpoint&#039;<\/span><\/p>\n<h5>\u95ee\u9898\u539f\u56e0<\/h5>\n<p>\u4f7f\u7528\u7684\u5355\u673a\u5355\u5361&#xff0c;\u4f46\u662f\u914d\u7f6e\u6587\u4ef6\u914d\u7f6e\u4e86deepspeed\u7684\u3002<\/p>\n<h6>\u89e3\u51b3\u529e\u6cd5<\/h6>\n<p>\u9700\u8981\u5728baichuan2_lora_sft_ds.yaml\u5c06deepspeed\u7684\u914d\u7f6e\u6ce8\u91ca\u6389\u3002 <img decoding=\"async\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/04\/20250419062106-680340d2e41af.png\" alt=\"\u5728\u8fd9\u91cc\u63d2\u5165\u56fe\u7247\u63cf\u8ff0\" \/> \u89e3\u51b3\u529e\u6cd5\u53c2\u8003&#xff1a;\u65e0\u6cd5\u4fdd\u5b58\u6a21\u578b<\/p>\n<h3>\u53c2\u8003\u8d44\u6599<\/h3>\n<p>\u4ec0\u4e48\u662f\u6307\u4ee4\u5fae\u8c03&#xff08;LLM&#xff09;<\/p>\n<p>LLaMA-Factory<\/p>\n<p>llama factory \u8bad\u7ec3 TensorBoard \u53ef\u89c6\u5316<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u6587\u7ae0\u6d4f\u89c8\u9605\u8bfb2.7k\u6b21\uff0c\u70b9\u8d5e22\u6b21\uff0c\u6536\u85cf26\u6b21\u3002LoRA \u63d0\u51fa\u5728\u9884\u8bad\u7ec3\u6a21\u578b\u7684\u53c2\u6570\u77e9\u9635\u4e0a\u6dfb\u52a0\u4f4e\u79e9\u5206\u89e3\u77e9\u9635\u6765\u8fd1\u4f3c\u6bcf\u5c42\u7684\u53c2\u6570\u66f4\u65b0\uff0c\u4ece\u800c\u51cf\u5c11\u9002\u914d\u4e0b\u6e38\u4efb\u52a1\u6240\u9700\u8981\u8bad\u7ec3\u7684\u53c2\u6570\u3002_llamafactory \u6607\u817e<\/p>\n","protected":false},"author":2,"featured_media":26007,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[347,75,2067,2068,50,2066,956,86],"topic":[],"class_list":["post-26011","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-server","tag-llama","tag-llm","tag-lora","tag-nlp","tag-50","tag-2066","tag-956","tag-86"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v20.3 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>\u5728\u6607\u817e\u670d\u52a1\u5668\u4e0a\u4f7f\u7528llama-factory\u5bf9baichuan2-13b\u6a21\u578b\u8fdb\u884clora\u5fae\u8c03 - \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\/26011.html\" \/>\n<meta property=\"og:locale\" content=\"zh_CN\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"\u5728\u6607\u817e\u670d\u52a1\u5668\u4e0a\u4f7f\u7528llama-factory\u5bf9baichuan2-13b\u6a21\u578b\u8fdb\u884clora\u5fae\u8c03 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\" \/>\n<meta property=\"og:description\" content=\"\u6587\u7ae0\u6d4f\u89c8\u9605\u8bfb2.7k\u6b21\uff0c\u70b9\u8d5e22\u6b21\uff0c\u6536\u85cf26\u6b21\u3002LoRA \u63d0\u51fa\u5728\u9884\u8bad\u7ec3\u6a21\u578b\u7684\u53c2\u6570\u77e9\u9635\u4e0a\u6dfb\u52a0\u4f4e\u79e9\u5206\u89e3\u77e9\u9635\u6765\u8fd1\u4f3c\u6bcf\u5c42\u7684\u53c2\u6570\u66f4\u65b0\uff0c\u4ece\u800c\u51cf\u5c11\u9002\u914d\u4e0b\u6e38\u4efb\u52a1\u6240\u9700\u8981\u8bad\u7ec3\u7684\u53c2\u6570\u3002_llamafactory \u6607\u817e\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.wsisp.com\/helps\/26011.html\" \/>\n<meta property=\"og:site_name\" content=\"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\" \/>\n<meta property=\"article:published_time\" content=\"2025-04-19T06:21:08+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/04\/20250419062106-680340d276018.png\" \/>\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\/26011.html\",\"url\":\"https:\/\/www.wsisp.com\/helps\/26011.html\",\"name\":\"\u5728\u6607\u817e\u670d\u52a1\u5668\u4e0a\u4f7f\u7528llama-factory\u5bf9baichuan2-13b\u6a21\u578b\u8fdb\u884clora\u5fae\u8c03 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\",\"isPartOf\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/#website\"},\"datePublished\":\"2025-04-19T06:21:08+00:00\",\"dateModified\":\"2025-04-19T06:21:08+00:00\",\"author\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41\"},\"breadcrumb\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/26011.html#breadcrumb\"},\"inLanguage\":\"zh-Hans\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.wsisp.com\/helps\/26011.html\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/26011.html#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"\u9996\u9875\",\"item\":\"https:\/\/www.wsisp.com\/helps\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"\u5728\u6607\u817e\u670d\u52a1\u5668\u4e0a\u4f7f\u7528llama-factory\u5bf9baichuan2-13b\u6a21\u578b\u8fdb\u884clora\u5fae\u8c03\"}]},{\"@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":"\u5728\u6607\u817e\u670d\u52a1\u5668\u4e0a\u4f7f\u7528llama-factory\u5bf9baichuan2-13b\u6a21\u578b\u8fdb\u884clora\u5fae\u8c03 - \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\/26011.html","og_locale":"zh_CN","og_type":"article","og_title":"\u5728\u6607\u817e\u670d\u52a1\u5668\u4e0a\u4f7f\u7528llama-factory\u5bf9baichuan2-13b\u6a21\u578b\u8fdb\u884clora\u5fae\u8c03 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","og_description":"\u6587\u7ae0\u6d4f\u89c8\u9605\u8bfb2.7k\u6b21\uff0c\u70b9\u8d5e22\u6b21\uff0c\u6536\u85cf26\u6b21\u3002LoRA \u63d0\u51fa\u5728\u9884\u8bad\u7ec3\u6a21\u578b\u7684\u53c2\u6570\u77e9\u9635\u4e0a\u6dfb\u52a0\u4f4e\u79e9\u5206\u89e3\u77e9\u9635\u6765\u8fd1\u4f3c\u6bcf\u5c42\u7684\u53c2\u6570\u66f4\u65b0\uff0c\u4ece\u800c\u51cf\u5c11\u9002\u914d\u4e0b\u6e38\u4efb\u52a1\u6240\u9700\u8981\u8bad\u7ec3\u7684\u53c2\u6570\u3002_llamafactory \u6607\u817e","og_url":"https:\/\/www.wsisp.com\/helps\/26011.html","og_site_name":"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","article_published_time":"2025-04-19T06:21:08+00:00","og_image":[{"url":"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/04\/20250419062106-680340d276018.png"}],"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\/26011.html","url":"https:\/\/www.wsisp.com\/helps\/26011.html","name":"\u5728\u6607\u817e\u670d\u52a1\u5668\u4e0a\u4f7f\u7528llama-factory\u5bf9baichuan2-13b\u6a21\u578b\u8fdb\u884clora\u5fae\u8c03 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","isPartOf":{"@id":"https:\/\/www.wsisp.com\/helps\/#website"},"datePublished":"2025-04-19T06:21:08+00:00","dateModified":"2025-04-19T06:21:08+00:00","author":{"@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41"},"breadcrumb":{"@id":"https:\/\/www.wsisp.com\/helps\/26011.html#breadcrumb"},"inLanguage":"zh-Hans","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.wsisp.com\/helps\/26011.html"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.wsisp.com\/helps\/26011.html#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"\u9996\u9875","item":"https:\/\/www.wsisp.com\/helps"},{"@type":"ListItem","position":2,"name":"\u5728\u6607\u817e\u670d\u52a1\u5668\u4e0a\u4f7f\u7528llama-factory\u5bf9baichuan2-13b\u6a21\u578b\u8fdb\u884clora\u5fae\u8c03"}]},{"@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\/26011","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=26011"}],"version-history":[{"count":0,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts\/26011\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/media\/26007"}],"wp:attachment":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/media?parent=26011"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/categories?post=26011"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/tags?post=26011"},{"taxonomy":"topic","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/topic?post=26011"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}