Skip to content
Tools9 min read

Run Google's Gemma 4 on your own laptop with Ollama

Gemma 4 is Google DeepMind's family of open models, and the small versions run on a laptop. Ollama, a free open-source app, runs it with one command. Here is the install, which size to pick, the commands worth knowing, images, memory, and how your code can call it.

Anas Siddiqui @anas.helloworld
New guides start as reels. Follow so you catch the next one.

Contents

Gemma 4 is a family of open models from Google DeepMind, released under the Apache 2.0 licence. Ollama's model page says the smaller ones are "specifically designed for efficient local execution on laptops and mobile devices". Once a model is downloaded, it runs on your machine: what you type is answered there, not on someone else's server.

Gemma and Ollama are not made by webridgeAI. Every command, size and figure below was checked against ollama.com/library/gemma4, the Ollama documentation and Google's Gemma 4 announcement on 15 October 2026. Model pages change, so check the sizes again before a large download.

1. What you need

WhatWhy
OllamaA free, open-source app (MIT licence) that downloads open models and runs them on your computer. macOS, Windows and Linux.
Disk spaceFrom about 4.6GB for the smallest Gemma 4 model up to about 20GB for the largest.
MemoryThe model has to fit in memory while it runs. See section 8.
A terminalTerminal on a Mac, PowerShell on Windows. Ollama also has a desktop app if you prefer a chat window.

No account and no API key are needed to run a model locally.

2. Install Ollama

On macOS or Linux:

curl -fsSL https://ollama.com/install.sh | sh

On Windows, in PowerShell:

irm https://ollama.com/install.ps1 | iex

Or download the installer from ollama.com/download.

Check it worked:

ollama --version

On macOS and Windows, Ollama updates itself: choose "Restart to update" from the menu bar or taskbar icon when an update is ready. On Linux, run the install script again.

3. Run Gemma 4 for the first time

ollama run gemma4

The first run downloads the model (the default is about 6.6GB to 9.5GB), then opens a chat in your terminal. After that it starts from your disk. Type a question and press Enter. Type /bye to leave, or /? to list the other chat commands.

To paste several lines at once, wrap them in triple quotes:

>>> """Summarise this in two lines:
... (paste your text here)
... """

You can also ask a single question without opening a chat:

ollama run gemma4 "Explain what a context window is in two sentences."

4. Choose the right size

Sizes and details from Ollama's model page:

CommandDownloadParametersContextInput
ollama run gemma4:e2b4.6GB to 7.5GB2.3B effective (5.1B with embeddings)128KText, image, audio
ollama run gemma4:e4b (the default)6.6GB to 9.5GB4.5B effective (8B with embeddings)128KText, image, audio
ollama run gemma4:12b7.7GB to 8.0GB12B (listed as a workstation model)256KText, image
ollama run gemma4:26b16GB to 19GB25.2B total, 3.8B active (mixture of experts)256KText, image
ollama run gemma4:31b19GB to 20GB30.7B (dense)256KText, image

What the columns mean:

  • Effective parameters (the "E" in E2B and E4B): 2.3B and 4.5B parameters do the computing, and the full file (5.1B and 8B) also carries extra embedding weights. That is why the download is bigger than the name suggests.
  • Mixture of experts (the 26B): the model holds 25.2B parameters but uses only 3.8B for each word it writes, so it answers faster than its size suggests. It still needs the memory for all 25.2B.
  • Context is how much text the model can consider at once. 128K tokens is roughly a few hundred pages.

How much better do the bigger ones get? These are Google's own published results, shown on Ollama's page, not independent tests:

BenchmarkE2BE4B26B31B
MMLU Pro (general knowledge)60.0%69.4%82.6%85.2%
LiveCodeBench v6 (coding)44.0%52.0%77.1%80.0%
GPQA Diamond (hard science questions)43.4%58.6%82.3%84.3%

Our suggestion:

  • Small or older laptop, or 8GB of memory: start with gemma4:e2b.
  • Most recent laptops: the default gemma4 (E4B).
  • 16GB or more, coding or long documents: try gemma4:12b.
  • A workstation, or a Mac with a lot of unified memory: gemma4:26b or gemma4:31b.

That mapping is our rule of thumb, not Ollama's. If answers come quickly, step up one size; if your machine slows to a crawl, step down. Avoid tags that end in cloud if you want everything local: those run on Ollama's servers.

5. The commands worth knowing

CommandWhat it does
ollama pull gemma4:e2bDownload a model without starting a chat.
ollama lsList the models you have downloaded.
ollama psList the models loaded in memory right now, and whether they are on the GPU or CPU.
ollama stop gemma4Unload a model from memory immediately.
ollama rm gemma4:31bDelete a model to free disk space.
ollama serveStart the Ollama server yourself (the desktop app normally does this for you).

Where the downloaded models live, if you want to check the space they use:

  • macOS: ~/.ollama/models
  • Linux: /usr/share/ollama/.ollama/models
  • Windows: C:\Users\%username%\.ollama\models

To keep them on another drive, set the OLLAMA_MODELS environment variable to the new folder.

6. Show it an image

Every Gemma 4 size reads images. In the terminal, put the file path in your prompt:

ollama run gemma4 ./receipt.jpg "Does this receipt add up? Show the maths."

In a chat that is already open, drag the image file into the terminal window and type your question after the path. In the Ollama desktop app, attach the image to your message.

Good first tests: a photo of a receipt, a screenshot of an error message, a chart from a report, a page of handwritten notes.

The E2B and E4B models also accept audio input, according to Ollama's model page.

7. Thinking mode

Gemma 4 can reason step by step before it answers. In the terminal you may see a block of thinking before the reply. It tends to help on hard questions and makes every answer slower.

