LlamaFactory部署及模型微调【win10环境】

发布于:2025-03-29 ⋅ 阅读:(28) ⋅ 点赞:(0)

在这里插入图片描述

1.Llama-Factory简介

LLaMA-Factory,全称 Large Language Model Factory,旨在简化大模型的微调过程,帮助开发者快速适应特定任务需求,提升模型表现。它支持多种预训练模型和微调算法,适用于智能客服、语音识别、机器翻译等多种应用场景。

2.Llama-Factory部署

2.1.git克隆项目

git clone https://github.com/hiyouga/LLaMA-Factory

2.2.基础模块安装

pip install -e ".[torch,metrics]" -i  https://mirrors.aliyun.com/pypi/simple/

在这里插入图片描述

2.3.开启量化

pip install https://github.com/jllllll/bitsandbytes-windows-webui/releases/download/wheels/bitsandbytes-0.41.2.post2-py3-none-win_amd64.whl

2.4.开启FlashAttention-2

如果要在 Windows 平台上开启 FlashAttention-2,需要安装预编译的 flash-attn 库,支持 CUDA 12.1 到 12.2,请根据需求到 flash-attention 下载对应版本安装。

 pip install F:\11-X-AGI\python-whl\flash_attn-2.7.1.post1+cu124torch2.3.1cxx11abiFALSE-cp310-cp310-win_amd64.whl

2.5.torch版本不匹配问题解决

pip uninstall torch torchvision torchaudio -y
pip install torch==2.3.1 torchvision==0.18.1 torchaudio==2.3.1 --index-url https://download.pytorch.org/whl/cu121

2.6.验证torch是否可用

import torch
torch.cuda.current_device()
torch.cuda.get_device_name(0)
torch.__version__
print(torch.cuda.is_available())

3.下载模型

https://huggingface.co/deepseek-ai/DeepSeek-R1-Distill-Qwen-7B/tree/main
在这里插入图片描述
模型文件放置到你可以找到的目录即可

4.启动web-ui

python webui.py

在这里插入图片描述

5.训练模型初体验

界面操作比较简单,选择模型、选择数据集、开始训练
在这里插入图片描述
在这里插入图片描述
微调模型的评估、保存、挂载等操作都是界面上显而易见的操作,不再赘述。