Ollama 模型的导出与导入

本文将介绍如何使用 Ollama 工具导出模型文件,从 HuggingFace 或镜像网站下载 GGUF 格式的模型文件,以及如何将模型文件导入到项目中。

导出某个模型

  • 执行 ollama show --modelfile 查看模型信息,以 deepseek-r1:1.5b 为例
[root@localhost ~]# ollama list
NAME                ID              SIZE      MODIFIED       
deepseek-r1:7b      0a8c26691023    4.7 GB    42 minutes ago    
deepseek-r1:1.5b    a42b25d8c10a    1.1 GB    53 minutes ago

[root@localhost ~]# ollama show --modelfile deepseek-r1:1.5b | grep "^FROM"
FROM /usr/share/ollama/.ollama/models/blobs/sha256-aabd4debf0c8f08881923f2c25fc0fdeed24435271c2b3e92c4af36704040dbc

[root@localhost ~]# du -sh /usr/share/ollama/.ollama/models/blobs/sha256-aabd4debf0c8f08881923f2c25fc0fdeed24435271c2b3e92c4af36704040dbc
1.1G    /usr/share/ollama/.ollama/models/blobs/sha256-aabd4debf0c8f08881923f2c25fc0fdeed24435271c2b3e92c4af36704040dbc
  • 从模型文件信息里得知 /usr/share/ollama/.ollama/models/blobs/sha256-aabd4debf0c8f08881923f2c25fc0fdeed24435271c2b3e92c4af36704040dbc 即为 deepseek-r1:1.5b(格式为gguf)

手动导入GGUF模型文件

  • 第1步,从 huggingface.co 下载gguf格式的模型文件(若官网打不开,可使用镜像 hf-mirror.com),示例 DeepSeek-R1-Distill-Qwen-7B-GGUF

DeepSeek-R1 蒸馏模型 hf-mirror 下载地址
DeepSeek-R1-Distill-Qwen-1.5B https://hf-mirror.com/bartowski/DeepSeek-R1-Distill-Qwen-1.5B-GGUF/tree/main
DeepSeek-R1-Distill-Qwen-7B https://hf-mirror.com/bartowski/DeepSeek-R1-Distill-Qwen-7B-GGUF/tree/main
DeepSeek-R1-Distill-Llama-8B https://hf-mirror.com/bartowski/DeepSeek-R1-Distill-Llama-8B-GGUF/tree/main
DeepSeek-R1-Distill-Qwen-14B https://hf-mirror.com/bartowski/DeepSeek-R1-Distill-Qwen-14B-GGUF/tree/main
DeepSeek-R1-Distill-Qwen-32B https://hf-mirror.com/bartowski/DeepSeek-R1-Distill-Qwen-32B-GGUF/tree/main
DeepSeek-R1-Distill-Llama-70B https://hf-mirror.com/bartowski/DeepSeek-R1-Distill-Llama-70B-GGUF/tree/main
  • 第2步,将 .gguf 模型文件拷贝到某个目录,示例 DeepSeek-R1-Distill-Qwen-7B-IQ2_M.gguf
cd /data/ollama
ll DeepSeek-R1-Distill-Qwen-7B-IQ2_M.gguf
  • 第3步,在同目录下创建一个 model.txt 文件,内容如下:
from ./DeepSeek-R1-Distill-Qwen-7B-IQ2_M.gguf
  • 第4步,导入该模型文件并确认
cd /data/ollama
ollama create deepseek-r1:7b -f ./model.txt
ollama list
Copyright © www.sqlfans.cn 2021 - 2026 All Right Reserved更新时间: 2026-05-30 12:00:12

results matching ""

    No results matching ""