EmbeddingGemma 2
EmbeddingGemma 2 is an open-weight embedding model. It turns text into a 768-dimension vector with length 1, so the dot product of two vectors is their cosine similarity. Use it for semantic search, retrieval for RAG, clustering, classification, and deduplication.
It is served on POST /v2/embeddings, which follows the OpenAI embeddings API, so the OpenAI SDKs
work with only the base URL changed.
EmbeddingGemma 2 is available on Provisioned Throughput: capacity is set up for your workload and enabled for your organisation. Without access, requests return 404 not_found_error and the model isn’t listed in GET /v2/models. Contact us to request access. See Provisioned Throughput.
At a glance
Quickstart
Embed a query and a document, then compare them:
Response (vectors shortened to their first values):
data[i].index matches the position of the string in input.
Task prefixes
EmbeddingGemma 2 is trained with a prefix that says what each text is for. The API does not add it, so put it at the start of every string. Without one, retrieval quality drops.
For search, embed queries with the query prefix and documents with the document prefix.
Smaller vectors
dimensions is not supported and returns 400. To store 512, 256, or 128 values per vector,
keep the first N values of the 768-dimension vector and scale it back to length 1:
Parameters
Known limitations
- Text only. Image embeddings are not available on the API.
- The task prefix is not added for you (see Task prefixes).
- Any string over 8,192 tokens fails the whole request. Split long documents into chunks before embedding them.
- The 8,192-token limit is checked against an estimate made before the text is tokenised, and the estimate runs high, at about 1.25 tokens per English word. A 7,000-word string (about 7,000 real tokens) is refused with “Estimated tokens (8750) exceed the context window of 8192”. Keep each string under about 6,500 words.