【ms-swift 大模型微调实战】

安装环境

下载模型

  • modelscope download --model Qwen/Qwen2.5-7B-Instruct --local_dir ./Qwen2.5-7B-Instruct

微调

  • 实验环境:4 * A100# 显存占用:4 * 70GB

    复制代码
      NPROC_PER_NODE=4 CUDA_VISIBLE_DEVICES=0,1,2,3 swift sft \
          --model_type qwen2_5-72b-instruct \
          --model_id_or_path Qwen2.5-72B-Instruct \
          --dataset qwen2-pro-en#500 qwen2-pro-zh#500 self-cognition#500 \
          --logging_steps 5 \
          --learning_rate 1e-4 \
          --output_dir output \ 
          --lora_target_modules ALL \
          --model_name 小黄 'Xiao Huang' \
          --model_author 魔搭 ModelScope \
          --deepspeed default-zero3
  • 单卡A10/3090可运行的例子 (Qwen2.5-7B-Instruct)# 显存占用:24GB

    复制代码
    	CUDA_VISIBLE_DEVICES=0 swift sft \
      --model_type qwen2_5-7b-instruct \
      --model_id_or_path Qwen2.5-7B-Instruct \
      --dataset qwen2-pro-en#500 qwen2-pro-zh#500 self-cognition#500 \
      --logging_steps 5 \
      --max_length 2048 \
      --learning_rate 1e-4 \
      --output_dir output \
      --lora_target_modules ALL \
      --model_name 小黄 'Xiao Huang' \
      --model_author 魔搭 ModelScope

融合lora

复制代码
CUDA_VISIBLE_DEVICES=0,1 swift export \    
        --ckpt_dir output/qwen2_5-72b-instruct/vx-xxx/checkpoint-xxx \    
        --merge_lora true

vLLM部署

vllm serve xxxxx-checkpoint-merged [opentional args]

参考

相关推荐
小何code11 天前
人工智能【第53篇】大模型微调实战:LoRA与QLoRA技术详解
lora·llama·peft·qlora·大模型微调
cooldream200919 天前
基于 AutoDL 云算力使用 LLaMA Factory 微调大模型及 API 服务搭建完整记录
大模型微调·llama-factory
cooldream200919 天前
利用网络算力使用 Unsloth 实现llama大模型的微调部署调用
大模型微调·llama.cpp·unsloth
Wilber的技术分享25 天前
【大模型面试八股 3】大模型微调技术:LoRA、QLoRA等
人工智能·深度学习·面试·lora·peft·qlora·大模型微调
Joseph Cooper1 个月前
大模型微调技术完全指南:从原理到实践的系统性入门(2026 版)
人工智能·chatgpt·lora·peft·qlora·大模型微调·dpo
m0_650108242 个月前
LoRA:大语言模型低秩适配
论文阅读·lora·大模型微调·经典方法
AI、少年郎2 个月前
MiniMind第 2 篇:破除大模型 “神秘感“, 环境搭建|Win/Linux 本地快速部署
linux·运维·服务器·ai·大模型训练·大模型微调·大模型原理
AI、少年郎2 个月前
MiniMind第 3 篇:底层原理|Decoder-Only 小模型核心:RMSNorm/SwiGLU/RoPE 极简吃透
人工智能·ai编程·大模型训练·大模型微调·大模型原理
gz7seven2 个月前
大模型学习笔记------微调之LoRA
lora·大模型·大模型微调·lora原理