Ollama 本地部署大型语言模型完整指南
Ollama 简介
Ollama 是一个基于 Go 语言开发的开源框架,旨在简化本地运行大型语言模型(LLM)的过程。它允许用户在个人电脑上高效地加载、运行和管理各种开源模型,无需依赖云端服务。
官方文档:https://ollama.ai/docs GitHub 仓库:https://github.com/ollama/ollama
安装与配置
下载安装
访问 Ollama 官网根据操作系统类型选择对应的安装包。以下以 macOS 为例进行演示。
安装完成后,在终端输入 ollama 即可查看支持的命令列表。
Usage:
ollama [flags]
ollama [command]
Available Commands:
serve Start ollama
create Create a model from a Modelfile
show Show information for a model
run Run a model
pull Pull a model from a registry
push Push a model to a registry
list List models
cp Copy a model
rm Remove a model
help Help about any command
版本检查与模型管理
查看当前安装的 Ollama 版本:
ollama -v
# 输出示例:ollama version is 0.1.31
查看已下载的模型列表:
ollama list
# 输出示例:
# NAME ID SIZE MODIFIED
# gemma:2b b50d6c999e59 1.7 GB 3 hours ago
下载大模型
安装后默认会提示是否安装 llama2 模型。以下是 Ollama 支持的部分主流模型及其参数:
| Model | Parameters | Size | Command |
|---|---|---|---|
| Llama 3 | 8B | 4.7GB | ollama run llama3 |
| Llama 3 | 70B | 40GB | ollama run llama3:70b |
| Mistral | 7B | 4.1GB | ollama run mistral |
| Gemma | 2B | 1.4GB |


