Skip to content

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:

NameSize/UsageContextInput
qwen3-vl:8b6.1GB256KText,Image
qwen3-vl:4b-instruct-q4_K_M3.3GB256KText,Image

It is slower but it still ok

NameSize/UsageContextInput
qwen3:8b5.2GB40KText

For more than 16G VRAM, Apple M2 newer chip

NameSize/UsageContextInput
qwen3.6:27b-q4_K_M17GB256KText,Image
qwen3.5:27b-q4_K_M17GB256KText,Image
qwen2.5:14b-instruct-q4_K_M9.0GB32KText
deepseek-r1:14b9.0GB128KText

pull a model ollama pull deepseek-r1:8b

the model default storage location:

  • macOS $HOME/.ollama/models
  • windows %USERPROFILE%\.ollama\models

start HTTP service

sh
# 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 serve

Access ollama via HTTP API http://localhost:11434

Test it on macOS shell

sh
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

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-json

The built-in OpenAI-compatible API (v1) can be accessed via: curl http://localhost:11434/v1/models .

ollama is similar docker CLI tool

sh
ollama ps
ollama list
ollama pull <model name>

HTTP API

list models /api/tags

chat completion /api/generate

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描述使用场景代表模型
vlvision-language,可以识别图片信息。需要上传图片、截图、图表一起理解的任务。qwen3-vl:8b
instruct指令微调版本,比 base 模型更适合按用户指令对话。聊天助手、问答、代码解释、工具调用入口。qwen2.5:14b-instruct-q4_K_M
itinstruction tuned 的缩写,含义接近 instruct优先选择给终端聊天或 API 对话使用。gemma3:4b-it-q4_K_M
q4_K_Mllama.cpp / GGUF 常见 4-bit K quant medium 量化格式。显存有限时优先,体积、速度和质量较均衡。qwen3:8b-q4_K_M
q5_K_M5-bit K quant medium,通常比 q4_K_M 更占空间、质量更好。显存略宽裕时换取更稳的输出质量。qwen2.5-coder:14b-instruct-q5_K_M
q8_08-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 文件

shell
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

txt
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

Released under the CC-BY-NC-4.0