Gemma 4 / Ollama

Gemma 4 & EmbeddingGemma 2 on Ollama

Ollama is the most popular way to run Google's open models on your own machine. One command downloads a model, keeps it ready in the background, and gives every app on your computer a local API. This guide covers both the chat model and the new search model.

Windows, macOS and Linux · free · sizes from Ollama's library ·

$ ollama pull gemma4:12b pulling weights pulling template pulling params success $ ollama list NAME SIZEgemma4:12b 8.0 GB Ollama server localhost:11434 Chat app Code editor Your script
Pull once, then every app on your machine can use the model.
1 commandto download and chat
4.3 - 19 GBGemma 4 QAT downloads
378 MBSmallest EmbeddingGemma 2
:11434Local API port
Quick start

Up and running in three steps

  1. Install Ollama

    Download it from ollama.com/download. On Linux: curl -fsSL https://ollama.com/install.sh | sh

  2. Run a Gemma 4 model

    In a terminal: ollama run gemma4:12b-it-qat. The first run downloads 7.2 GB, then opens a chat. On an 8 GB machine use gemma4:e4b-it-qat.

  3. Add the search model if you want it

    ollama pull embeddinggemma-2 adds EmbeddingGemma 2 in 1.3 GB.

Step-by-step help for each system is in the install guide; Mac details in Mac setup. Prefer an app with buttons? See LM Studio.

Gemma 4

Gemma 4 tags on Ollama

Each size has a default tag and a QAT tag. The QAT ones are Google's quantisation-aware builds, a little smaller and better at holding quality.

ModelDefault tagDownloadQAT tagQAT downloadContext
Gemma 4 E2Bgemma4:e2b4.6 - 7.5 GBgemma4:e2b-it-qat4.3 GB128K
Gemma 4 E4Bgemma4:e4b6.6 - 9.5 GBgemma4:e4b-it-qat6.1 GB128K
Gemma 4 12Bgemma4:12b7.7 - 8.0 GBgemma4:12b-it-qat7.2 GB256K
Gemma 4 26B A4Bgemma4:26b-a4b16 - 19 GBgemma4:26b-a4b-it-qat16 GB256K
Gemma 4 31Bgemma4:31b19 - 20 GBgemma4:31b-it-qat19 GB256K
Tag endingWhat it isExample
-it-qatGoogle's quantisation-aware 4-bit build - the usual choicegemma4:12b-it-qat
-it-q4_K_MStandard 4-bitgemma4:e4b-it-q4_K_M
-it-q8_08-bit: larger, closer to full qualitygemma4:12b-it-q8_0
-it-bf16Full precisiongemma4:31b-it-bf16, 63 GB
-mlxApple silicon buildgemma4:12b-mlx, 7.7 GB
-mxfp8 · -nvfp4Formats for particular graphics hardwaregemma4:31b-nvfp4
:cloudRuns on Ollama's hosted service, not your machinegemma4:cloud
Do not rely on plain gemma4 for anything that must stay the same. It currently points to the E4B build, and Ollama can repoint it. Name the size, and the build if it matters.

Sizes from Ollama's gemma4 tag list, October 2026; a range means the tag has more than one build. gemma4:26b is a shorter name for the 26B A4B. How these names relate to Hugging Face names is on the models page; choosing a size is covered in how to download, the VRAM guide and QAT builds.

Daily use

Commands you will use

In the terminal

ollama pull gemma4:12b-it-qat          # download a model
ollama run gemma4:12b-it-qat           # chat in the terminal
ollama run gemma4 "roses are red"      # one-off prompt
ollama list                            # models you have
ollama ps                              # models loaded now, and on what
ollama show gemma4:12b-it-qat          # details of a model
ollama stop gemma4:12b-it-qat          # unload from memory
ollama rm gemma4:12b-it-qat            # delete to free disk

Inside a chat

/set system You are a concise assistant.
/set parameter num_ctx 32768     # longer memory for this chat
/set think                       # reason before answering
/set nothink                     # answer straight away
/clear                           # forget the conversation so far
/bye                             # leave

Ask about a picture

ollama run gemma4:12b-it-qat "What is in this image? ./photo.png"

Put the image's file path in the prompt. Every Gemma 4 size reads images.

Thinking controls from Ollama's thinking documentation. More on using the model in how to use Gemma 4, chat and prompting.

Settings

Three settings worth changing

📏

Context length

Gemma 4 holds 128K or 256K tokens, but Ollama starts a model with a much smaller window. Raise it if long chats lose their beginning. More context uses more memory.

🧠

Thinking

On for maths, code and planning; off for quick chat. Use /set think and /set nothink, or the think field in the API.

⚡

Graphics card use

