Embeddings are the retrieval half of a private RAG loop. Text goes in, a list of numbers comes out, and the numbers stay on your disk. On a Mac with Ollama installed the whole path runs on localhost. Google's EmbeddingGemma is the model to pull for it.
EmbeddingGemma installs with ollama pull embeddinggemma
Check the version first. The model card on the EmbeddingGemma library page says the model requires Ollama v0.11.10 or later. Then pull it and confirm:
ollama --version
ollama pull embeddinggemma
ollama list
The library page lists two tags, embeddinggemma:latest and embeddinggemma:300m. Both show 622MB, a 2K context window and text input. The readme describes a 300M parameter model built from Gemma 3 with T5Gemma initialization, trained on roughly 320 billion tokens in more than 100 spoken languages.
Keep Ollama running while you work, either the menu bar app or ollama serve. If nothing answers on port 11434, every command below fails on connect.
POST /api/embed returns the vector array
One request, one vector:
curl -X POST http://localhost:11434/api/embed \
-H "Content-Type: application/json" \
-d '{
"model": "embeddinggemma",
"input": "The quick brown fox jumps over the lazy dog."
}'
The 200 body carries model, embeddings as number[][], total_duration and load_duration in nanoseconds, and prompt_eval_count for input tokens. No key in the header. The endpoint reference has the full field list.
There is a CLI path as well. ollama run embeddinggemma "Hello world" prints a JSON array, and echo "Hello world" | ollama run embeddinggemma does the same. Python users get ollama.embed(model='embeddinggemma', input='...') and read the vector length with len(r['embeddings'][0]).
Batch input, plus truncate and dimensions
input also takes an array of strings, so a folder of notes becomes a single call:
curl http://localhost:11434/api/embed -d '{
"model": "embeddinggemma",
"input": ["First sentence", "Second sentence", "Third sentence"]
}'
Body fields beyond model and input are documented as truncate, dimensions (integer), keep_alive and options. Truncate defaults to true, so input past the context window gets cut instead of throwing; set it to false and the request errors instead. Print len(...) on your first response to see the vector size rather than assuming one.
Cosine similarity, and one model on both sides
The embeddings guide is blunt about retrieval. Vectors come back L2-normalized, unit length. Use cosine similarity for most semantic search work. Index with one model, query with the same model, because vectors from different models do not compare. The guide puts typical vector length at 384 to 1024 dimensions, depending on the model.
Earlier Ollama work on this site already covered the same endpoint shape: search your notes by meaning with Ollama embeddings. EmbeddingGemma is a swap of the model field and nothing else.
The generation side is the same server. Xcode chat running on a local Ollama model covers the chat half on port 11434, and a retrieval agent usually needs structured outputs for the JSON answer plus tool calling to reach files. Embeddings slot in front of both.
OpenAI clients can use /v1/embeddings
If the code already imports the OpenAI SDK, point it at the local server instead of rewriting it. The compatibility page lists /v1/embeddings with supported fields model, input (string, array of strings, or token arrays), encoding format, dimensions and user. The SDK insists on an API key value; Ollama ignores it on a local server.
from openai import OpenAI
client = OpenAI(base_url='http://localhost:11434/v1/', api_key='ollama') # required but ignored
Both routes hit the same process on 127.0.0.1. The model files, the vectors and whatever index you build from them stay on the Mac.
Photo: Apple. Source: Ollama documentation.