【实战】minigpt4的体验和微调

news/2024/7/7 20:25:41

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

http://lihuaxi.xjx100.cn/news/1237382.html

相关文章

初识Notes Domino 14 Drop1

大家好,才是真的好。 周末花了点时间,安装了一下Notes Domino 14 Drop1版本。考虑到大多数人的习惯,没采用Docker或K8s方式来部署,也没采用一键配置功能,依旧通过传统方式一步一步进行安装和配置,这样大家…

从微观世界的RST包文视角助力企业网络应用故障排查和优化

1. 前言 随着互联网的普及和发展,各行业的业务和应用越来越依赖于网络。然而,网络环境的不稳定性和复杂性使得出现各种异常现象的概率变得更高了。这些异常现象会导致业务无法正常运行,给用户带来困扰,甚至影响企业的形象和利益。…

Vue3-04-生命周期

Vue 的生命周期描述组件从创建到销毁的全过程。Vue3 和 Vue2 的生命周期钩子非常像,我们仍然可以在相同的场景下使用相同的钩子函数。 Vue3 在设计时对先前的版本进行了向下兼容,如果你的项目还在使用选项式 API 进行构建,那么不需要修改生命…

深入理解深拷贝与浅拷贝

初识深拷贝与浅拷贝 深拷贝与浅拷贝都是Javascript中实现拷贝的一个方式,或许说拷贝有些同学可能不是很理解,其实我们也可以叫他们深复制与浅复制。那么接下来,让我们先了解一下什么是浅拷贝,什么是深拷贝。 浅拷贝 浅拷贝指的…

Kotlin Lambda表达式和匿名函数的组合简直太强了

Kotlin Lambda表达式和匿名函数的组合简直太强了 简介 首先,在 Kotlin 中,函数是“第一公民”(First Class Citizen)。因此,它们可以被分配为变量的值,作为其他函数的参数传递或者函数的返回值。同样&…

DataOps是现代数据堆栈的未来吗?

DevOps 席卷软件工程世界之前,一旦应用程序启动并运行,开发人员就会一头雾水。 工程师不是第一个知道何时发生中断,而是只会发现客户或利益相关者何时抱怨“网站滞后”或 503 页面过多。 不幸的是,这导致了同样的错误反复出现&a…

Definition of regularity in PDE theory

Regularity is one of the vague yet very useful terms to talk about a vast variety of results in a uniform way. Other examples of such words include “dynamics” in dynamical systems (I have never seen a real definition of this term but everyone uses it, an…

python-psutil模块:进程信息获取及杀进程

目录 获取进程信息 Windows杀进程 psutil是跨平台库,能够轻松实现获取系统运行的进程和系统利用率等信息,可用来做系统监控,性能分析,进程管理。 获取进程信息 import psutilpids psutil.pids() for pid in pids:p psutil.…