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

相关推荐
山顶夕景7 小时前
【VLM】Format Decoupled Reinforcement Learning for Document OCR
大模型·llm·ocr·多模态·文档智能·vlm
用什么都重名13 小时前
「实战指南」使用 Python 调用大模型(LLM)
python·大模型·llm·api调用
mumu-hn13 小时前
浅说LLM-Agent(大模型-智能体)
人工智能·llm·agent
人工干智能18 小时前
LangChain的提示模板template中的{tool_names}和{agent_scratchpad}
langchain·llm
一个处女座的程序猿19 小时前
Transformer 之LCW/TTT-E2E:《End-to-End Test-Time Training for Long Context》翻译与解读
llm·transformer·lcw·ttt-e2e
utmhikari20 小时前
【极客日常】快速上手复杂后端项目开发的经验
ai·llm·知识库·系统设计·后端开发·rag
沛沛老爹1 天前
Web转AI架构篇:Agent Skills vs MCP-混合架构设计模式实战指南
java·前端·人工智能·架构·llm·rag
紫小米2 天前
MCP协议与实践
python·llm·mcp协议
沛沛老爹2 天前
Web开发者进阶AI架构:Agent Skills与MCP的企业级架构权衡实战
java·人工智能·架构·llm·llama·rag
sg_knight2 天前
Claude Code 与 ChatGPT、Copilot 有什么区别?
人工智能·chatgpt·llm·copilot·claude·ai大模型·claude-code