LlamaFactory微调Qwen3-0.6B大模型步骤

参考文档

1、下载Qwen3-0.6B大模型

2、下载LLaMA-Factory-man项目

3、验证模型推理的效果

cd examples/inference

创建qwen3_0.6B.yaml,里面填入

model_name_or_path: /workspace/codes/deepseek/Qwen3-0.6B

template: qwen

在终端中输入:

GRADIO_SERVER_PORT=8103 llamafactory-cli webchat examples/inference/qwen3_0.6B.yaml

(注:localhost:8103 指的是程序启动机器自身的8103端口,云上的用户可能无法通过本地的笔记本电脑直接访问,需要找云厂商获取域名和端口号的一些配置关系进行配置)

4、加载自定义数据集,符合alpaca格式,并在dataset_info.json中进行注册

5、运行训练脚本

GRADIO_SERVER_PORT=8103 CUDA_VISIBLE_DEVICES=0 llamafactory-cli train

--stage sft

--do_train

--model_name_or_path /workspace/codes/deepseek/Qwen3-0.6B

--dataset alpaca_zh_demo,identity,train

--dataset_dir ./data

--template qwen

--finetuning_type lora

--output_dir ./saves/Qwen3-0.6B/lora/sft

--overwrite_cache

--overwrite_output_dir

--cutoff_len 1024

--preprocessing_num_workers 16

--per_device_train_batch_size 2

--per_device_eval_batch_size 1

--gradient_accumulation_steps 8

--lr_scheduler_type cosine

--logging_steps 50

--warmup_steps 20

--save_steps 100

--eval_steps 50

--save_strategy steps

--eval_strategy steps

--load_best_model_at_end

--learning_rate 5e-5

--num_train_epochs 5.0

--max_samples 1000

--val_size 0.1

--plot_loss

--fp16

6、动态合并LoRA的推理

GRADIO_SERVER_PORT=8103 CUDA_VISIBLE_DEVICES=0 llamafactory-cli webchat

--model_name_or_path /workspace/codes/deepseek/Qwen3-0.6B

--adapter_name_or_path ./saves/Qwen3-0.6B/lora/sft

--template qwen

--finetuning_type lora

7、批量预测和训练效果评估

CUDA_VISIBLE_DEVICES=0 llamafactory-cli train

--stage sft

--do_predict

--model_name_or_path /workspace/codes/deepseek/Qwen3-0.6B

--adapter_name_or_path ./saves/Qwen3-0.6B/lora/sft

--eval_dataset alpaca_zh_demo,identity,train

--dataset_dir ./data

--template qwen

--finetuning_type lora

--output_dir ./saves/Qwen3-0.6B/lora/predict

--overwrite_cache

--overwrite_output_dir

--cutoff_len 1024

--preprocessing_num_workers 16

--per_device_eval_batch_size 1

--max_samples 20

--predict_with_generate

相关推荐
CoderJia程序员甲1 小时前
GitHub 热榜项目 - 周榜(2026-08-30)
ai·大模型·llm·github·ai教程
tachibana22 小时前
Agent 的长短期记忆系统
人工智能·ai·大模型·llm·agent
北落L2 小时前
Embedding:从 Token 到向量表示
llm
leeyi4 小时前
Eino + DeepFlux 实战全景复盘:100 篇,从 5 分钟 Demo 到企业级平台(第100篇-E86)
llm·aigc·agent
阡之尘埃13 小时前
Python数据分析案例85——大模型微调全流程(SFT的LoRA微调)
人工智能·python·深度学习·语言模型·llm·微调·千问
tachibana216 小时前
复杂任务怎么做的任务拆分?
人工智能·ai·大模型·llm·agent
tachibana216 小时前
ReAct、Plan-and-Execute、Reflection 三种范式有什么核心区别
人工智能·ai·大模型·llm·agent
EDPJ21 小时前
(2024|DeepSeek & 北大,Loss-Free Balancing,每专家偏置,QB)MoE 的无辅助损失负载均衡策略
llm·负载均衡·大语言模型·moe
桃西西呀2 天前
GPT-5.6 的 ultra 模式凭什么开 4 个 Agent 并行跑?——多智能体协作,是把"一个聪明人"换成"一个团队"
人工智能·llm·agent