Ollama部署模型
1.前情
本次采用Ollama进行大语言模型qwen2-0.5B、embedding模型bge-large-zh-1.5的部署,通过离线部署的方式,并接入原有系统中使用。
系统环境: Linux VM-16-15-tencentos 5.4.119-19.0009.44 x86_64
备注: 无显卡资源,只有CPU
2.简介
Ollama:是一个旨在简化大型语言模型本地部署和运行过程的工具。非常方便将模型服务发布为API。Ollama支持两种格式的模型文件:GGUF、Safetensors。
GGUF:专为大型语言模型设计的二进制文件格式,主要关注存储效率和加载性能,以及跨平台和跨框架的兼容性。
Safetensors: Hugging Face团队开发,专为存储和加载大型张量(tensors)而设计,旨在提供一种高效、安全且易于使用的方式来管理机器学习模型的权重和其他相关数据。将安全性作为核心设计理念之一。
建议采用gguf的模型权重文件,可以通过ollama下载(https://ollama.org.cn/library
),也可以在社区直接找对应模型转为gguf文件或者是现成的gguf。
3.离线安装ollama
3.1准备材料
ollama各版本地址: https://github.com/ollama/ollama/releases/
本次使用:ollama-linux-amd64.tgz ( x86_64版本 )
安装脚本下载地址:https://ollama.com/install.sh
上面两个文件可以通过网盘下载:
通过网盘分享的文件:ollama
链接: https://pan.baidu.com/s/1WPHmMNjoV2SNjuAOiyMQxg?pwd=j36h 提取码: j36h
--来自百度网盘超级会员v6的分享
3.2安装启动
将ollama-linux-amd64.tgz、安装脚本:install.sh上传到linux服务器 ollama目录下:
修改安装脚本
- 将启动脚本的82-84行注释:
#curl --fail --show-error --location --progress-bar \
#"https://ollama.com/download/ollama-linux-${ARCH}.tgz${VER_