最近在群里有不少人反馈,ollama安装deepseek有以下几个问题。
1,特别慢,或者多次中断,导致下载不下来
2,无魔法
3,想在内网环境安装,没有网络
我研究了下解决方案。通过已经下载的模型,可以直接导入。
#查看本地的模型ollama listNAME ID SIZE MODIFIEDbge-m3:latest 790764642607 1.2 GB 5 days agodeepseek-r1:32b 38056bbcbb2d 19 GB 6 days agodeepseek-r1:14b ea35dfe18182 9.0 GB 2 weeks agodeepseek-r1:8b 28f8fd6cdc67 4.9 GB 2 weeks agollama3.2-vision:latest 085a1fdae525 7.9 GB 3 weeks ago
查看模型的modefile
ollama show deepseek-r1:8b --modelfile# Modelfile generated by "ollama show"# To build a new Modelfile based on this, replace FROM with:# FROM deepseek-r1:8bFROM E:\ai\ollama\models\blobs\sha256-6340dc3229b0d08ea9cc49b75d4098702983e17b4c096d57afbbf2ffc813f2beTEMPLATE """{{- if .System }}{{ .System }}{{ end }}{{- range $i, $_ := .Messages }}{{- $last := eq (len (slice $.Messages $i)) 1}}{{- if eq .Role "user" }}<|User|>{{ .Content }}{{- else if eq .Role "assistant" }}<|Assistant|>{{ .Content }}{{- if not $last }}<|end▁of▁sentence|>{{- end }}{{- end }}{{- if and $last (ne .Role "assistant") }}<|Assistant|>{{- end }}{{- end }}"""PARAMETER stop <|begin▁of▁sentence|>PARAMETER stop <|end▁of▁sentence|>PARAMETER stop <|User|>PARAMETER stop <|Assistant|>LICENSE """MIT LicenseCopyright (c) 2023 DeepSeekPermission is hereby granted, free of charge, to any person obtaining a copyof this software and associated documentation files (the "Software"), to dealin the Software without restriction, including without limitation the rightsto use, copy, modify, merge, publish, distribute, sublicense, and/or sellcopies of the Software, and to permit persons to whom the Software isfurnished to do so, subject to the following conditions:The above copyright notice and this permission notice shall be included in allcopies or substantial portions of the Software.THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS ORIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THEAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHERLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THESOFTWARE."""
这里有个关键FROM,标识模型所在的位置,在我这里FROM的地址是:
E:\ai\ollama\models\blobs\sha256-6340dc3229b0d08ea9cc49b75d4098702983e17b4c096d57afbbf2ffc813f2be
备份模型我先把我的文件备份下。备份到E:\ai\ollama\models 目录下
删除模型
ollama rm deepseek-r1:8b配置模型文件
在任何一个地方创建Modelfile,复制刚才show出来的信息,并修改FROM的路径。示例如下:
# Modelfile generated by "ollama show"# To build a new Modelfile based on this, replace FROM with:# FROM deepseek-r1:8bFROM E:\ai\ollama\models\sha256-6340dc3229b0d08ea9cc49b75d4098702983e17b4c096d57afbbf2ffc813f2beTEMPLATE """{{- if .System }}{{ .System }}{{ end }}{{- range $i, $_ := .Messages }}{{- $last := eq (len (slice $.Messages $i)) 1}}{{- if eq .Role "user" }}<|User|>{{ .Content }}{{- else if eq .Role "assistant" }}<|Assistant|>{{ .Content }}{{- if not $last }}<|end▁of▁sentence|>{{- end }}{{- end }}{{- if and $last (ne .Role "assistant") }}<|Assistant|>{{- end }}{{- end }}"""PARAMETER stop <|begin▁of▁sentence|>PARAMETER stop <|end▁of▁sentence|>PARAMETER stop <|User|>PARAMETER stop <|Assistant|>LICENSE """MIT LicenseCopyright (c) 2023 DeepSeekPermission is hereby granted, free of charge, to any person obtaining a copyof this software and associated documentation files (the "Software"), to dealin the Software without restriction, including without limitation the rightsto use, copy, modify, merge, publish, distribute, sublicense, and/or sellcopies of the Software, and to permit persons to whom the Software isfurnished to do so, subject to the following conditions:The above copyright notice and this permission notice shall be included in allcopies or substantial portions of the Software.THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS ORIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THEAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHERLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THESOFTWARE."""
执行创建模型名称自己可以改,比如r18b 这样
ollama create deepseek-r1:8b -f Modelfile使用
附:几个个常用模型的Modelfile。 8b的示例就是。
向量模型:
ollama show bge-m3:latest --modelfile
# Modelfile generated by "ollama show"# To build a new Modelfile based on this, replace FROM with:# FROM bge-m3:latestFROM E:\ai\ollama\models\blobs\sha256-daec91ffb5dd0c27411bd71f29932917c49cf529a641d0168496c3a501e3062cTEMPLATE {{ .Prompt }}LICENSE """MIT LicenseCopyright (c) [year] [fullname]Permission is hereby granted, free of charge, to any person obtaining a copyof this software and associated documentation files (the "Software"), to dealin the Software without restriction, including without limitation the rightsto use, copy, modify, merge, publish, distribute, sublicense, and/or sellcopies of the Software, and to permit persons to whom the Software isfurnished to do so, subject to the following conditions:The above copyright notice and this permission notice shall be included in allcopies or substantial portions of the Software.THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS ORIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THEAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHERLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THESOFTWARE."""
7b的
ollama show deepseek-r1 --modelfile
# Modelfile generated by "ollama show"# To build a new Modelfile based on this, replace FROM with:# FROM deepseek-r1:latestFROM E:\ai\ollama\models\blobs\sha256-96c415656d377afbff962f6cdb2394ab092ccbcbaab4b82525bc4ca800fe8a49TEMPLATE """{{- if .System }}{{ .System }}{{ end }}{{- range $i, $_ := .Messages }}{{- $last := eq (len (slice $.Messages $i)) 1}}{{- if eq .Role "user" }}<|User|>{{ .Content }}{{- else if eq .Role "assistant" }}<|Assistant|>{{ .Content }}{{- if not $last }}<|end▁of▁sentence|>{{- end }}{{- end }}{{- if and $last (ne .Role "assistant") }}<|Assistant|>{{- end }}{{- end }}"""PARAMETER stop <|begin▁of▁sentence|>PARAMETER stop <|end▁of▁sentence|>PARAMETER stop <|User|>PARAMETER stop <|Assistant|>LICENSE """MIT LicenseCopyright (c) 2023 DeepSeekPermission is hereby granted, free of charge, to any person obtaining a copyof this software and associated documentation files (the "Software"), to dealin the Software without restriction, including without limitation the rightsto use, copy, modify, merge, publish, distribute, sublicense, and/or sellcopies of the Software, and to permit persons to whom the Software isfurnished to do so, subject to the following conditions:The above copyright notice and this permission notice shall be included in allcopies or substantial portions of the Software.THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS ORIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THEAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHERLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THESOFTWARE."""
14b的
ollama show deepseek-r1:14b --modelfile
# Modelfile generated by "ollama show"# To build a new Modelfile based on this, replace FROM with:# FROM deepseek-r1:14bFROM E:\ai\ollama\models\blobs\sha256-6e9f90f02bb3b39b59e81916e8cfce9deb45aeaeb9a54a5be4414486b907dc1eTEMPLATE """{{- if .System }}{{ .System }}{{ end }}{{- range $i, $_ := .Messages }}{{- $last := eq (len (slice $.Messages $i)) 1}}{{- if eq .Role "user" }}<|User|>{{ .Content }}{{- else if eq .Role "assistant" }}<|Assistant|>{{ .Content }}{{- if not $last }}<|end▁of▁sentence|>{{- end }}{{- end }}{{- if and $last (ne .Role "assistant") }}<|Assistant|>{{- end }}{{- end }}"""PARAMETER stop <|begin▁of▁sentence|>PARAMETER stop <|end▁of▁sentence|>PARAMETER stop <|User|>PARAMETER stop <|Assistant|>LICENSE """MIT LicenseCopyright (c) 2023 DeepSeekPermission is hereby granted, free of charge, to any person obtaining a copyof this software and associated documentation files (the "Software"), to dealin the Software without restriction, including without limitation the rightsto use, copy, modify, merge, publish, distribute, sublicense, and/or sellcopies of the Software, and to permit persons to whom the Software isfurnished to do so, subject to the following conditions:The above copyright notice and this permission notice shall be included in allcopies or substantial portions of the Software.THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS ORIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THEAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHERLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THESOFTWARE."""
32b 的
ollama show deepseek-r1:32b --modelfile
# Modelfile generated by "ollama show"# To build a new Modelfile based on this, replace FROM with:# FROM deepseek-r1:32bFROM E:\ai\ollama\models\blobs\sha256-6150cb382311b69f09cc0f9a1b69fc029cbd742b66bb8ec531aa5ecf5c613e93TEMPLATE """{{- if .System }}{{ .System }}{{ end }}{{- range $i, $_ := .Messages }}{{- $last := eq (len (slice $.Messages $i)) 1}}{{- if eq .Role "user" }}<|User|>{{ .Content }}{{- else if eq .Role "assistant" }}<|Assistant|>{{ .Content }}{{- if not $last }}<|end▁of▁sentence|>{{- end }}{{- end }}{{- if and $last (ne .Role "assistant") }}<|Assistant|>{{- end }}{{- end }}"""PARAMETER stop <|begin▁of▁sentence|>PARAMETER stop <|end▁of▁sentence|>PARAMETER stop <|User|>PARAMETER stop <|Assistant|>LICENSE """MIT LicenseCopyright (c) 2023 DeepSeekPermission is hereby granted, free of charge, to any person obtaining a copyof this software and associated documentation files (the "Software"), to dealin the Software without restriction, including without limitation the rightsto use, copy, modify, merge, publish, distribute, sublicense, and/or sellcopies of the Software, and to permit persons to whom the Software isfurnished to do so, subject to the following conditions:The above copyright notice and this permission notice shall be included in allcopies or substantial portions of the Software.THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS ORIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THEAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHERLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THESOFTWARE."""
我上传网盘以后在家里的mac电脑上创建成功。

我把相关的模型和Modefile上传到网盘了,本地使用可以直接下载,生产内网使用,建议自己下载,自己获取。
链接:https://pan.quark.cn/s/512e627c261a
注意事项:
1,Modefile中的From 路径,可以是绝对路径也可以是相对路径
2,From 路径的后的模型文件名称一定要和文件名一样
创作不易,辛苦大家动动发财的小手。
if 文章有用:点赞()收藏()关注()else:留言吐槽()
最后,我们邀请了各个AI赛道的极客和大咖,开了一个10多天的免费公开课,有图文分享,有直播实操讲解。
如果你想深度使用学习AI,并且想要抓住AI风口赚钱,请尽快扫码进群听课程分享。
名额有限,先到先得!
原文作者:5ycode;如有侵权,请联系管理员删除。