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

相关推荐
JouYY1 小时前
大模型底层学习(二)- 预训练(Pre-training)流程概览
架构·llm·agent
zzzll11112 小时前
Agent 开发的五种架构范式及选型思路
人工智能·架构·大模型·llm
浮生望2 小时前
React+TS+Tailwind实战:在浏览器里跑DeepSeek-R1端侧模型
llm
吃饱了得干活2 小时前
LangChain Agent 高级玩法:命名、结构化输出与流式模式
langchain·llm·agent
AINative软件工程5 小时前
LLM 生产环境的 Prompt 注入防御工程实践:5 层防护体系与真实攻防案例
llm·ai编程
smartfish_liu15 小时前
LLM.deepseek: 2026-7-24工作总结
llm·agent
小林ixn15 小时前
大模型的“高考成绩单”:读懂Benchmark,选对真·生产力模型
人工智能·llm·测试
冬奇Lab15 小时前
AI 评测系列(04):RAG 评测——RAGAS 四指标实战与一个反直觉发现
人工智能·llm·agent
Darling噜啦啦16 小时前
GPT-5.6 意味着什么?从 Benchmark 跑分到模型分层,读懂 AI 行业的三个真相
llm
吴佳浩19 小时前
今天我们讲讲大模型的“核心”技术:蒸馏(Model Distillation)
人工智能·llm·agent