archive2026

Gemma 4 with Ollama: picking a size

Google released Gemma 4 under Apache 2.0 on 2 April 2026. How the four sizes differ, how to choose one for your hardware, and the Ollama settings that matter.

4 min read#llm#ollama#local-llm

Google DeepMind released Gemma 4 on 2 April 2026. I have spent some evenings since then trying it on my own machines. Two things make it interesting for local use. The license is now Apache 2.0; earlier Gemma versions had a custom license with use restrictions, so this is simpler for anything commercial. And there are four sizes, from small models for edge devices to a 31B dense model.

All sizes accept text and images. The two small ones also accept audio. I have not tried audio.

The four sizes

Name Type Context Ollama tag
E2B small, for edge devices 128K gemma4:e2b
E4B small, for edge devices 128K gemma4:e4b (the default gemma4)
26B A4B Mixture-of-Experts, about 4B active 256K gemma4:26b
31B dense 256K gemma4:31b

Two notes that I missed at first. “E” means effective parameters: the E2B and E4B models have more weights on disk than the name suggests. Look at the download size in the Ollama library, not at the number in the name. And the Mixture-of-Experts model saves compute, but no memory. The 26B model only uses about 4B parameters per token, so it generates text fast, similar to a small model. But all 26B parameters must be in memory, so plan RAM or VRAM like for a 26B model.

How to choose

This is how I would pick, by memory first:

  • Laptop or mini PC with 16 GB RAM, no GPU: E4B. It is fast enough for chat, summaries and simple tool calls.
  • Raspberry Pi 5 or other small board: E2B, and only for short prompts. Output is slow.
  • Desktop with a 24 GB GPU, or a Mac with 32 GB or more: 26B. It gives much better answers than E4B and is still fast because of the MoE design.
  • Quality first, and you have the memory: 31B dense. It is slower than 26B on the same hardware.

Try two sizes with your own prompts before you decide. When you compare, use the same quantization level; a Q4 31B against an 8-bit 26B tells you little.

Running it with Ollama

Update Ollama first. A new model family often needs a new Ollama version, and older versions may fail to load it or give strange output. Check this before you decide the model is bad.

ollama --version
ollama pull gemma4:e4b
ollama run gemma4:e4b "Explain MQTT retained messages in three sentences."

Check what you downloaded:

ollama show gemma4:e4b

This prints the parameter count, the quantization, and the context length the model supports.

Set the context size yourself

The model supports 128K or 256K tokens, but Ollama does not load the model with the full context by default. A larger context needs more memory for the KV cache. If you send a long document and the context is too small, the start of the document is cut off without an error. This one cost me some confused answers before I understood it.

Set num_ctx per request through the API:

curl http://localhost:11434/api/chat -d '{
  "model": "gemma4:e4b",
  "messages": [{"role": "user", "content": "Summarize this log: ..."}],
  "options": {"num_ctx": 16384},
  "stream": false
}'

Or make a variant with a Modelfile, so every client gets the same setting:

FROM gemma4:e4b
PARAMETER num_ctx 16384
ollama create gemma4-e4b-16k -f Modelfile

Do not set the full 128K “just in case”. Pick the size your longest real input needs, plus room for the answer. Then watch memory use with ollama ps, which shows the loaded size and whether the model runs on GPU or CPU.

Images

Gemma 4 accepts images in all sizes. With the CLI, put the file path in the prompt:

ollama run gemma4:e4b "What is shown in this picture? ./frame.jpg"

Through the API, send the image as base64 in the images field of a message. This is useful for a camera project: describe a frame, or check whether a door is open. For counting or locating objects, a detector like YOLO is still faster and more exact. Use the language model for questions that need a description.