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

相关推荐
冬奇Lab9 小时前
Agent 系列(18):成本与性能优化——省钱且更快
人工智能·llm·agent
吴佳浩9 小时前
Hermes vs OpenClaw:基于源码的 Agent Loop 全面分析
人工智能·llm·agent
AndrewHZ11 小时前
【LLM技术全景】规模定律与模型演进:为什么模型越大越强?
人工智能·gpt·深度学习·语言模型·llm·openai·规模定律
装不满的克莱因瓶11 小时前
了解 LangChain 中的 LLM 与 ChatModel 的差异
人工智能·python·ai·langchain·llm·agent·chatmodel
颜酱12 小时前
LangChain 工具调用:从原理、入门到落地
langchain·llm
swipe12 小时前
做多轮对话 Agent,为什么我建议把短期记忆放到 Redis
后端·面试·llm
swipe12 小时前
别再把关系库和向量库拆开了:PostgreSQL 搭建 AI 长期记忆层实战
面试·langchain·llm
元Y亨H15 小时前
大数据转大模型(LLM)进阶学习路线图
大数据·llm
小lan猫19 小时前
用 AI Agent 让购物更便捷:LumiGlow 电商网站实践
前端框架·llm·agent
meilindehuzi_a19 小时前
全栈进阶:告别 Node 繁琐配置,用下一代运行时 Bun 丝滑构建 AI Agent 客户端
人工智能·llm