Overview
Ollama downloads open-weight models and serves them locally on port 11434. Use it for three cases and use a hosted frontier model for everything else.
- Offline or air-gapped hosts.
- Data that cannot leave the machine (patient records, restricted source code, contract-bound PII).
- Bulk low-stakes work (classification, extraction) where the marginal token is free once the GPU is paid for.
Tags ending in -cloud run on Ollama’s hosted service, not your hardware. Do not use them in the privacy lane; OLLAMA_NO_CLOUD=1 disables cloud features on a server.
Pick the model by memory budget, then benchmark
The weights plus the KV cache must fit in VRAM (or unified memory on Apple Silicon). A model that spills to system RAM is far slower. Sizes below are the default-quantization download sizes on the Ollama library as of 2026-10-01.
| Memory | Candidates (pull an explicit size tag) |
|---|---|
| 8 to 16 GB | qwen3.5:9b (6.6 GB), gemma4:e4b, gpt-oss:20b (14 GB) |
| 24 to 32 GB | qwen3.8:27b (18 GB), gemma4:31b (19 to 20 GB), glm-4.7-flash (19 GB) |
| 24 to 32 GB, code | qwen3-coder:30b (19 GB, 3B active MoE, 256K context) |
| 64 to 80 GB | gpt-oss:120b (65 GB) |
- Always pull an explicit size tag.
:latestpoints at a different size per family (qwen3.6pulls the 35B,gemma4pulls E4B,gpt-osspulls 20B). - Gemma 4 E2B and E4B accept audio as well as image input; the larger Gemma 4 sizes take images only.
- For embeddings use a dedicated model, not a chat model (see embeddings):
embeddinggemma,qwen3-embedding,nomic-embed-text, orbge-m3. - Build a 50 to 100 question golden set from your own task and pick the smallest model that passes. Public benchmarks do not predict your domain.
Use Q4_K_M by default and move up only on evidence
Quantization stores weights at fewer bits. Memory is roughly bits per weight divided by 8, in GB per billion parameters, plus the KV cache. Bits per weight below are from the llama.cpp quantize benchmarks.
| Tag suffix | Bits/weight | GB per billion params | Use |
|---|---|---|---|
q3_K_M | 4.0 | 0.5 | Only when memory forces it |
q4_K_M | 4.9 | 0.6 | Default |
q5_K_M / q6_K | 5.7 / 6.6 | 0.7 / 0.8 | Step up when Q4 fails your eval |
q8_0 | 8.5 | 1.1 | Near-lossless; fits when you have headroom |
fp16 / bf16 | 16 | 2.0 | Reference runs |
ollama pull qwen3.8:27b # default tag, about 18 GB
ollama pull qwen3-coder:30b-a3b-q8_0 # 32 GB- Run the same golden set at
q4_K_Mand one step up, then keep the cheaper one that passes. Try Q5 or Q6 before jumping to Q8. - When a model ships a
qattag (Gemma 4) or a native 4-bit format (gpt-oss ships MXFP4), compare it againstq4_K_Mon your eval instead of re-quantizing it yourself. - Do not mix quantization levels when a pipeline compares or merges outputs across calls.
Size context length to the task
Context memory grows with the window, and the default depends on VRAM: 4K under 24 GiB, 32K at 24 to 48 GiB, 256K at 48 GiB or more. Agents and coding tools need at least 64K.
OLLAMA_CONTEXT_LENGTH=65536 OLLAMA_FLASH_ATTENTION=1 OLLAMA_KV_CACHE_TYPE=q8_0 ollama serve
ollama ps # CONTEXT and PROCESSOR columns show the real allocation and any CPU offloadOLLAMA_KV_CACHE_TYPE=q8_0needs Flash Attention and uses about half the memory of the defaultf16;q4_0uses about a quarter at a visible quality cost on long contexts.- Set a larger window only when inputs need it. For chat, a small window is faster; for long documents, retrieve instead (see rag).
Route work between local and hosted models
- Fast path: send classification, summarization, and extraction to Ollama; keep the hard reasoning step on a frontier model.
- Fallback: fail over to a local model when the hosted API is down or over quota.
- Claude Code can target a local model through Ollama’s Anthropic-compatible endpoint; see ollama-serving for the setup and its limits.
Log both routes with one schema so quality and cost compare side by side. The same prompt rarely ports unchanged; see prompt-design.