Through the API (section 10), add "think": true to a request to ask for the reasoning, or "think": false to ask for an answer without it where the model allows. The reasoning comes back in its own field (message.thinking), separate from the answer (message.content), so your code can show or hide it.

8. Context length and memory

Two things decide how much memory Gemma uses:

  • The model size you picked in section 4. The model has to fit in memory while it runs, so you need more free memory than the download size.
  • The context length: how much text it keeps in view. Ollama's FAQ gives the default as 4096 tokens and notes that memory use grows with it.

To raise the context length for one chat (for a long document), type this inside the chat:

/set parameter num_ctx 16384

To change it for everything, set OLLAMA_CONTEXT_LENGTH (for example 8192) before starting Ollama.

Check where the model is running with ollama ps. The PROCESSOR column shows 100% GPU when it fits in graphics memory (or a Mac's unified memory), 100% CPU when it runs on the processor alone, or a split such as 48%/52% CPU/GPU. Fully on the GPU is fastest. If you see a large CPU share and slow answers, pick a smaller model or a shorter context.

Ollama keeps a model in memory for 5 minutes after you last used it, so the next question starts quickly. ollama stop gemma4 frees the memory straight away. To change the default, set OLLAMA_KEEP_ALIVE (for example 30m, or 0 to unload after every answer).

9. Give it a standing instruction

If you always want the same behaviour (short answers, British spelling, a particular format), build your own variant with a Modelfile. Create a file called Modelfile:

FROM gemma4
SYSTEM """You answer in plain English, in five sentences or fewer, and say when you are not sure."""

Then create and run it:

ollama create my-gemma -f Modelfile
ollama run my-gemma

It reuses the weights you already downloaded, so it takes almost no extra disk space.

10. Call it from your own code

Ollama runs a server on your machine at http://localhost:11434. Ollama's documentation notes that local requests need no API key. By default the server only listens on your own computer (127.0.0.1), so other devices on your network cannot reach it unless you change OLLAMA_HOST.

From the terminal:

curl http://localhost:11434/api/chat -d '{
  "model": "gemma4",
  "messages": [{ "role": "user", "content": "Summarise this paragraph in one line: ..." }],
  "stream": false
}'

From Python (pip install ollama):

from ollama import chat
 
response = chat(
    model="gemma4",
    messages=[{"role": "user", "content": "Why is the sky blue?"}],
)
print(response.message.content)

To print the answer as it is written, pass stream=True and loop over the result:

stream = chat(model="gemma4", messages=[{"role": "user", "content": "Why is the sky blue?"}], stream=True)
for chunk in stream:
    print(chunk["message"]["content"], end="", flush=True)

To send an image, add its path to the message: {"role": "user", "content": "Describe this image.", "images": ["photo.jpg"]}.

From JavaScript (npm install ollama):

import ollama from "ollama";
 
const response = await ollama.chat({
  model: "gemma4",
  messages: [{ role: "user", content: "Why is the sky blue?" }],
});
console.log(response.message.content);

From any tool that already speaks the OpenAI format: point it at http://localhost:11434/v1/. Those clients require an API key, but Ollama ignores it, so any value works:

from openai import OpenAI
 
client = OpenAI(base_url="http://localhost:11434/v1/", api_key="ollama")
reply = client.chat.completions.create(
    model="gemma4",
    messages=[{"role": "user", "content": "Write a haiku about local models."}],
)
print(reply.choices[0].message.content)

The local server supports /v1/chat/completions, /v1/completions, /v1/models, /v1/embeddings and /v1/responses.

11. Use it inside other tools

Ollama's model page lists apps it can start with Gemma 4 as the model, using ollama launch:

ollama launch claude --model gemma4
ollama launch opencode --model gemma4

The same page also lists Hermes Agent (hermes) and OpenClaw (openclaw). These are separate products with their own terms, so check what each one sends over the network before you use it with private material. On a Mac, the Ollama app's Settings, then Apps, is where you choose which Ollama models connected desktop apps can use.

12. Privacy: what stays on your laptop

Ollama's FAQ says: "We don't see your prompts or data when you run locally." That holds when:

  • You run a local tag (anything without cloud in its name). Cloud tags send your prompt to Ollama's servers.
  • The app calling the model is also local. A tool that talks to Gemma on your laptop can still send your text somewhere else.
  • You have not exposed the server to your network with OLLAMA_HOST.

Once a model is downloaded, it answers with no internet connection at all. Turning Wi-Fi off is a simple way to prove it to yourself.

13. When something goes wrong

What you seeWhat to try
Answers are very slowRun ollama ps. If most of the model is on the CPU, step down a size or lower num_ctx. Close other heavy apps.
The download stallsRun the same ollama pull again. Check free disk space.
"model not found"Check the exact tag with ollama ls, or the list on ollama.com/library/gemma4.
Your code cannot connect to localhost:11434Make sure Ollama is running (open the app, or run ollama serve).
It forgets the start of a long documentRaise the context length (section 8).
You are low on disk spaceollama ls to see what you have, ollama rm to delete the sizes you do not use.

Honest notes

  • "Frontier-level performance at each size" is how the model page describes Gemma 4, and the benchmark table above is Google's own. Neither is an independent test. Try it on your own work before relying on it.
  • Smaller models are faster and lighter, and they get more things wrong. Check anything that matters, especially numbers and quotes.
  • Download size is not the same as the memory a model needs. Our size suggestions are a starting point, not a guarantee.
Before you go

Found this useful? Get the next one.

Each new guide starts as a reel on Instagram. Follow there or on LinkedIn so you see it first.

Reading is free. So is the call.

Bring the workflow you have in mind. Fifteen minutes is enough to tell whether a system fits it, and if it does not, we say so.

Book a callWrite to usFree, fifteen minutes