[GH-ISSUE #12753] 如何将多模态模型从safetensor格式转到ollama可用的格式? #70516

Closed
opened 2026-05-04 21:49:42 -05:00 by GiteaMirror · 4 comments
Owner

Originally created by @DoubleRedX on GitHub (Oct 23, 2025).
Original GitHub issue: https://github.com/ollama/ollama/issues/12753

  • 我尝试了llama.cpp的转换脚本将safetensor转成gguf格式,只有text的部分被处理。
  • 我尝试了直接加载safetensor格式的权重,但是出现了bug。

请问是否有类似于llama.cpp中的转换脚本类似的工具,能够将safetensor转换成符合ollama要求的格式的权重?包括这里涉及的量化过程。

Originally created by @DoubleRedX on GitHub (Oct 23, 2025). Original GitHub issue: https://github.com/ollama/ollama/issues/12753 - 我尝试了llama.cpp的转换脚本将safetensor转成gguf格式,只有text的部分被处理。 - 我尝试了直接加载safetensor格式的权重,但是出现了bug。 请问是否有类似于llama.cpp中的转换脚本类似的工具,能够将safetensor转换成符合ollama要求的格式的权重?包括这里涉及的量化过程。
GiteaMirror added the needs more info label 2026-05-04 21:49:42 -05:00
Author
Owner

@rick-github commented on GitHub (Oct 23, 2025):

Which model?

<!-- gh-comment-id:3436482426 --> @rick-github commented on GitHub (Oct 23, 2025): Which model?
Author
Owner

@DoubleRedX commented on GitHub (Oct 24, 2025):

Which model?

Qwen2.5-vl. 我的最终目的是在特定平台上适配qwen3-vl等多模态模型。这里边涉及到权重格式转换和量化,因此我想用qwen2.5-vl首先验证一下模型转换步骤的正确性。然后发现1、多模态的模型用llama.cpp提供的脚本转成gguf格式的时候,vision的部分是一个单独的文件。2、如果直接从safetensor使用,因为平台的原因无法使用这种方式。3、目前我在尝试从ollama解析权重文件的逻辑倒推编码的逻辑。
所以如果能提供一个权重转换的脚本会方便一些。

<!-- gh-comment-id:3440562685 --> @DoubleRedX commented on GitHub (Oct 24, 2025): > Which model? Qwen2.5-vl. 我的最终目的是在特定平台上适配qwen3-vl等多模态模型。这里边涉及到权重格式转换和量化,因此我想用qwen2.5-vl首先验证一下模型转换步骤的正确性。然后发现1、多模态的模型用llama.cpp提供的脚本转成gguf格式的时候,vision的部分是一个单独的文件。2、如果直接从safetensor使用,因为平台的原因无法使用这种方式。3、目前我在尝试从ollama解析权重文件的逻辑倒推编码的逻辑。 所以如果能提供一个权重转换的脚本会方便一些。
Author
Owner

@rick-github commented on GitHub (Oct 24, 2025):

What platform issues? Importing directly into ollama from the safetensors format is the recommended way for models using the new ollama engine.

<!-- gh-comment-id:3441296321 --> @rick-github commented on GitHub (Oct 24, 2025): What platform issues? Importing directly into ollama from the safetensors format is the recommended way for models using the new ollama engine.
Author
Owner

@DoubleRedX commented on GitHub (Nov 6, 2025):

convert_hf_to_gguf.py

I attempted to implement a script for converting a multimodal model from safetensor to gguf format. Adapted from the script in llama.cpp. This script takes Qwen 2.5L as an example. Usage: python convert_hf_to_gguf.py --ollama --outfile /path/to/output.gguf --outtype f16 /root/.cache/modelscope/hub/models/Qwen/Qwen2___5-VL-3B-Instruct/
It might be useful.🙂

<!-- gh-comment-id:3496817889 --> @DoubleRedX commented on GitHub (Nov 6, 2025): [convert_hf_to_gguf.py](https://github.com/user-attachments/files/23390230/convert_hf_to_gguf.py) I attempted to implement a script for converting a multimodal model from safetensor to gguf format. Adapted from the script in llama.cpp. This script takes Qwen 2.5L as an example. Usage: python convert_hf_to_gguf.py --ollama --outfile /path/to/output.gguf --outtype f16 /root/.cache/modelscope/hub/models/Qwen/Qwen2___5-VL-3B-Instruct/ It might be useful.🙂
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/ollama#70516