ollama
Ollama 是前 Docker 工程师 Jeffrey Morgan 和 Michael Fessenden 主要用 Go 和 C++ 语言实现的本地大语言模型(LLM)运行与管理平台,使用 MIT 许可,首个版本发布于 2023 年;随后作者成立了同名初创企业 Ollama Inc.,该企业在获得光速创投(Lightspeed)等机构的早期融资后,作为官方实体主导后续的开源开发与生态建设。
ollama.com/search 网站索引了各类模型。
Install
brew install ollama
Quick start
Run faster models on Apple M2 chip 16G VRAM:
| Name | Size/Usage | Context | Input |
|---|---|---|---|
qwen3-vl:8b | 6.1GB | 256K | Text,Image |
qwen3-vl:4b-instruct-q4_K_M | 3.3GB | 256K | Text,Image |
It is slower but it still ok
| Name | Size/Usage | Context | Input |
|---|---|---|---|
qwen3:8b | 5.2GB | 40K | Text |
For more than 16G VRAM, Apple M2 newer chip
| Name | Size/Usage | Context | Input |
|---|---|---|---|
qwen3.6:27b-q4_K_M | 17GB | 256K | Text,Image |
qwen3.5:27b-q4_K_M | 17GB | 256K | Text,Image |
qwen2.5:14b-instruct-q4_K_M | 9.0GB | 32K | Text |
deepseek-r1:14b | 9.0GB | 128K | Text |
pull a model ollama pull deepseek-r1:8b
the model default storage location:
- macOS
$HOME/.ollama/models - windows
%USERPROFILE%\.ollama\models
start HTTP service
# default is 127.0.0.1:11434
export OLLAMA_HOST=0.0.0.0:11434
export OLLAMA_KEEP_ALIVE=30d
export OLLAMA_MODELS=$HOME/.ollama/models
ollama serveAccess ollama via HTTP API http://localhost:11434
Test it on macOS shell
curl http://localhost:11434/api/generate -d '{
"model": "deepseek-r1:8b",
"prompt": "answer in shortly: why is the sky blue?",
"stream": false
}'Test it on Windows pwsh
(Invoke-WebRequest -method POST -Body '{"model":"deepseek-r1:8b", "prompt":"answer in shortly: why is the sky blue?", "stream": false}' -uri http://localhost:11434/api/generate ).Content | ConvertFrom-jsonThe built-in OpenAI-compatible API (v1) can be accessed via: curl http://localhost:11434/v1/models .
ollama is similar docker CLI tool
ollama ps
ollama list
ollama pull <model name>HTTP API
list models /api/tags
chat completion /api/generate
模型索引 ollama.com/search
model 上的标记 tools embedding thinking vision 含义
| tag 标记 | 描述 | 使用场景 | 代表模型 |
|---|---|---|---|
| tools | 支持 tool calling / function calling,可以按 schema 调用外部工具。 | Agent、查数据库、调用 API、联网搜索。 | qwen3, llama3-groq-tool-use |
| embedding | 输出文本向量,不用于普通聊天回复。 | 语义搜索、相似度匹配、RAG、聚类。 | embeddinggemma, nomic-embed-text |
| thinking | 支持独立的 thinking / reasoning 输出字段。 | 展示、审计或隐藏推理过程。 | deepseek-r1, qwen3, gpt-oss |
| vision | 支持图片输入,通常可以同时处理图片和文本。 | 图片问答、OCR、图表/截图理解。 | gemma3, llava, qwen3-vl |
model 名后缀含义
| 模型名后缀 quant | 描述 | 使用场景 | 代表模型 |
|---|---|---|---|
vl | vision-language,可以识别图片信息。 | 需要上传图片、截图、图表一起理解的任务。 | qwen3-vl:8b |
instruct | 指令微调版本,比 base 模型更适合按用户指令对话。 | 聊天助手、问答、代码解释、工具调用入口。 | qwen2.5:14b-instruct-q4_K_M |
it | instruction tuned 的缩写,含义接近 instruct。 | 优先选择给终端聊天或 API 对话使用。 | gemma3:4b-it-q4_K_M |
q4_K_M | llama.cpp / GGUF 常见 4-bit K quant medium 量化格式。 | 显存有限时优先,体积、速度和质量较均衡。 | qwen3:8b-q4_K_M |
q5_K_M | 5-bit K quant medium,通常比 q4_K_M 更占空间、质量更好。 | 显存略宽裕时换取更稳的输出质量。 | qwen2.5-coder:14b-instruct-q5_K_M |
q8_0 | 8-bit 量化,体积更大,质量更接近原始权重。 | 高显存机器、本地质量优先测试。 | llama3.1:8b-instruct-q8_0 |
14b-instruct-q4_K_M | 组合 tag:14B 参数、指令微调、4-bit K medium 量化。 | 判断模型规模、用途和显存压力。 | qwen2.5:14b-instruct-q4_K_M |
使用 Hugging Face 上的模型
下载 GGUF 文件
pip install -U "huggingface_hub[cli]"
mkdir -p ~/models/
hf auth login
# Create a token from https://huggingface.co/settings/tokens
hf download <user>/<model>[-quant] --local-dir ~/models/生成 Modelfile
FROM ./Qwen3.5-9B-Q4_K_M.gguf
PARAMETER temperature 0.7
PARAMETER top_p 0.9
PARAMETER num_ctx 16384
TEMPLATE """{{- if .System }}{{ .System }}{{ end }}
{{- range .Messages }}
<|im_start|>{{ .Role }}
{{ .Content }}<|im_end|>
{{ end }}<|im_start|>assistant
"""
SYSTEM "You are a helpful assistant."构建 ollama create Qwen3.5-9B-Q4_K_M -f Modelfile
启动 ollama run Qwen3.5-9B-Q4_K_M:latest
