环境要求
- python 3.8 and above
- pytorch 1.12 and above, 2.0 and above are recommended
- transformers 4.32 and above
- CUDA 11.4 and above are recommended (this is for GPU users, flash-attention users, etc.)
微调步骤
1. 资源下载
Qwen:https://github.com/QwenLM/Qwen
qwen1_8B模型:https://modelscope.cn/models/Qwen/Qwen-1_8B-Chat
torch:https://download.pytorch.org/whl/torch_stable.html
flash-attention:https://github.com/Dao-AILab/flash-attention/releases/
2. 环境安装
conda create -n qwen python==3.10.1
# 安装torch
pip install "F:\llm\ptorch\torch-2.1.2+cu121-cp310-cp310-win_amd64.whl"
# 依赖
cd F:\github\Qwen
pip install -r requirements.txt
# 模型推理 web依赖包 图形化界面
pip install -r requirements_web_demo.txt
# 直接安装如果有问题,那就手动下载,本地安装
pip install "peft<0.8.0" deepspeed
# 非必须,模型加速,使用上面的连接下载到本地然后安装,手动编译我3个小时没编译完
pip install F:\llm\flash_attn-2.4.1+cu121torch2.1cxx11abiFALSE-cp310-cp310-win_amd64.whl
# 模型
git clone https://www.modelscope.cn/Qwen/Qwen-1_8B-Chat.git
3. 准备微调数据
看官网的微调格式:
[{
"id":"identity_0","conversations":[{
"from":"user","value":"你好"},{
"from":"assistant","value":"我是一个语言模型,我叫通义千问。"}]}]
准备数据如下:
DISC-Law-SFT-Triplet-released-Qwen.json<