大模型微调的使用

## 魔搭社区

注册后有免费的100小时的GPU资源
# qwen 微调法律大模型

## 准备环境

# 下载qwen和模型
git clone https://github.com/QwenLM/Qwen.git
git clone https://www.modelscope.cn/qwen/Qwen-1_8B-Chat.git

# 安装依赖
pip install -r requirements.txt

# 安装torch
方法1
下载地址:http://download.pytorch.org/whl/torch_stable.html
wget http://download.pytorch.org/whl/cu121/torch-2.1.1%2Bcu121-cp310-cp310-linux_x86_64.whl
pip install torch-2.1.1+cu121-cp310-cp310-linux_x86_64.whl

方法2
去这个网站上找好对应版本的指令:https://pytorch.org/get-started/previous-versions/
pip install torch==2.1.1+cu121 torchvision==0.15.2+cu121 torchaudio==2.1.1+cu121 torchtext==0.15.2 torchdata==0.6.10 --extra-index-url https://download.pytorch.org/whl/cu121


# 安装deepspeed
pip install "peft<0.8.0" deepspeed
## 微调

准备模型:Qwen-1_8B-Chat

准备训练数据:trans_data.json(训练数据自己准备一个json的)

```
cd Qwen

# 修改微调配置
vim finetune_lora_single_gpu.sh
chmod +x finetune_lora_single_gpu.sh

# 微调,根据需要修改
./finetune_lora_single_gpu.sh -m /mnt/workspace/Qwen-1_8B-Chat -d /mnt/workspace/Qwen/trans_data.json
./finetune_lora_single_gpu.sh -m /mnt/workspace/Qwen/Qwen-1_8B-Chat -d /mnt/workspace/Qwen/new-DISC-Law.json


# 合并模型,模型合并文件 qwen_lora_merge.py,上传到Qwen文件夹里,然后修改微调模型路径
lora_model_path="/mnt/workspace/Qwen/output_qwen/checkpoint-30"
(路径根据自己文件的路径进行修改)
# 合并模型
python qwen_lora_merge.py 
## 测试

### 交互式Demo
```
cd Qwen
python cli_demo.py -c Qwen-1_8B-Chat_merge
```

### Web Demo
```
# 启动服务
python web_demo.py --cpu-only -c=Qwen-1_8B-Chat
# 查看web界面
http://127.0.0.1:8000/
```
  • 7
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

戏羽虞

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值