Run ollama ps while a chat is open. If it does not say the model is on the GPU, choose a smaller size or a shorter context.

# Put these two lines in a file called Modelfile:
FROM gemma4:12b-it-qat
PARAMETER num_ctx 32768

# Then build and run your saved version:
ollama create gemma4-32k -f Modelfile
ollama run gemma4-32k

Three ways to set the context

For one chat: /set parameter num_ctx 32768. For everything: set OLLAMA_CONTEXT_LENGTH before Ollama starts. For a saved model: a Modelfile, as shown.

Sampling

Google recommends temperature 1.0, top-p 0.95 and top-k 64 for every Gemma 4 size.

Sampling values from Google's model card; around 32K is this site's suggested starting context. What each setting does is covered under capabilities.

Local API

Call Gemma 4 from your own code

Once a model is pulled, Ollama serves it at localhost:11434. No key, no internet.

# pip install ollama
import ollama

reply = ollama.chat(
    model="gemma4:12b-it-qat",
    messages=[
        {"role": "system", "content": "You are a concise assistant."},
        {"role": "user", "content": "Why is the sky blue?"},
    ],
)
print(reply["message"]["content"])

Ollama's own Python library. There is a JavaScript one too.

curl http://localhost:11434/api/chat -d '{
  "model": "gemma4:12b-it-qat",
  "messages": [
    {"role": "system", "content": "You are a concise assistant."},
    {"role": "user", "content": "Why is the sky blue?"}
  ],
  "think": false,
  "stream": false
}'
# pip install openai
from openai import OpenAI

client = OpenAI(base_url="http://localhost:11434/v1", api_key="ollama")

reply = client.chat.completions.create(
    model="gemma4:12b-it-qat",
    messages=[{"role": "user", "content": "Why is the sky blue?"}],
)
print(reply.choices[0].message.content)

Ollama also speaks the OpenAI format at /v1, so existing tools and editor extensions can use it by changing one address.

More on endpoints and hosted alternatives on the API page; connecting an editor is in Gemma 4 coding.

EmbeddingGemma 2 · released October 6, 2026
Search with Ollama

EmbeddingGemma 2 on Ollama

EmbeddingGemma 2 is Google's new open model for search. You do not chat with it: you send it content and it returns a vector, a list of 768 numbers that captures the meaning. It was in Ollama's library the day after release.

Your text"northern lights" EmbeddingGemma 2localhost:11434/api/embed [0.021-0.1140.0870.003-0.0580.142… 768 ] Similar meanings give similar lists of numbers - that is what search compares
Text in, numbers out.
TagParametersDownloadInputs Ollama listsChoose it for
embeddinggemma-2:270m270M378 MBTextText and code search; the lightest option
embeddinggemma-2:440m440M714 MBText, imageText and image search
embeddinggemma-2:570m570M990 MBTextThe build that includes the audio part
embeddinggemma-2 · :740m740M1.3 GBText, imageThe full model
Audio and video. The model itself embeds audio and video, but Ollama's library page lists only text and image as inputs. To embed recordings or clips, use Python with sentence-transformers, as shown in how to use.
ollama pull embeddinggemma-2            # full model, 1.3 GB
ollama pull embeddinggemma-2:270m       # text and code only, 378 MB
curl http://localhost:11434/api/embed -d '{
  "model": "embeddinggemma-2",
  "input": "What causes the northern lights?"
}'

# Several texts at once: pass a list
curl http://localhost:11434/api/embed -d '{
  "model": "embeddinggemma-2",
  "input": ["first passage", "second passage", "third passage"]
}'
# pip install ollama
import ollama

out = ollama.embed(
    model="embeddinggemma-2",
    input=["first passage", "second passage"],
)
print(len(out["embeddings"]), len(out["embeddings"][0]))   # 2 768

Ready-to-compare vectors

Ollama's documentation says the embed endpoint returns unit-length vectors, and recommends cosine similarity for search.

Same model both sides

Embed your documents and your queries with the same model and size. Vectors from different models cannot be compared.

Task labels

Google recommends a short task label on text, such as task: search result | query: before a query. Through a raw endpoint you add it yourself.

Shorter vectors

You can keep only the first 512 or 256 numbers to save space, then re-normalise. Google reports a sharp drop at 128 for images.

Tags, sizes and inputs from Ollama's embeddinggemma-2 page; endpoint behaviour from Ollama's embeddings documentation; task labels and quality figures from Google's model card and developer guide. Each size also has -bf16, -mxfp8 and -nvfp4 variants. Known limits are on the limitations page.

Both models

Answer questions from your own documents

With both models pulled, about thirty lines of Python give you private question-answering: EmbeddingGemma 2 finds the right passage, Gemma 4 writes the answer.

