MiniCPM-V icon indicating copy to clipboard operation
MiniCPM-V copied to clipboard

[ollama] - 使用 ollama 创建 Q4_K_M minicpm-v 失败

Open arkohut opened this issue 1 year ago • 1 comments

起始日期 | Start Date

No response

实现PR | Implementation PR

No response

相关Issues | Reference Issues

No response

摘要 | Summary

我微调了 minicpm-v2.6 然后希望将其提交到 ollama 方便使用。按照教程做如下步骤:

  1. 将微调获取的 safetensors 使用 ./examples/llava/minicpmv-surgery.py 处理 「成功」
  2. 将 image encode 转换为 gguf 「成功」
  3. 使用 convert hf to gguf 将 model 转换为 gguf 「成功」
  4. 使用 llama-quantize 生成 Q4_K_M 的 gguf 「成功」
  5. 使用 ollama create 将 fp16 的模型提交到 ollama 「成功」
  6. 使用 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

arkohut avatar Oct 12 '24 09:10 arkohut

is there any ollama model that works with this?

hololeo avatar Oct 12 '24 15:10 hololeo

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.

arkohut avatar Oct 14 '24 03:10 arkohut

一样的问题: 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文件,这种多模态估计现在不支持直接创建,有其他步骤之类的

CrayonSSR avatar Oct 27 '24 03:10 CrayonSSR

https://github.com/ollama/ollama/issues/6272 这里的方案可以解决这个问题。总结一下:

使用 llama.cpp 做完量化所获得的 gguf 文件不知为何会多 8 字节,解决方案有两个:

  1. 删除那 8 个字节
  2. 直接使用 ollama create -q xxx 的命令从 fp16 的 gguf 进行量化,而不是使用 llama.cpp 进行量化

arkohut avatar Nov 06 '24 15:11 arkohut

可以参考 https://github.com/OpenSQZ/MiniCPM-V-CookBook/blob/main/quantization/gguf/minicpm-v4_5_gguf_quantize_zh.md 将模型转换为gguf格式,然后用ollama在cpu上运行。但是速度非常的慢

tungsten106 avatar Sep 29 '25 09:09 tungsten106