ollama 部署 deepseek-r1 70B 模型完整指南

360影视 2025-02-02 12:36 2

摘要:pip install modelscopemodelscope download --model unsloth/DeepSeek-R1-Distill-Llama-70B-GGUF DeepSeek-R1-Distill-Llama-70B-Q5_K_M.

Ollama运行界面

1. 获取GGUF格式模型文件

通过ModelScope平台下载量化后的模型文件(推荐Q5_K_M中等量化级别):

pip install modelscopemodelscope download --model unsloth/DeepSeek-R1-Distill-Llama-70B-GGUF DeepSeek-R1-Distill-Llama-70B-Q5_K_M.gguf --local_dir /DeepSeek-R1-Distill-Llama-70B-GGUF

技术说明:GGUF(GPT-Generated Unified Format)是专为LLM设计的跨平台格式,支持CPU/GPU混合推理,特别适合在苹果芯片设备或纯CPU环境运行。Q5_K_M量化在保持94%精度的同时,将模型体积压缩至49GB。

1. 安装Ollama推理框架

参考官网ollama/ollama: Get up and running with Llama 3.3, Phi 4, Gemma 2, and other large language models.

curl -fsSL https://ollama.com/install.sh | sudo sh

2. 配置远程访问(可选)

参考ollama/docs/faq.md at main · ollama/ollama

如需通过其他设备访问,需修改服务配置:

sudo nano /etc/systemd/system/ollama.service

在[Service]部分添加:

Environment="OLLAMA_HOST=0.0.0.0"Environment="OLLAMA_ORIGINS=*"

刷新服务配置:

sudo systemctl daemon-reloadsudo systemctl restart ollama# 这里填入gguf文件路径FROM /home/DeepSeek-R1-Distill-Llama-70B-GGUF/DeepSeek-R1-Distill-Llama-70B-Q5_K_M.gguf# 以下为模型模板配置TEMPLATE """{{- if .System }}{{ .System }}{{ end }}{{- range $i, $_ := .Messages }}{{- $last := eq (len (slice $.Messages $i)) 1}}{{- if eq .Role "user" }}{{ .Content }}{{- else if eq .Role "assistant" }}{{ .Content }}{{- if not $last }}{{- end }}{{- end }}{{- if and $last (ne .Role "assistant") }}{{- end }}{{- end }}"""PARAMETER stop ""PARAMETER stop ""PARAMETER stop ""PARAMETER stop ""PARAMETER num_ctx 12800

1. 创建Ollama模型实例

ollama create DeepSeek-R1-Distill-Llama-70B-Q5_K_M -f /home/DeepSeek-R1-Distill-Llama-70B-GGUF/Modelfile

2. 验证模型列表

ollama list# 预期输出NAME ID SIZE MODIFIEDDeepSeek-R1-Distill-Llama-70B-Q5_K_M:latest dd7ae729f6fc 49 GB 46 minutes ago

3. 启动模型服务

ollama run DeepSeek-R1-Distill-Llama-70B-Q5_K_M:latest

成功运行后将进入交互式命令行界面。

Ollama服务状态

Open WebUI:搭建可视化聊天界面API集成:通过RESTful API对接应用程序LangChain:构建自动化AI工作流

来源:AIGC研究社

相关推荐