编译llama.cp
参考
下载模型
05b模型下载
转化模型
创建虚拟环境
conda create --prefix=D:\miniconda3\envs\llamacpp python=3.10 conda activate D:\miniconda3\envs\llamacpp
安装所需要的包
cd G:\Cpp\llama.cpp-master pip install -r requirements.txt python convert.py -h
执行转换命令
# python convert.py G:\Python\Qwen1.5-0.5B-Chat --outfile G:\Cpp\qwenchat0.5b.gguf --outtype q8_0 python convert-hf-to-gguf.py G:\Python\Qwen1.5-0.5B-Chat --outfile G:\Cpp\qwenchat0.5b.gguf # 解释 # python # convert.py # convert.py路径 # /content/finetuned-2_merged # 模型路径 # --outfile finetuned-2.gguf # 要分配的gguf模型名称 # --outtype q8_0 #以8 Bit量化
将模型量化为5Bit(使用q5_k-m方法)
quantize.exe G:\Cpp\qwenchat0.5b.gguf qwenchat0.5b-q5_k_m.gguf q5_k_m # 4bit,基本不太行 # quantize.exe G:\Cpp\qwenchat0.5b.gguf qwenchat0.5b-q4_0.gguf q4_0
控制台运行模型
# 注意Qwen模型要使用chatml prompt 模版 main.exe -m qwenchat0.5b-q5_k_m.gguf -n 512 --chatml
http方式运行模型
server.exe -m qwenchat0.5b-q5_k_m.gguf -c 2048 --host 0.0.0.0 --port 8007 curl --request POST --url http://localhost:8007/completion --header "Content-Type: application/json" --data '{"prompt": "你好","n_predict": 128}'
页面的话访问8007即可
server参数解释
尝鲜通义千问1.8B
参考
hf2gguf