[ollama] - 使用 ollama 创建 Q4_K_M minicpm-v 失败
起始日期 | Start Date
No response
实现PR | Implementation PR
No response
相关Issues | Reference Issues
No response
摘要 | Summary
我微调了 minicpm-v2.6 然后希望将其提交到 ollama 方便使用。按照教程做如下步骤:
- 将微调获取的 safetensors 使用 ./examples/llava/minicpmv-surgery.py 处理 「成功」
- 将 image encode 转换为 gguf 「成功」
- 使用 convert hf to gguf 将 model 转换为 gguf 「成功」
- 使用 llama-quantize 生成 Q4_K_M 的 gguf 「成功」
- 使用 ollama create 将 fp16 的模型提交到 ollama 「成功」
- 使用 ollama create 将 q4_k_m 的模型提交到 ollama 「失败」报错 Error: invalid file magic
同时,我在 llama.cpp 中使用 llama-minicpmv-cli 也可以成功运行 Q4_K_M 的模型。
尝试了官方的 ollama 以及 opembmb/ollama ,尝试了 linux 环境以及 macos 都有相同的报错。
基本示例 | Basic Example
./ollama create arkohut/minicpm-v:8b-2.6-q4_K_M -f Modelfile.Q4_K_M
报错
transferring model data 100% Error: invalid file magic
缺陷 | Drawbacks
使用 ollama create 将 q4_k_m 的模型提交到 ollama 「失败」报错 Error: invalid file magic
未解决问题 | Unresolved questions
No response
is there any ollama model that works with this?
is there any ollama model that works with this?
Yes, the official model in ollama minicpm-v:8b-2.6-q4_K_M works! But following the instruction in openbmb/minicpm-v I can not build the quantized model myself.
一样的问题: Ollama v0.3.14
gguf file: https://huggingface.co/bartowski/MiniCPM-V-2_6-GGUF
> ollama create minicpm2.6:q4 -f .\Modelfile
transferring model data 100%
Error: invalid file magic
Modelfile
FROM MiniCPM-V-2_6-Q4_K_M.gguf
临时解决方案 / Temporary solution, use ollama official model
https://ollama.com/library/minicpm-v:8b-2.6-q4_K_M
ollama run minicpm-v:8b-2.6-q4_K_M
看看官方版多一个1GB的projector文件,这种多模态估计现在不支持直接创建,有其他步骤之类的
https://github.com/ollama/ollama/issues/6272 这里的方案可以解决这个问题。总结一下:
使用 llama.cpp 做完量化所获得的 gguf 文件不知为何会多 8 字节,解决方案有两个:
- 删除那 8 个字节
- 直接使用
ollama create -q xxx的命令从 fp16 的gguf进行量化,而不是使用llama.cpp进行量化
可以参考 https://github.com/OpenSQZ/MiniCPM-V-CookBook/blob/main/quantization/gguf/minicpm-v4_5_gguf_quantize_zh.md 将模型转换为gguf格式,然后用ollama在cpu上运行。但是速度非常的慢