Model guide
EmbeddingGemma 300M
EmbeddingGemma 300M is a compact multilingual model for document search, similarity and classification features. It creates vectors rather than chat answers, so choose it as the retrieval part of a workflow. Keep chunks within its input limit and preserve the documented query and document formatting.
At a glance
- Parameters
- 0.31B
- Accepts
- Text
- Returns
- Vectors
- Published context limit
- 2,048 tokens
- Model format
- safetensors · GGUF
- Software and download hosts
- Ollama · sentence-transformers · TEI. Follow the exact setup below; this list does not establish support for every format, input type or software version.
- Model-weight download
- 1.21 GB of F32 weights · native workflow
- Languages
- 100+ languages
- License
- Gemma
Record memory while indexing a batch of your usual passage length. Time one query separately.
Best for
- Build a searchable index of short text passages on-device. Keep each input within the 2,048-token limit and inspect the first retrieved passage.
Choose something else when
- For images, use a multimodal embedding model. EmbeddingGemma accepts text.
Using this model for document search
Select this model for the document-search step in an app that supports it. Keep the model that generates answers separate. Check document chunk length and any required query or document prefixes in the model’s instructions.
Changing the embedding model changes the document vectors. Rebuild the document index rather than mixing vectors from different models.
First setup
EmbeddingGemma is a 308-million-parameter text embedding model, not a chat model. For an app-based start, download it with ollama pull embeddinggemma, keep Ollama running, then enter this in PowerShell:
$body = @{model='embeddinggemma'; input=@('The meeting starts at 10:30.')} | ConvertTo-Json
$result = Invoke-RestMethod -Uri http://localhost:11434/api/embed -Method Post -ContentType 'application/json' -Body $body
$result.embeddings[0].Count
Expect a numeric vector (768 values with the standard package), not prose. The model's 2,048-token limit applies to each chunk. For query/document retrieval with automatic prompts, accept Google's model license on Hugging Face, sign in using hf auth login if access is requested, and install sentence-transformers:
from sentence_transformers import SentenceTransformer
model = SentenceTransformer("google/embeddinggemma-300m", device="cpu")
query = model.encode_query(["When does the meeting start?"])
documents = model.encode_document(["The meeting starts at 10:30.", "Lunch is at noon."])
print(model.similarity(query, documents))
The CPU example uses float32; use float32 or bfloat16, not float16. Google's sub-200 MB quantized deployment example is not the memory requirement of this Python program. The model can be used on CPU; a document collection and its index require additional memory and storage. If access is denied, resolve the license/account permission rather than retrying a different model name.
Save the Python example as example.py, then run python example.py in the environment where you installed its packages. The first run downloads model files; later local execution still needs the cached files. Start with these short inputs and batch size 1. If loading runs out of memory, close other model processes or use a smaller model; do not interpret missing output as an empty search result. See the publisher model card for the full workflow.
This creates a 2,048-token copy of embeddinggemma named embeddinggemma-300m-short-context. Save the following as a file named Modelfile in your working folder:
FROM embeddinggemma
PARAMETER num_ctx 2048
Then run these commands from that folder:
ollama pull embeddinggemma
ollama create embeddinggemma-300m-short-context -f ./Modelfile
ollama run embeddinggemma-300m-short-context
Run the example in Model-specific setup. While the model is loaded, run ollama ps in another terminal and check CONTEXT and PROCESSOR.
The recorded Ollama package is BF16: 0.62 GB of model weights. Use Ollama 0.40.18 or a supporting newer release. A Hugging Face GGUF or MLX checkpoint is a separate representation; choose the matching source and runner in the memory calculator.
See Ollama context settings and the Modelfile instructions.
Time a fixed set of passages at batch size 1, then measure the batch size you plan to use. Indexing time and query time are separate; reranking adds a second model call.
