在纯C/C ++中推断Minigpt4。
minigpt4.cpp的主要目标是使用GGML库使用4位量化运行Minigpt4。


要求:git
git clone --recursive https://github.com/Maknee/minigpt4.cpp
cd minigpt4.cpp转到发布并将minigpt4库文件提取到存储库目录中。
要求:CMAKE,Visual Studio和Git
cmake .
cmake --build . --config Release
binReleaseminigpt4.dll应生成
要求:CMAKE(Ubuntu: sudo apt install cmake )
cmake .
cmake --build . --config Release minigpt4.so应该生成
要求:CMAKE(MACOS: brew install cmake )
cmake .
cmake --build . --config Release minigpt4.dylib应该生成
注意:如果您使用openCV构建(允许在库本身内加载和预处理图像之类的功能), ON MINIGPT4_BUILD_WITH_OPENCV设置为in CMakeLists.txt或使用-DMINIGPT4_BUILD_WITH_OPENCV=ON作为cmake cli的参数。
在拥抱面孔〜7b或13b上可以使用预量化的模型。
建议获得可靠的结果,但推理速度缓慢:Minigpt4-13b-f16.bin
要求:Python 3.x和Pytorch。
克隆Minigpt-4存储库并执行设置
cd minigpt4
git clone https://github.com/Vision-CAIR/MiniGPT-4.git
cd MiniGPT-4
conda env create -f environment.yml
conda activate minigpt4在Checkpoint Aligned with Vicuna 7B下,在Minigpt-4存储库中下载验证的检查点或Checkpoint Aligned with Vicuna 13B或从HuggingFace链接下载7B或13B
将模型权重转换为GGML格式
7b型号
cd minigpt4
python convert.py C:pretrained_minigpt4_7b.pth --ftype=f16
13B型号
cd minigpt4
python convert.py C:pretrained_minigpt4.pth --ftype=f16
7b型号
python convert.py ~ /Downloads/pretrained_minigpt4_7b.pth --outtype f1613B型号
python convert.py ~ /Downloads/pretrained_minigpt4.pth --outtype f16应该生成minigpt4-7B-f16.bin或minigpt4-13B-f16.bin
拥抱面孔可用预量化模型
建议获得可靠的结果和不错的推理速度:ggml-vicuna-13b-v0-q5_k.bin
要求:Python 3.x和Pytorch。
遵循Minigpt4的指南获取Vicuna-V0模型。
然后,克隆Llama.cpp
git clone https://github.com/ggerganov/llama.cpp
cd llama.cpp
cmake .
cmake --build . --config Release将模型转换为GGML
python convert.py < path-to-model >量化模型
python quanitize < path-to-model > < output-model > Q4_1测试Minigpt4是否可以通过拨打以下方式来替换minigpt4-13B-f16.bin和ggml-vicuna-13B-v0-q5_k.bin用各自的型号
cd minigpt4
python minigpt4_library.py minigpt4-13B-f16.bin ggml-vicuna-13B-v0-q5_k.bin安装WebUI的要求
pip install -r requirements.txt然后,运行WebUI,用各自的型号替换minigpt4-13B-f16.bin和ggml-vicuna-13B-v0-q5_k.bin
python webui.py minigpt4-13B-f16.bin ggml-vicuna-13B-v0-q5_k.bin输出应包含以下内容:
Running on local URL: http://127.0.0.1:7860
To create a public link, set ` share=True ` in `launch () ` .请访问浏览器中的http://127.0.0.1:7860 ,您应该能够与WebUI进行交互。