【实战】minigpt4的体验和微调

MiniGPT-4

https://github.com/vision-cair/minigpt-4

1 环境配置

1.1 安装环境

git lfs install
//如果报错 :git: 'lfs' is not a git command. See 'git --help'.
//尝试使用:
sudo apt-get install git-lfs
git lfs install

1.2 准备Vicuna权重

(1)下载 Vicuna’s delta weight

git lfs install
git clone https://huggingface.co/lmsys/vicuna-13b-delta-v0  # more powerful, need at least 24G gpu memory
# or
git clone https://huggingface.co/lmsys/vicuna-7b-delta-v0  # smaller, need 12G gpu memory

(2)填写表格以获得原始的LLAMA-7B或LLAMA-13B权重
这个东西其实也不用这么老实,直接huggingface上拉下来就行
(3)下载兼容library

pip install git+https://github.com/lm-sys/FastChat.git@v0.1.10

(4)创建最终权重

python -m fastchat.model.apply_delta --base /path/to/llama-13bOR7b-hf/  --target /path/to/save/working/vicuna/weight/  --delta /path/to/vicuna-13bOR7b-delta-v0/

同时修改minigpt4/configs/models/minigpt4.yaml中llama_model的路径
报错:

Tokenizer class LLaMATokenizer does not exist or is not currently imported.

参考#59将llama-13b-hf/tokenizer_config.json 中的"tokenizer_class": “LLaMATokenizer” 改成 “tokenizer_class”: “LlamaTokenizer”

1.3 下载预训练权重

百度网盘: Vicuna 7B:

谷歌:Vicuna 13B
https://drive.google.com/file/d/1a4zLvaiDBr-36pasffmgpvH5P7CKmpze/view
Vicuna 7B:
https://drive.google.com/file/d/1RY9jV0dyqLX-o38LrumkKRh6Jtaop58R/view

同时修改配置文件中路径到实际下载路径

2. 体验

python demo.py --cfg-path eval_configs/minigpt4_eval.yaml  --gpu-id 0

在这里插入图片描述

3.微调

预训练贫困小孩就算了,不过就算是微调至少要16G

train_configs/minigpt4_stage2_finetune.yaml配置

  weight_decay: 0.05
  max_epoch: 5
  iters_per_epoch: 20
  batch_size_train: 1 #12
  batch_size_eval: 1 #12
  num_workers: 2
  warmup_steps: 200

修改两个路径
(1)train_configs/minigpt4_stage2_pretrain.yaml为第一阶段的训练checkpoint
(2minigpt4/configs/datasets/cc_sbu/align.yaml修改为数据集路径

官方有提供训练集和第一阶段预训练模型

训练集格式如下:

{“annotations”: [{“image_id”: “2”, “caption”: “The image shows a man
fishing on a lawn next to a river with a bridge in the background.
Trees can be seen on the other side of the river, and the sky is
cloudy.”}
对应图片:
在这里插入图片描述

NUM_GPU为自己的gpu数量

torchrun --nproc-per-node NUM_GPU train.py --cfg-path train_configs/minigpt4_stage2_finetune.yaml
  • 0
    点赞
  • 12
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
第 1 章入门 l 1 . 1 SPring 风云再起 l 1 . 1 . 1 重新认识 SPring 2 1 . 1 . 2 SPring Boot 精要 3 1 . 1 . 3 SPring Boot 不是什么 6 1 . 2 SpringB0ot 人门 6 1 . 2 . !安装 SPring BootCU 7 1 . 2 . 2 使用 Spring Initializr 初始化 Spring Boot 项目 10 1 . 3 小结 18 第 2 章开发第一个应用程序 19 2 . 1 运用 Spring Boot 19 2 . 1 . 1 查看初始化的 Spring soot 新项目 21 21 . 2 Spring Boot 项目构建过程解析 24 2 . 2 使川起步依赖, 27 2 . 2 . 1 指定基于功能的依赖 28 2 . 2 . 2 覆盖起步依赖引入的传递依赖… 29 2 . 3 使用自动配且 30 2 . 3 . 1 专注于应用程序功能 31 2 . 3 . 2 运行应用程序 36 2 . 3 , 3 刚刚发生了什么 38 2 . 4 小结 41 第 3 章自定义配置 42 3 . !覆盖 SPring Boot 自动配丑 42 3 . 1 . 1 保护应用程序 43 3 . 2 通过属性文件外且配且 49 3 . 2 . 1 自动配置微调 50 3 . 2 . 2 应用程序 Bean 的配置外置 55 3 . 2 . 3 使用 Profilc 进行配呈 59 3 . 3 定制应用程序错误页面 62 3 . 4 小结 64 第 4 章测试 “ 4 . 1 集成测试自动配置 “ 4 . 2 测试 Web 应用程序 68 4 . 2 . !模拟 SPring MVC, 69 4 . 2 . 2 侧试 Wcb 安全 72 4 . 3 测试运行中的应用程序 74 4 . 3 . 1 用随机端口启动服务器, 75 4 . 3 . 2 使用 Sclcniuln 沮 11 试 HTML 页面 76 4 . 4 小结 78 第 5 章 Groovy 与 Spring Boot CLI 80 5 . 1 开发 SPring Boot CLI 应用程序 80 5 . 1 . 1 设置 CU 项目 81 5 . 1 . 2 通过 Groovy 消除代码嗓声 引 5 . 1 . 3 发生了什么 85 5 . 2 获取依赖 86 5 . 2 . 1 覆盖双认依赖版本 87 5 . 2 . 2 添加依赖仓库 88 5 . 3 用 CLI 运行测试 89 5 . 4 创建可部署的产物,, , … 91 5 . 5 小结 91

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值