Gemma 4 now has a 12B laptop lane, MTP drafters, and QAT checkpoints. Pick an Ollama tag, tune context, and keep local inference on the fast memory path.
A local assistant can read private code, summarize design docs, and test prompts without sending files to a hosted model. Running locally solves privacy, but it creates a fit problem: which tag runs on your machine without crawling?
Gemma 4 and Ollama are a clean starting point. Gemma 4 is Google's Apache 2.0 open-weights family, with dense and Mixture-of-Experts (MoE) variants, native system-prompt support, multimodal inputs, and local tags with 128K or 256K context windows.[1][2] Ollama provides the local server, registry, CLI, and API wrapper.[3]
June 2026 updates changed the recommendation. Google documents Gemma 4 in five sizes: E2B, E4B, 12B, 26B A4B, and 31B. The family also has multi-token prediction (MTP) drafters and quantized checkpoints for lower memory pressure.[4][5][6] Start with E4B, try QAT when memory is tight, test 12B when you want more quality, and move to 26B or 31B only with clear headroom.
A tag chooses the weights, context limit, input modes, and runtime footprint Ollama loads. Current local tags split into laptop and workstation lanes.[7][2] Use gemma4:e2b for tight memory, gemma4:e4b as the default local assistant, and gemma4:12b when E4B already stays fast. Use gemma4:26b as the first workstation MoE test and gemma4:31b only when a dense 20 GB artifact still leaves context headroom.
Dense models run most of the model for every generated token; gemma4:31b is the heavy dense option.[1] MoE models have many expert blocks, but activate a smaller path for each token. Google labels Gemma 4 26B as an A4B MoE, and Ollama describes the 26B tag as a 4B-active workstation model.[1][7]
The gemma4:cloud and gemma4:31b-cloud tags are different. They are Ollama's cloud paths, not local artifacts to size against your GPU.[2]
| First choice | Use it when | Move away when |
|---|---|---|
gemma4:e2b-it-qat | Memory is the hard limit and you need a smoke-test lane | Quality misses the task after the runtime stays on fast memory |
gemma4:e4b | You want the default laptop assistant and a simple baseline | E4B is stable and a measured quality gap justifies 12B |
gemma4:12b | You have headroom after context and process overhead | ollama ps shows CPU offload or latency breaks the budget |
gemma4:26b | You have workstation memory and want to test the MoE path | The smaller tag meets the same eval target with better latency |
gemma4:31b | You specifically need the dense large-model comparison | Its 20 GB artifact leaves too little room for context and cache |
Fit rule: Keep the smallest tag that passes your eval and remains on fast memory at the context length you actually use.
Default to gemma4:e4b. As of July 11, 2026, Ollama still marks E4B as the latest local tag even though 12B and QAT variants are listed.[7] Pin exact tags in scripts.
Published size is the download artifact, not the full runtime budget. At inference time, the machine also needs memory for loaded weights, prompt tokens, image tokens, the key-value (KV) cache, and process overhead.
The KV cache stores attention keys and values from previous tokens so the model doesn't recompute the whole conversation every step. Because it grows with context length, a tag can fit at 4K and become painful at 64K.
Use a conservative fit order:
gemma4:e2b-it-qat or gemma4:e2b.gemma4:e4b-it-qat, gemma4:e4b, then gemma4:12b only if E4B has margin.gemma4:12b before gemma4:26b-a4b-it-qat or gemma4:26b.gemma4:26b before dense gemma4:31b.
Rule: a smaller model that stays fully on fast memory usually beats a bigger model that barely fits. If gemma4:26b and gemma4:31b both look possible, test 26B first because its MoE active path is much smaller.[1] If gemma4:e4b almost fits, try the QAT tag before dropping to E2B.
Normal post-training quantization compresses a trained model after training. That often works well, but the model didn't learn under those low-precision constraints.
Quantization-aware training (QAT) changes that sequence. The model trains with simulated low-precision behavior, so the checkpoint is better prepared for compressed inference.[6]
Ollama's current tags show the desktop effect: E2B drops from 7.2 GB to 4.3 GB with QAT, E4B from 9.6 GB to 6.1 GB, 12B from 7.6 GB to 7.2 GB, 26B from 18 GB to 16 GB, and 31B from 20 GB to 19 GB.[2] Don't read QAT as "same quality, no tradeoff, always much smaller." The biggest published size drops are on E2B and E4B. QAT improves the chance that a useful model stays within your memory budget.
Standard decoding generates one token, appends it to context, then runs the model again. That loop is reliable, but slow when the next few tokens are predictable.
Multi-token prediction (MTP) adds a drafter path. The drafter proposes likely next tokens, and the target Gemma 4 model verifies them. Accepted drafts give you multiple output tokens from fewer expensive target-model steps. Rejected drafts fall back to the target model's verified output.[5]
MTP helps generated-token throughput, not model fit. It doesn't remove prompt-processing cost, image-processing cost, or KV-cache memory. Ollama's visible specialized MTP tag is gemma4:31b-coding-mtp-bf16, a 64 GB text-and-image artifact, so it isn't the laptop starting point.[2] Add MTP after the base or QAT tag fits, then keep it only if sustained tokens per second improves.
Install Ollama from the official project. On Linux, the install script is fastest. On macOS and Windows, use the desktop app from Ollama.[3] Then pull one explicit tag:
1curl -fsSL https://ollama.com/install.sh | sh
2
3ollama --version
4ollama pull gemma4:e4b
5ollama run gemma4:e4bSwap in gemma4:e4b-it-qat when memory is tight. Try gemma4:12b only after E4B stays fast under your real context length.
After the first response, run ollama ps. The PROCESSOR column tells you whether the model stayed on GPU or spilled partly to CPU.[8] Spilling is often why a model "works" but feels unusable.
Separate installation failures from model failures. Check the CLI, local HTTP service, downloaded tag, and loaded process in that order:
1ollama --version
2curl -s http://localhost:11434/api/tags
3ollama pull gemma4:e4b
4ollama run gemma4:e4b "Reply with exactly: local-ready"
5ollama psThe response text verifies generation. It doesn't prove that the model fits well. Read ollama ps after generation and record its NAME, PROCESSOR, and CONTEXT columns. A successful answer with partial CPU placement is a valid smoke test but a poor latency baseline.
If curl can't connect, start ollama serve and repeat the HTTP check. A responsive service with a missing tag needs another pull with the full error preserved. Working generation with bad placement calls for a context or tag change rather than an Ollama reinstall.
Ollama exposes OpenAI-compatible /v1/chat/completions and /v1/responses endpoints, so existing SDK code can point at http://localhost:11434/v1/ with a placeholder key like ollama.[9] Use that path when you want one integration surface across hosted and local models.
Use the native Ollama API when you need model-specific controls, such as Gemma 4's thinking token, sampling settings, or direct num_ctx options. Send model: "gemma4:e4b", normal chat messages, and options like {"temperature": 1.0, "top_p": 0.95, "top_k": 64, "num_ctx": 32768}. The Ollama Gemma 4 page recommends those sampling defaults and enables thinking with <|think|> at the start of the system prompt.[7] Keep prior thinking blocks out of durable chat history unless your application has a specific reason to store them.
For multimodal prompts, Google's model card gives model-input ordering guidance: place image content before the text prompt, but place audio content after the text prompt.[1] Ollama controls the local request format and runtime support. Its main local Gemma 4 tags currently list text and image input, so don't infer local audio support from Google's model-level guidance; verify the exact Ollama tag and runtime before planning an audio workflow.[2]
Runtime boundary: Google documents how Gemma 4 expects supported modalities to be ordered. Ollama documentation and tag metadata determine which of those modalities your local endpoint can accept.
A model's maximum context isn't necessarily what Ollama allocates by default. Ollama's current context docs say defaults are tiered by VRAM: less than 24 GiB gets 4K, 24-48 GiB gets 32K, and 48 GiB or more gets 256K.[10] The FAQ still describes 4096 tokens as the baseline default and shows override paths.[8]
Set the smallest context window that fits the task. For the daemon, start with OLLAMA_CONTEXT_LENGTH=32768 ollama serve; inside ollama run, use /set parameter num_ctx 32768; and through the native API, send "options": {"num_ctx": 32768}.
Then run ollama ps and check CONTEXT plus PROCESSOR. If the model is split across CPU and GPU, reduce num_ctx, try the matching QAT tag, or move down a model size.[10][8]
OpenAI-compatible requests don't set context size per request. For that path, create a derived model with a Modelfile, such as FROM gemma4:e4b plus PARAMETER num_ctx 32768, then call ollama create.[9]
Common failures usually come from mixing up bottlenecks:
num_ctx and check ollama ps.Debugging habit: separate model fit, context fit, and decode speed. QAT helps model fit. num_ctx helps context fit. MTP helps decode speed when your runtime exposes a drafter path.
Use symptoms to choose the next measurement:
| Symptom | Check | Likely next move |
|---|---|---|
| Connection refused on port 11434 | Ollama service status | Start or restart the service |
| Pull stops repeatedly | Free disk space and network error | Free space, then retry the same tag |
| First prompt crashes | num_ctx and system memory | Restart at a shorter context |
| First token is slow | Prompt length and load_duration | Warm the model, then shorten the prompt |
| Decode starts fast and degrades | ollama ps placement | Reduce context or use a smaller tag |
| QAT fits but quality drops | Fixed task-level acceptance tests | Keep standard E4B or test 12B with headroom |
Don't compare tags while changing prompt, context, and sampling together. That produces a number but hides its cause. Keep a written run record so a later runtime update doesn't get mistaken for a model-quality change.
Build a small benchmark around the local API. Run the same prompt against gemma4:e4b, gemma4:e4b-it-qat, gemma4:12b, and gemma4:26b-a4b-it-qat if your machine has workstation headroom. Record time to first token, tokens per second, num_ctx, ollama ps PROCESSOR, and image usage. That result tells you whether the limit is weight memory, context pressure, or decode throughput.
Use three prompt classes instead of one favorite prompt:
Run each prompt once to warm the model, then run measured trials with the same num_ctx, sampling settings, and output cap. Store raw native-API responses because Ollama includes prompt and generation token counts plus timing fields.[9] Don't compare an image request with a text-only request or a cold load with a warm process.
This shell request disables streaming so one JSON object contains the complete timing record:
1curl -s http://localhost:11434/api/generate \
2 -d '{
3 "model": "gemma4:e4b",
4 "prompt": "List three checks for a failing unit test.",
5 "stream": false,
6 "options": {
7 "num_ctx": 8192,
8 "temperature": 0
9 }
10 }' > gemma4-e4b-run.jsonInspect the fields without inventing a machine-independent target:
1jq '{
2 model,
3 done,
4 prompt_eval_count,
5 eval_count,
6 total_duration,
7 load_duration,
8 prompt_eval_duration,
9 eval_duration
10}' gemma4-e4b-run.jsonCompute rates from each response instead of copying a published result. Durations are reported in nanoseconds, so generated-token throughput is eval_count / (eval_duration / 1e9). Record machine, Ollama version, tag, context, placement, and whether the run was cold or warm beside that value.
Quality needs a separate score. Write expected properties before running models, such as "names all three failing assertions" or "returns valid JSON matching schema." A faster tag loses if it misses the required behavior. Keep the smallest tag that passes those checks and meets your latency budget.
A useful receipt has enough context to repeat the comparison later:
1machine: <CPU, GPU, and memory>
2ollama_version: <ollama --version>
3tag: gemma4:e4b
4context: 8192
5processor: <ollama ps PROCESSOR>
6prompt_pack: <path or commit>
7sampling: temperature=0
8warm_state: warm
9raw_response: gemma4-e4b-run.jsonRepeat the same receipt for QAT and 12B. If only one field changes, the comparison can answer a specific question. If several fields change, treat it as a new experiment rather than a continuation.
Gemma 4 is a strong local pick when you want an Apache 2.0 family, laptop-scale tags, a 12B middle lane, QAT checkpoints, a MoE workstation option, and a simple local API.[1][4][6][9] Start with gemma4:e4b, use QAT when memory is tight, test 12B with margin, and try 26B only when ollama ps keeps model plus context on the fast path.[7][10]
Gemma 4 Model Card
Gemma Team, Google DeepMind · 2026
gemma4 tags
Ollama · 2026
Ollama GitHub Repository
Ollama Team · 2026
Introducing Gemma 4 12B: a unified, encoder-free multimodal model
Google · 2026
Accelerating Gemma 4: faster inference with multi-token prediction drafters
Google · 2026
Gemma 4 QAT models: Optimizing model compression for mobile and laptop efficiency
Google · 2026
gemma4
Ollama · 2026
FAQ - Ollama
Ollama · 2026
OpenAI compatibility - Ollama
Ollama · 2026
Context length - Ollama
Ollama · 2026