minigpt-4 本地部署

minigpt-4 git主页。
笔者参考了深度学习笔记–本地部署Mini-GPT4,使用了http链接,

huggingface下载llama和vicuna权重的download.txt分别如下:

http://huggingface.co/decapoda-research/llama-7b-hf/resolve/main/.gitattributes
http://huggingface.co/decapoda-research/llama-7b-hf/resolve/main/LICENSE
http://huggingface.co/decapoda-research/llama-7b-hf/resolve/main/README.md
http://huggingface.co/decapoda-research/llama-7b-hf/resolve/main/config.json
http://huggingface.co/decapoda-research/llama-7b-hf/resolve/main/generation_config.json
http://huggingface.co/decapoda-research/llama-7b-hf/resolve/main/pytorch_model-00001-of-00033.bin
http://huggingface.co/decapoda-research/llama-7b-hf/resolve/main/pytorch_model-00002-of-00033.bin
http://huggingface.co/decapoda-research/llama-7b-hf/resolve/main/pytorch_model-00003-of-00033.bin
http://huggingface.co/decapoda-research/llama-7b-hf/resolve/main/pytorch_model-00004-of-00033.bin
http://huggingface.co/decapoda-research/llama-7b-hf/resolve/main/pytorch_model-00005-of-00033.bin
http://huggingface.co/decapoda-research/llama-7b-hf/resolve/main/pytorch_model-00006-of-00033.bin
http://huggingface.co/decapoda-research/llama-7b-hf/resolve/main/pytorch_model-00007-of-00033.bin
http://huggingface.co/decapoda-research/llama-7b-hf/resolve/main/pytorch_model-00008-of-00033.bin
http://huggingface.co/decapoda-research/llama-7b-hf/resolve/main/pytorch_model-00009-of-00033.bin
http://huggingface.co/decapoda-research/llama-7b-hf/resolve/main/pytorch_model-00010-of-00033.bin
http://huggingface.co/decapoda-research/llama-7b-hf/resolve/main/pytorch_model-00011-of-00033.bin
http://huggingface.co/decapoda-research/llama-7b-hf/resolve/main/pytorch_model-00012-of-00033.bin
http://huggingface.co/decapoda-research/llama-7b-hf/resolve/main/pytorch_model-00013-of-00033.bin
http://huggingface.co/decapoda-research/llama-7b-hf/resolve/main/pytorch_model-00014-of-00033.bin
http://huggingface.co/decapoda-research/llama-7b-hf/resolve/main/pytorch_model-00015-of-00033.bin
http://huggingface.co/decapoda-research/llama-7b-hf/resolve/main/pytorch_model-00016-of-00033.bin
http://huggingface.co/decapoda-research/llama-7b-hf/resolve/main/pytorch_model-00017-of-00033.bin
http://huggingface.co/decapoda-research/llama-7b-hf/resolve/main/pytorch_model-00018-of-00033.bin
http://huggingface.co/decapoda-research/llama-7b-hf/resolve/main/pytorch_model-00019-of-00033.bin
http://huggingface.co/decapoda-research/llama-7b-hf/resolve/main/pytorch_model-00020-of-00033.bin
http://huggingface.co/decapoda-research/llama-7b-hf/resolve/main/pytorch_model-00021-of-00033.bin
http://huggingface.co/decapoda-research/llama-7b-hf/resolve/main/pytorch_model-00022-of-00033.bin
http://huggingface.co/decapoda-research/llama-7b-hf/resolve/main/pytorch_model-00023-of-00033.bin
http://huggingface.co/decapoda-research/llama-7b-hf/resolve/main/pytorch_model-00024-of-00033.bin
http://huggingface.co/decapoda-research/llama-7b-hf/resolve/main/pytorch_model-00025-of-00033.bin
http://huggingface.co/decapoda-research/llama-7b-hf/resolve/main/pytorch_model-00026-of-00033.bin
http://huggingface.co/decapoda-research/llama-7b-hf/resolve/main/pytorch_model-00027-of-00033.bin
http://huggingface.co/decapoda-research/llama-7b-hf/resolve/main/pytorch_model-00028-of-00033.bin
http://huggingface.co/decapoda-research/llama-7b-hf/resolve/main/pytorch_model-00029-of-00033.bin
http://huggingface.co/decapoda-research/llama-7b-hf/resolve/main/pytorch_model-00030-of-00033.bin
http://huggingface.co/decapoda-research/llama-7b-hf/resolve/main/pytorch_model-00031-of-00033.bin
http://huggingface.co/decapoda-research/llama-7b-hf/resolve/main/pytorch_model-00032-of-00033.bin
http://huggingface.co/decapoda-research/llama-7b-hf/resolve/main/pytorch_model-00033-of-00033.bin
http://huggingface.co/decapoda-research/llama-7b-hf/resolve/main/pytorch_model.bin.index.json
http://huggingface.co/decapoda-research/llama-7b-hf/resolve/main/special_tokens_map.json
http://huggingface.co/decapoda-research/llama-7b-hf/resolve/main/tokenizer.model
http://huggingface.co/decapoda-research/llama-7b-hf/resolve/main/tokenizer_config.json
http://huggingface.co/lmsys/vicuna-7b-delta-v1.1/resolve/main/.gitattributes
http://huggingface.co/lmsys/vicuna-7b-delta-v1.1/resolve/main/README.md
http://huggingface.co/lmsys/vicuna-7b-delta-v1.1/resolve/main/config.json
http://huggingface.co/lmsys/vicuna-7b-delta-v1.1/resolve/main/generation_config.json
http://huggingface.co/lmsys/vicuna-7b-delta-v1.1/resolve/main/pytorch_model-00001-of-00002.bin
http://huggingface.co/lmsys/vicuna-7b-delta-v1.1/resolve/main/pytorch_model-00002-of-00002.bin
http://huggingface.co/lmsys/vicuna-7b-delta-v1.1/resolve/main/pytorch_model.bin.index.json
http://huggingface.co/lmsys/vicuna-7b-delta-v1.1/resolve/main/special_tokens_map.json
http://huggingface.co/lmsys/vicuna-7b-delta-v1.1/resolve/main/tokenizer.model
http://huggingface.co/lmsys/vicuna-7b-delta-v1.1/resolve/main/tokenizer_config.json

