Skip to content

ssbuild/qwen_vl_finetuning

Repository files navigation

statement

    2024-04-22 简化
    2023-10-19 微调完成
    2023-10-18 初始化

update

install

  • pip install -U -r requirements.txt
  • 如果无法安装 , 可以切换官方源 pip install -i https://pypi.org/simple -U -r requirements.txt

# flash-attention对显卡算例要求算力7.5 以上 , 下面可选安装 ,如果卡不支持可以不安装。
git clone -b v1.0.8 https://github.com/Dao-AILab/flash-attention
cd flash-attention && pip install .
pip install csrc/layer_norm
pip install csrc/rotary

weight

data sample

open_data https://github.com/ssbuild/open_data

单条数据示例

p prefix  optional
q question optional
a answer   must

 {
    "id": 0, 
    "p": null,
    "paragraph": [
         {
             "q": "Picture 1: <img>https://qianwen-res.oss-cn-beijing.aliyuncs.com/Qwen-VL/assets/demo.jpeg</img>\n图中的狗是什么品种?",
             "a":  "图中是一只拉布拉多犬。"
         },
        {
           "q": "框出图中的格子衬衫",
           "a": "<ref>格子衬衫</ref><box>(588,499),(725,789)</box>"
        }
     ]
 }

或者

{
    "id": 0,
    "conversations": [
      {
        "from": "user",
        "value": "Picture 1: <img>https://qianwen-res.oss-cn-beijing.aliyuncs.com/Qwen-VL/assets/demo.jpeg</img>\n图中的狗是什么品种?"
      },
      {
        "from": "assistant",
        "value": "图中是一只拉布拉多犬。"
      },
      {
        "from": "user",
        "value": "框出图中的格子衬衫"
      },
      {
        "from": "assistant",
        "value": "<ref>格子衬衫</ref><box>(588,499),(725,789)</box>"
      }
    ]
  }

infer

# infer.py 推理预训练模型
# infer_finetuning.py 推理微调模型
# infer_lora_finetuning.py 推理lora微调模型
 python infer.py
量化等级 最低 GPU 显存
FP16(无量化) 13 GB
INT8 10 GB
INT4 6 GB

inference

training

    # 制作数据
    cd scripts
    bash train_full.sh -m dataset 
    or
    bash train_lora.sh -m dataset 
    or
    bash train_ptv2.sh -m dataset 
    
    注: num_process_worker 为多进程制作数据 , 如果数据量较大 , 适当调大至cpu数量
    dataHelper.make_dataset_with_args(data_args.train_file,mixed_data=False, shuffle=True,mode='train',num_process_worker=0)
    
    # 全参数训练 
        bash train_full.sh -m train
        
    # lora adalora ia3 
        bash train_lora.sh -m train
        
    # ptv2
        bash train_ptv2.sh -m train

训练参数

训练参数

友情链接

纯粹而干净的代码

Reference

https://github.com/QwenLM/Qwen-VL

Star History

Star History Chart

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published