【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]

参考

相关推荐
带电的小王3 天前
【大模型基础_毛玉仁】4.5 实践与应用--参数高效微调PEFT
大模型微调
林泽毅8 天前
Transformers x SwanLab:可视化NLP模型训练(2025最新版)
人工智能·python·深度学习·机器学习·自然语言处理·大模型·大模型微调
_Meilinger_14 天前
大模型微调|使用 LLaMA-Factory 微调 Llama3-8B-Chinese-Chat 完成知识问答任务
大模型·llm·微调·llama·大模型微调·llama-factory·unsloth
Nicolas89314 天前
【大模型实战】利用ms-swift微调框架对QwQ-32B推理模型进行微调
大模型·swift·大模型微调·lora微调·微调框架·推理模型微调·msswift
背太阳的牧羊人15 天前
LLaMA-Factory 训练数据默认使用 instruction、input、output 三个 key
人工智能·llama·大模型微调
冀辉1 个月前
Ubuntu2204下使用NVIDIA GeForce RTX 4090进行DeepSeek-R1-Distill-Llama-8B模型微调
人工智能·sft·大模型微调·unsloth·deepseek蒸馏模型微调
初窺門徑1 个月前
llama-factory部署微调方法(wsl-Ubuntu & Windows)
llama·大模型微调·llama-factory
大鱼>1 个月前
Ubuntu 服务器Llama Factory 搭建DeepSeek-R1微调训练环境
llama·大模型微调·deepseek
小白顶呱呱1 个月前
图解【提示工程 VS 微调 VS RAG、全量微调 VS LoRA微调、TopK VS TopP】截图笔记
笔记·大模型·prompt·rag·大模型微调
Nicolas8933 个月前
【大模型实战篇】LLaMA Factory微调ChatGLM-4-9B模型
大模型·全参微调·大模型微调·glm4·llamafactory·chatglm9b