下载权重的脚本如下,使用了wget ${file} --no-check-certificate 绕开https检查:

#! /bin/bash
while read file; do
	wget ${file} --no-check-certificate 
done < download.txt

笔者的环境下,安装FastChat 0.1.10会导致依赖冲突:

The conflict is caused by:
    fschat 0.1.10 depends on tokenizers>=0.12.1
    transformers 4.35.0.dev0 depends on tokenizers<0.15 and >=0.14

To fix this you could try to:
1. loosen the range of package versions you've specified
2. remove package versions to allow pip attempt to solve the dependency conflict

因此改为安装别的版本fastchat

pip install fschat

再补充安装accelerate

pip install accelerate

之后执行python demo时,缺什么依赖就直接pip install安装即可。作者没有列出requirements.txt

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

其它修改

执行python demo.py仍然会遇到其它错误:

如果在下载bert tokenizer和bert config时报HTTPS错误,可以到huggingface把文件下载下来,再修改Minigpt-4项目的源码models/blip2.py

tokenizer = BertTokenizer.from_pretrained("/root/minigpt4/bert-base-uncased", local_files_only=True)
...
encoder_config = BertConfig.from_pretrained("/root/minigpt4/bert-base-uncased", local_files_only=True)       

让代码监听网络,而不只是127.0.0.1

demo.launch(share=True, enable_queue=True, server_name='0.0.0.0')

你可能感兴趣的:(AI与ML,python)