Skip to main content

embeddings

Creates, updates, deletes, gets or lists an embeddings resource.

Overview

Nameembeddings
TypeResource
Idgemini.models.embeddings

Fields

The following fields are returned by SELECT queries:

NameDatatypeDescription
embeddingobjectOutput only. The embedding generated from the input content.
usageMetadataobjectOutput only. The usage metadata for the request.

Methods

The following methods are available for this resource:

NameAccessible byRequired ParamsOptional ParamsDescription
embed_contentselectmodelsIdcontent, taskType, title, model, embedContentConfig, outputDimensionalityGenerates a text embedding vector from the input Content using the specified Gemini Embedding model.
async_batch_embed_contentexecmodelsIdEnqueues a batch of EmbedContent requests for batch processing. We have a BatchEmbedContents handler in GenerativeService, but it was synchronized. So we name this one to be Async to avoid confusion.

Parameters

Parameters can be passed in the WHERE clause of a query. Check the Methods section to see which parameters are required or optional for each operation.

NameDatatypeDescription
modelsIdstring
contentobjectThe base structured datatype containing multi-part content of a message. A Content includes a role field designating the producer of the Content and a parts field containing multi-part data that contains the content of the message turn.
embedContentConfigobjectConfigurations for the EmbedContent request.
modelstringRequired. The model's resource name. This serves as an ID for the Model to use. This name should match a model name returned by the ListModels method. Format: models/{model}
outputDimensionalityintegerOptional. Deprecated: Please use EmbedContentConfig.output_dimensionality instead. Optional reduced dimension for the output embedding. If set, excessive values in the output embedding are truncated from the end. Supported by newer models since 2024 only. You cannot set this value if using the earlier model (models/embedding-001).
taskTypestringOptional. Deprecated: Please use EmbedContentConfig.task_type instead. Optional task type for which the embeddings will be used. Not supported on earlier models (models/embedding-001).
titlestringOptional. Deprecated: Please use EmbedContentConfig.title instead. An optional title for the text. Only applicable when TaskType is RETRIEVAL_DOCUMENT. Note: Specifying a title for RETRIEVAL_DOCUMENT provides better quality embeddings for retrieval.

SELECT examples

Generates a text embedding vector from the input Content using the specified Gemini Embedding model.

SELECT
embedding,
usageMetadata
FROM gemini.models.embeddings
WHERE modelsId = '{{ modelsId }}' -- required
AND content = '{{ content }}'
AND taskType = '{{ taskType }}'
AND title = '{{ title }}'
AND model = '{{ model }}'
AND embedContentConfig = '{{ embedContentConfig }}'
AND outputDimensionality = '{{ outputDimensionality }}'
;

Lifecycle Methods

Enqueues a batch of EmbedContent requests for batch processing. We have a BatchEmbedContents handler in GenerativeService, but it was synchronized. So we name this one to be Async to avoid confusion.

EXEC gemini.models.embeddings.async_batch_embed_content
@modelsId='{{ modelsId }}' --required
@@json=
'{
"batch": "{{ batch }}"
}'
;