qidao123.com技术社区-IT企服评测·应用市场

标题: llama.cpp运行qwen0.5B [打印本页]

作者: 杀鸡焉用牛刀    时间: 2024-7-24 06:51
标题: llama.cpp运行qwen0.5B
编译llama.cp

参考
下载模型

05b模型下载
转化模型

创建假造环境

  1. conda create --prefix=D:\miniconda3\envs\llamacpp python=3.10
  2. conda activate D:\miniconda3\envs\llamacpp
复制代码
安装所需要的包


  1. cd G:\Cpp\llama.cpp-master
  2. pip install -r requirements.txt
  3. python convert.py -h
复制代码



实行转换下令
  1. # python convert.py G:\Python\Qwen1.5-0.5B-Chat --outfile G:\Cpp\qwenchat0.5b.gguf --outtype q8_0
  2. python convert-hf-to-gguf.py G:\Python\Qwen1.5-0.5B-Chat  --outfile G:\Cpp\qwenchat0.5b.gguf
  3. # 解释
  4. # python
  5. # convert.py # convert.py路径
  6. # /content/finetuned-2_merged # 模型路径
  7. # --outfile finetuned-2.gguf # 要分配的gguf模型名称
  8. # --outtype q8_0 #以8 Bit量化
复制代码



   将模型量化为5Bit(利用q5_k-m方法)
  1. quantize.exe G:\Cpp\qwenchat0.5b.gguf qwenchat0.5b-q5_k_m.gguf q5_k_m
  2. # 4bit,基本不太行
  3. # quantize.exe G:\Cpp\qwenchat0.5b.gguf qwenchat0.5b-q4_0.gguf q4_0
复制代码


控制台运行模型

  1. # 注意Qwen模型要使用chatml prompt 模版
  2. main.exe -m qwenchat0.5b-q5_k_m.gguf -n 512 --chatml
复制代码

http方式运行模型

  1. server.exe -m qwenchat0.5b-q5_k_m.gguf -c 2048 --host 0.0.0.0 --port 8007
  2. curl --request POST --url http://localhost:8007/completion --header "Content-Type: application/json" --data '{"prompt": "你好","n_predict": 128}'
复制代码
页面的话访问8007即可

server参数解释
尝鲜通义千问1.8B
参考
hf2gguf

免责声明:如果侵犯了您的权益,请联系站长,我们会及时删除侵权内容,谢谢合作!更多信息从访问主页:qidao123.com:ToB企服之家,中国第一个企服评测及商务社交产业平台。




欢迎光临 qidao123.com技术社区-IT企服评测·应用市场 (https://dis.qidao123.com/) Powered by Discuz! X3.4