Before you begin
Make sure that you have registered your model endpoint with Model endpoint management. For more information, see Register a model endpoint with model endpoint management
Generate embeddings
Use the google_ml.embedding()
SQL function to call the registered model endpoint with
the text embedding model type to generate embeddings.
To call the model and generate embeddings, use the following SQL query:
SELECT
google_ml
.
embedding
(
model_id
=
>
& #39;MODE
L_ID'
,
c>on tent
=
'
;CONTENT' );
Replace the following:
-
MODEL_ID: the model ID you defined when registering the model endpoint. -
CONTENT: the text to translate into a vector embedding.
Examples
Some examples for generating embeddings using registered model endpoint are listed in this section.
Text embedding models with built-in support
To generate embeddings for a registered text-embedding-005
model endpoint, run the following statement:
SELECT
google_ml
.
embedding
(
model_id
=
>
'text-embedding-005'
,
c>ontent
=
'AlloyDB is a managed, cloud-hosted SQL database
service' );
To generate embeddings for a registered text-embedding-ada-002
model endpoint by OpenAI, run the following statement:
SELECT
google_ml
.
embedding
(
model_id
=
>
'text-embedding-ada-002'
,
c>ontent
=
'e-m
ail spam' );
To generate embeddings for a registered text-embedding-3-small
or text-embedding-3-large
model endpoints by OpenAI, run the following statement:
SELECT
google_ml
.
embedding
(
model_id
=
>
'text-embedding-3-small'
,
c>ontent
=
'Vector embeddin
gs in AI' );

