欢迎来到尧图网

客户服务 关于我们

您的位置:首页 > 健康 > 美食 > 【ms-swift 大模型微调实战】

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

2025/2/23 6:34:18 来源:https://blog.csdn.net/qq_39749966/article/details/143285892  浏览:    关键词:【ms-swift 大模型微调实战】

安装环境

  • pip config set global.index-url https://pypi.tuna.tsinghua.edu.cn/simple
  • pip install modelscope vllm ‘ms-swift[llm]’ -U

下载模型

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

参考

  • Qwen2.5 全链路模型体验、下载、推理、微调、部署实战!
  • https://github.com/modelscope/ms-swift
  • 自定义数据集
  • 微调文档
  • 推理文档

版权声明:

本网仅为发布的内容提供存储空间,不对发表、转载的内容提供任何形式的保证。凡本网注明“来源:XXX网络”的作品,均转载自其它媒体,著作权归作者所有,商业转载请联系作者获得授权,非商业转载请注明出处。

我们尊重并感谢每一位作者,均已注明文章来源和作者。如因作品内容、版权或其它问题,请及时与我们联系,联系邮箱:809451989@qq.com,投稿邮箱:809451989@qq.com

热搜词