项目地址:
https://github.com/Vision-CAIR/MiniGPT-4
2--配置环境依赖
git clone https://github.com/Vision-CAIR/MiniGPT-4.git
cd MiniGPT-4
conda env create -f environment.yml
conda activate minigpt4
默认配置的环境名为 minigpt4,也可以通过 environment.yml 来修改环境名,这里博主设置的 python 环境为 ljf_minigpt4:
3--下载权重
这里博主选用的 LLaMA 权重为 llama-7b-hf,Vicuna 增量文件为 vicuna-7b-delta-v1.1,对应的下载地址如下:
LLaMA 权重下载地址
Vicuna 增量文件下载地址
这里提供两种下载方式,第一种是基于 huggingface_hub 第三方库进行下载:
pip install huggingface_hub
from huggingface_hub import snapshot_download
snapshot_download(repo_id='decapoda-research/llama-7b-hf')
# 对应的存储地址为:~/.cache/huggingface/hub/models--decapoda-research--llama-7b-hf/snapshots/(一串数字)/
from huggingface_hub import snapshot_download
snapshot_download(repo_id='lmsys/vicuna-7b-delta-v1.1')
# 对应的存储地址为:~.cache/huggingface/hub/models--lmsys--vicuna-7b-delta-v1.1/snapshots/(一串数字)/
第一种下载方式容易出现连接超时的错误,这里提供第二种基于 wget 的下载方式:
# 记录每一个文件的下载url,使用 wget 来下载,download.txt 的内容如下:
https://huggingface.co/decapoda-research/llama-7b-hf/resolve/main/.gitattributes
https://huggingface.co/decapoda-research/llama-7b-hf/resolve/main/LICENSE
https://huggingface.co/decapoda-research/llama-7b-hf/resolve/main/README.md
https://huggingface.co/decapoda-research/llama-7b-hf/resolve/main/config.json
https://huggingface.co/decapoda-research/llama-7b-hf/resolve/main/generation_config.json
https://huggingface.co/decapoda-research/llama-7b-hf/resolve/main/pytorch_model-00001-of-00033.bin
https://huggingface.co/decapoda-research/llama-7b-hf/resolve/main/pytorch_model-00002-of-00033.bin
https://huggingface.co/decapoda-research/llama-7b-hf/resolve/main/pytorch_model-00003-of-00033.bin
https://huggingface.co/decapoda-research/llama-7b-hf/resolve/main/pytorch_model-00004-of-00033.bin
https://huggingface.co/decapoda-research/llama-7b-hf/resolve/main/pytorch_model-00005-of-00033.bin
https://huggingface.co/decapoda-research/llama-7b-hf/resolve/main/pytorch_model-00006-of-00033.bin
https://huggingface.co/decapoda-research/llama-7b-hf/resolve/main/pytorch_model-00007-of-00033.bin
https://huggingface.co/decapoda-research/llama-7b-hf/resolve/main/pytorch_model-00008-of-00033.bin
https://huggingface.co/decapoda-research/llama-7b-hf/resolve/main/pytorch_model-00009-of-00033.bin
https://huggingface.co/decapoda-research/llama-7b-hf/resolve/main/pytorch_model-00010-of-00033.bin
https://huggingface.co/decapoda-research/llama-7b-hf/resolve/main/pytorch_model-00011-of-00033.bin
https://huggingface.co/decapoda-research/llama-7b-hf/resolve/main/pytorch_model-00012-of-00033.bin
https://huggingface.co/decapoda-research/llama-7b-hf/resolve/main/pytorch_model-00013-of-00033.bin
https://huggingface.co/decapoda-research/llama-7b-hf/resolve/main/pytorch_model-00014-of-00033.bin
https://huggingface.co/decapoda-research/llama-7b-hf/resolve/main/pytorch_model-00015-of-00033.bin
https://huggingface.co/decapoda-research/llama-7b-hf/resolve/main/pytorch_model-00016-of-00033.bin
https://huggingface.co/decapoda-research/llama-7b-hf/resolve/main/pytorch_model-00017-of-00033.bin
https://huggingface.co/decapoda-research/llama-7b-hf/resolve/main/pytorch_model-00018-of-00033.bin
https://huggingface.co/decapoda-research/llama-7b-hf/resolve/main/pytorch_model-00019-of-00033.bin
https://huggingface.co/decapoda-research/llama-7b-hf/resolve/main/pytorch_model-00020-of-00033.bin
https://huggingface.co/decapoda-research/llama-7b-hf/resolve/main/pytorch_model-00021-of-00033.bin
https://huggingface.co/decapoda-research/llama-7b-hf/resolve/main/pytorch_model-00022-of-00033.bin
https://huggingface.co/decapoda-research/llama-7b-hf/resolve/main/pytorch_model-00023-of-00033.bin
https://huggingface.co/decapoda-research/llama-7b-hf/resolve/main/pytorch_model-00024-of-00033.bin
https://huggingface.co/decapoda-research/llama-7b-hf/resolve/main/pytorch_model-00025-of-00033.bin
https://huggingface.co/decapoda-research/llama-7b-hf/resolve/main/pytorch_model-00026-of-00033.bin
https://huggingface.co/decapoda-research/llama-7b-hf/resolve/main/pytorch_model-00027-of-00033.bin
https://huggingface.co/decapoda-research/llama-7b-hf/resolve/main/pytorch_model-00028-of-00033.bin
https://huggingface.co/decapoda-research/llama-7b-hf/resolve/main/pytorch_model-00029-of-00033.bin
https://huggingface.co/decapoda-research/llama-7b-hf/resolve/main/pytorch_model-00030-of-00033.bin
https://huggingface.co/decapoda-research/llama-7b-hf/resolve/main/pytorch_model-00031-of-00033.bin
https://huggingface.co/decapoda-research/llama-7b-hf/resolve/main/pytorch_model-00032-of-00033.bin
https://huggingface.co/decapoda-research/llama-7b-hf/resolve/main/pytorch_model-00033-of-00033.bin
https://huggingface.co/decapoda-research/llama-7b-hf/resolve/main/pytorch_model.bin.index.json
https://huggingface.co/decapoda-research/llama-7b-hf/resolve/main/special_tokens_map.json
https://huggingface.co/decapoda-research/llama-7b-hf/resolve/main/tokenizer.model
https://huggingface.co/decapoda-research/llama-7b-hf/resolve/main/tokenizer_config.json
编写 download.sh,下载 download.txt 中所有的文件:
#! /bin/bash
while read file; do
wget ${file}
done < download.txt
同理对于增量文件,记录所有文件的下载 url,通过 wget 下载:
https://huggingface.co/lmsys/vicuna-7b-delta-v1.1/resolve/main/.gitattributes
https://huggingface.co/lmsys/vicuna-7b-delta-v1.1/resolve/main/README.md
https://huggingface.co/lmsys/vicuna-7b-delta-v1.1/resolve/main/config.json
https://huggingface.co/lmsys/vicuna-7b-delta-v1.1/resolve/main/generation_config.json
https://huggingface.co/lmsys/vicuna-7b-delta-v1.1/resolve/main/pytorch_model-00001-of-00002.bin
https://huggingface.co/lmsys/vicuna-7b-delta-v1.1/resolve/main/pytorch_model-00002-of-00002.bin
https://huggingface.co/lmsys/vicuna-7b-delta-v1.1/resolve/main/pytorch_model.bin.index.json
https://huggingface.co/lmsys/vicuna-7b-delta-v1.1/resolve/main/special_tokens_map.json
https://huggingface.co/lmsys/vicuna-7b-delta-v1.1/resolve/main/tokenizer.model
https://huggingface.co/lmsys/vicuna-7b-delta-v1.1/resolve/main/tokenizer_config.json
#! /bin/bash
while read file; do
wget ${file}
done < download.txt
4--生成 Vicuna 权重
安装 FastChat 的 python 库:
pip install git+https://github.com/lm-sys/FastChat.git@v0.1.10
pip install fschat
终端执行以下命令,生成最终的权重文件:
python3 -m fastchat.model.apply_delta \
--base-model-path llama-7b-hf_path \
--target-model-path vicuna-7b_path \
--delta-path vicuna-7b-delta-v1.1_path
--bash-model-path 表示第 3 步中下载的 llama-7b-hf 权重的存放地址;
--target-model-path 表示生成 Vicuna 权重的存放地址;
--delta-path 表示第 3 步中下载的 vicuna-7b-delta-v1.1 权重的存放地址;
5--测试
首先下载测试权重,这里博主选用的是 Checkpoint Aligned with Vicuna 7B:
Checkpoint Aligned with Vicuna 13B 下载地址
Checkpoint Aligned with Vicuna 7B 下载地址
接着配置测试文件:
修改 MiniGPT-4/eval_configs/minigpt4_eval.yaml 配置文件中的 ckpt 路径为 Checkpoint Aligned with Vicuna 7B 的地址:
修改 MiniGPT-4/minigpt4/configs/models/minigpt4.yaml 配置文件中的 llama_model 为第4步生成 Vicuna 权重的存放地址:
执行以下命令启动网页端的 Mini-GPT4:
python demo.py --cfg-path eval_configs/minigpt4_eval.yaml --gpu-id 0
在本机打开 local url 即可,也可以使用其它电脑打开 public url:当然也可以修改提供的demo,无需使用网页端直接在终端测试推理结果:
6--可能出现的问题
① name ‘cuda_setup’ is not defined:
解决方法:
升级 bitsandbytes 库,这里博主选用 0.38.1 版本的 bitsandbytes 解决了问题;
pip install bitsandbytes==0.38.1
升级 bitsandbytes 库,这里博主选用 0.38.1 版本的 bitsandbytes 解决了问题;--delta-path 表示第 3 步中下载的 vicuna-7b-delta-v1.1 权重的存放地址;--bash-model-path 表示第 3 步中下载的 llama-7b-hf 权重的存放地址;--target-model-path 表示生成 Vicuna 权重的存放地址;4--生成 Vicuna 权重。6--可能出现的问题。
GPT-4 是大型多模态模型(large multimodal model),支持图像和文本的输入,并生成文本结果。
这个 thread 会汇总一下有关 GPT-4 的一些信息(包括论文中的一些要点和实际的体验)。
GPT-4 在专业和学术能力的 benchmark 上已经达到了人类水平。
例如模拟律师考试分数占所有应试者的前 10%,而 GPT-3 的测试结果为倒数 10%。
现在想要提前体验的有 2 种方法:
- ChatGPT Plus 订阅(可能不是所有人都有)
- Poe 中已经集成了 GPT-4(同时集成的还有 Claude+ 这个新的 AI)
以下摘要由ChatGPT-3.5 turbo自动生成
我们报道了GPT-4的开发,它是一个大规模、多模态模型,可以接受图像和文本输入,并产生文本输出。虽然在许多现实场景中不如人类,但GPT-4在各种专业和学术基准测试中展现了人类水平的表现,包括在模拟的律师考试中获得了约排名前10%的分数。GPT-4是一个基于Transformer的模型,预训练用于预测文档中的下一个令牌。事后训练的对齐过程提高了其准确性和符合所需行为的表现。该项目的核心组件是开发可在广泛的尺度上可预测行为的基础设施和优化方法。这使我们能够根据只使用GPT-4计算的1/1000的模型训练来准确预测GPT-4的某些方面的表现。
We report the development of GPT-4, a large-scale, multimodal model which can
accept image and text inputs and produce text outputs....
2023年6月新书,适合中高级技术人员参考学习使用。主要内容:
Chapter 1. GPT-4 and ChatGPT Essent?als
Chapter 2. Taking a Deep Dive into the GPT-4 and ChatGPT APIs
Chapter 3. Advanced Techniques to Unlock the Full Potential of GPT-4 and ChatGPT