当前位置: 首页 > news >正文

2.2 Windows本地部署DeepSeek模型 --- Ollama篇(下)

2.3Ollama加载已下载Deepseek模型

无网络连接,直接通过Ollama本地已经本地已经下载好的的Deepseek模型。

2.3.1 查看已安装模型

PS C:\Users\Administrator> ollama list
NAME                              ID              SIZE      MODIFIED
deepseek-r1:8b                    28f8fd6cdc67    4.9 GB    41 minutes ago
shaw/dmeta-embedding-zh:latest    55960d8a3a42    408 MB    21 hours ago
deepseek-r1:14b                   ea35dfe18182    9.0 GB    21 hours ago

2.3.2 下载Deepseek7b模型

通过Deepseek 开源Github仓库,如下:

https://github.com/deepseek-ai

跳转进入huggingface官网,下载模型,如下:

https://huggingface.co/deepseek-ai/DeepSeek-R1

model-00001-of-000002.safetensors 和 model-00002-of-000002.safetensors 是模型的分片文件。

大型语言模型(如 LLaMA、GPT 等)通常包含数十亿甚至数百亿个参数,导致模型文件非常大。为了便于管理和传输,模型文件会被分割成多个较小的分片。

每个分片文件包含模型的一部分参数或权重,加载时需要将所有分片合并才能完整地加载模型。

2.3.3 模型转换

例如我们之前在LM Studio中使用的模型格式为.gguf文件,我们需要将分片转换为.gguf文件,或直接使用LM Studio下载的模型文件

2.3.4 加载Deepseek7b本地模型

查看已下载模型的modlefile文件内容,如下:

PS C:\Users\Administrator> 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:8b

FROM C:\Users\Administrator\.ollama\models\blobs\sha256-6340dc3229b0d08ea9cc49b75d4098702983e17b4c096d57afbbf2ffc813f2be
TEMPLATE """{{- 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 License

Copyright (c) 2023 DeepSeek

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, 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 THE
SOFTWARE.
"""

PS C:\Users\Administrator>

在模型对应的目录创建对应的模型文件(modelfile),

内容如下:

Deepseek-R1_7B-Q8.mf

# Modelfile generated by "ollama show"
# To build a new Modelfile based on this, replace FROM with:
# FROM deepseek-r1:8b

FROM C:\01_bill\01_AI\01_deepseeks\01_models\DeepSeek-R1-Distill-Qwen-7B-Q8_0.gguf
TEMPLATE """{{- 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 License

Copyright (c) 2023 DeepSeek

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, 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 THE
SOFTWARE.
"""

 执行加载,如下: 

PS C:\01_bill\01_AI\01_deepseeks\01_models> ollama create Deepseek-R1_7B-Q8 -f .\Deepseek-R1_7B-Q8.mf
gathering model components
copying file sha256:318b1edf03c35eb962aa79c1c59d8e03a7fe902f793b68ab3dbe6ae850622515 100%
parsing GGUF
using existing layer sha256:318b1edf03c35eb962aa79c1c59d8e03a7fe902f793b68ab3dbe6ae850622515
creating new layer sha256:9bb403b8e0b1be4d97d845272dad98a44c2cc66b4ae4f234837336c09081303f
creating new layer sha256:09aafb1e797f213d94c7bbb20bc0d8bae736f51ab91b5a19cbe9362a840f08fb
using existing layer sha256:f4d24e9138dd4603380add165d2b0d970bef471fac194b436ebd50e6147c6588
writing manifest
success
PS C:\01_bill\01_AI\01_deepseeks\01_models> 

查看是否加载成功,如下:

PS C:\01_bill\01_AI\01_deepseeks\01_models> ollama list
NAME                              ID              SIZE      MODIFIED
Deepseek-R1_7B-Q8:latest          ff9b1ec4979d    8.1 GB    3 minutes ago
deepseek-r1:8b                    28f8fd6cdc67    4.9 GB    4 hours ago
shaw/dmeta-embedding-zh:latest    55960d8a3a42    408 MB    24 hours ago
deepseek-r1:14b                   ea35dfe18182    9.0 GB    24 hours ago

三,Cherry Studio

cherry-studio/docs/README.zh.md at main · CherryHQ/cherry-studio · GitHub

Cherry Studio 是一款支持多个大语言模型(LLM)服务商的桌面客户端。它支持支持文本、图片、Office、PDF 等多种格式,我们可以使用它来创建自己的本地知识库。

3.1 使能Ollama

 3.2 会话功能

3.3 创建本地知识库

这里需要shaw/dmeta-embedding-zh来加载我们的本地文件,如下:

相关文章:

  • Training-free Neural Architecture Search for RNNs and Transformers(预览版本)
  • 基于Rye的Django项目通过Pyinstaller用Github工作流简单打包
  • [原创](Modern C++)现代C++的关键性概念: 非常独特的std::sentinel_for概念(哨兵概念)
  • LeetCode Hot100刷题——反转链表(迭代+递归)
  • 【c++】反转字符串
  • 二次SQL注入
  • 线程安全问题(面试重难点)
  • Python asyncIO 面试题及参考答案 草
  • 【数据结构与算法】Java描述:第二节:LinkedList 链表
  • Python 数据可视化
  • Python包结构与 `__init__.py` 详解
  • FusionInsight MRS云原生数据湖
  • Python贝壳网二手小区数据爬取(2025年3月更)
  • Python教学:语法检测问题-由DeepSeek产生
  • 30-判断子序列
  • Educational Codeforces Round 7 F. The Sum of the k-th Powers 多项式、拉格朗日插值
  • 浏览器信息收集插件之 雪瞳 —— 洞悉无形,守护无界
  • 标量、向量、矩阵与张量:从维度理解数据结构的层次
  • 攻防世界web:NewsCenter(含sqlmap基本参数讲解)
  • 水管滴水漏水检测数据集VOC+YOLO格式2708张1类别
  • 做网站怎样建立服务器/我也要投放广告
  • 互联网建设网站/网站建设的一般步骤
  • 深圳做微信网站制作/seo百度发包工具
  • 怀柔建设网站/中囯联通腾迅
  • h5做网站/宁波网络推广运营公司电话
  • 怎么看一个网站是谁做的/优化关键词是什么意思