Rayrtfr b06d7bcf7f | 3 months ago | |
---|---|---|
.. | ||
README.md | 3 months ago |
以llama.cpp工具为例,介绍模型量化并在本地部署的详细步骤。Windows则可能需要cmake等编译工具的安装。本地快速部署体验推荐使用经过指令精调的Atom-7B-Chat模型,有条件的推荐使用6-bit或者8-bit模型,效果更佳。 运行前请确保:
make
(MacOS/Linux自带)或cmake
(Windows需自行安装)编译工具git pull
拉取最新代码,并执行make clean
进行清理$ git clone https://github.com/Rayrtfr/llama.cpp
./main
(用于推理)和./quantize
(用于量化)二进制文件。$ make
Windows/Linux用户如需启用GPU推理,则推荐与BLAS(或cuBLAS如果有GPU)一起编译,可以提高prompt处理速度。以下是和cuBLAS一起编译的命令,适用于NVIDIA相关GPU。参考:llama.cpp#blas-build
$ make LLAMA_CUBLAS=1
macOS用户无需额外操作,llama.cpp已对ARM NEON做优化,并且已自动启用BLAS。M系列芯片推荐使用Metal启用GPU推理,显著提升速度。只需将编译命令改为:LLAMA_METAL=1 make
,参考llama.cpp#metal-build
$ LLAMA_METAL=1 make
目前llama.cpp已支持.safetensors
文件以及huggingface格式.bin
转换为GGUF的FP16格式。
/path/Atom-7B-Chat是模型下载的目录位置。
$ python convert.py --outfile ./atom-7B-cpp.gguf /path/Atom-7B-Chat
$ ./quantize ./atom-7B-cpp.gguf ./ggml-atom-7B-q4_0.gguf q4_0
./main
中指定例如-ngl 40
表示offload 40层模型参数到GPU使用以下命令启动聊天。
text="<s>Human: 介绍一下北京\n</s><s>Assistant:"
./main -m \
./ggml-atom-7B-q4_0.gguf \
-p "${text}" \
--logdir ./logtxt
如果要带聊天的上下文,上面的text需要调整成类似这样:
text="<s>Human: 介绍一下北京\n</s><s>Assistant:北京是一个美丽的城市</s>\n<s>Human: 再介绍一下合肥\n</s><s>Assistant:"
更详细的官方说明请参考:https://github.com/ggerganov/llama.cpp/tree/master/examples/main
No Description
CSV Markdown Python other
Dear OpenI User
Thank you for your continuous support to the Openl Qizhi Community AI Collaboration Platform. In order to protect your usage rights and ensure network security, we updated the Openl Qizhi Community AI Collaboration Platform Usage Agreement in January 2024. The updated agreement specifies that users are prohibited from using intranet penetration tools. After you click "Agree and continue", you can continue to use our services. Thank you for your cooperation and understanding.
For more agreement content, please refer to the《Openl Qizhi Community AI Collaboration Platform Usage Agreement》