# pip install ollama
# ollama pull embeddinggemma-2   ·   ollama pull gemma4:12b-it-qat
import ollama

passages = [
    "Refunds are available within 30 days of purchase.",
    "Support is open Monday to Friday, 9am to 5pm.",
    "Orders over $50 ship free within the country.",
]
question = "Can I get my money back after three weeks?"

# 1. Turn the passages and the question into vectors
p_vecs = ollama.embed(model="embeddinggemma-2", input=passages)["embeddings"]
q_vec = ollama.embed(model="embeddinggemma-2", input=question)["embeddings"][0]

# 2. Find the closest passage (the vectors are unit length, so a dot product is enough)
scores = [sum(a * b for a, b in zip(q_vec, p)) for p in p_vecs]
best = passages[scores.index(max(scores))]

# 3. Let Gemma 4 answer from it
reply = ollama.chat(
    model="gemma4:12b-it-qat",
    messages=[
        {"role": "system", "content": "Answer only from the context. "
         "If the answer is not there, say you do not know."},
        {"role": "user", "content": f"Context: {best}\n\nQuestion: {question}"},
    ],
)
print(reply["message"]["content"])

Everything stays local

Both models run through the same Ollama server on your machine. Nothing is sent to a cloud service.

For more documents

Keep the vectors in a vector database instead of a list, and retrieve the top few passages, not just one.

Memory needed

The 12B needs about 6.7 GB for its weights and EmbeddingGemma 2 at most 1.3 GB, so both fit on a 16 GB machine.

This sample was written for this page from Ollama's documented calls and has not been run against live models here. The same idea with Google's Python library is in how to use both.

Going further

More things Ollama can do

# Run Google's official GGUF straight from Hugging Face
ollama run hf.co/google/gemma-4-12B-it-qat-q4_0-gguf:Q4_0

# No suitable hardware? Ollama's hosted version (your prompts leave your machine)
ollama run gemma4:cloud

# Use a local model behind Claude Code (unofficial; see the linked page)
ollama launch claude

# In Docker
docker run -d -v ollama:/root/.ollama -p 11434:11434 --name ollama ollama/ollama
docker exec -it ollama ollama run gemma4:12b-it-qat

The Claude Code setup and its trade-offs are explained in Gemma 4 vs Claude Code; serving a team is under self-hosting; hosted prices are on the pricing page. Phones use a different app - see mobile downloads and the Android page.

When it goes wrong

Troubleshooting

ProblemLikely causeFix
Nothing answers at localhost:11434Ollama is not runningOpen the app, or run ollama serve
Replies are very slowThe model is on the processor, not the graphics cardCheck ollama ps; use a smaller size or shorter context
It forgets earlier messagesThe context window is at its small defaultRaise num_ctx
Odd symbols or broken tool callsA model pulled before the July 2026 refreshollama pull the same tag again
"Model not found"The tag is mistypedOllama tags are lowercase: gemma4:12b, not gemma-4-12B
The model changed by itselfYou used a general tag that was repointedName the size and build explicitly
Embedding search gives odd resultsDifferent models or sizes used for documents and queriesRe-embed everything with one tag
The disk is filling upSeveral large models keptollama list, then ollama rm what you do not use

Causes and fixes are this site's guidance, not an official list. More in the install guide and the FAQ.

FAQ

Ollama questions

Which Gemma 4 tag should I use on Ollama?

gemma4:12b-it-qat on a 16 GB machine, gemma4:e4b-it-qat on 8 GB, and gemma4:26b-a4b-it-qat or gemma4:31b-it-qat with a 24 GB graphics card.

Is Ollama free?

Running models on your own machine with Ollama is free, and both models are Apache 2.0. Ollama's hosted :cloud option is a separate service with its own terms.

Does it work offline?

Yes. After a model is pulled, it runs with no connection and your prompts stay on your machine.

How do I use EmbeddingGemma 2 with Ollama?

Run ollama pull embeddinggemma-2, then send text to http://localhost:11434/api/embed. You get a vector back for each text.

Can I chat with EmbeddingGemma 2?

No. It only produces vectors. Use a Gemma 4 model for chat, and combine the two to answer questions from your own files.

How do I turn thinking on or off?

In a chat, type /set think or /set nothink. In the API, set the think field to true or false.

How do I update a model?

Run ollama pull with the same tag. Refreshed weights arrive as updates to existing tags.

Ollama or LM Studio?

Ollama if you are comfortable in a terminal or want to script things; LM Studio if you prefer an app with a chat window. Other options are in the runtime selector and the download hub; results to expect are on benchmarks, features and safety.

One command to start

ollama run gemma4:12b-it-qat

Top '