Une fois les points de terminaison de modèle ajoutés et enregistrés dans la gestion des points de terminaison de modèle, vous pouvez les référencer à l'aide de l'ID de modèle pour générer des embeddings.
Utilisez la fonction SQL google_ml.embedding() pour appeler le point de terminaison du modèle enregistré avec le type de modèle d'embedding de texte afin de générer des embeddings.
Pour appeler le modèle et générer des embeddings, utilisez la requête SQL suivante :
MODEL_ID : ID du modèle que vous avez défini lors de l'enregistrement du point de terminaison du modèle
CONTENT : texte à traduire en embedding vectoriel.
Exemples
Cette section présente quelques exemples de génération d'embeddings à l'aide de points de terminaison de modèles enregistrés.
Modèles d'embedding de texte avec prise en charge intégrée
Pour générer des embeddings pour un point de terminaison de modèle textembedding-gecko@002 enregistré, exécutez l'instruction suivante :
SELECTgoogle_ml.embedding(model_id=>'textembedding-gecko@002',content=>'Cloud SQL is a managed, cloud-hosted SQL database service');
Sauf indication contraire, le contenu de cette page est régi par une licence Creative Commons Attribution 4.0, et les échantillons de code sont régis par une licence Apache 2.0. Pour en savoir plus, consultez les Règles du site Google Developers. Java est une marque déposée d'Oracle et/ou de ses sociétés affiliées.
Dernière mise à jour le 2025/09/04 (UTC).
[[["Facile à comprendre","easyToUnderstand","thumb-up"],["J'ai pu résoudre mon problème","solvedMyProblem","thumb-up"],["Autre","otherUp","thumb-up"]],[["Difficile à comprendre","hardToUnderstand","thumb-down"],["Informations ou exemple de code incorrects","incorrectInformationOrSampleCode","thumb-down"],["Il n'y a pas l'information/les exemples dont j'ai besoin","missingTheInformationSamplesINeed","thumb-down"],["Problème de traduction","translationIssue","thumb-down"],["Autre","otherDown","thumb-down"]],["Dernière mise à jour le 2025/09/04 (UTC)."],[],[],null,["# Generate vector embeddings with model endpoint management\n\n| **Preview**\n|\n|\n| This product is subject to the \"Pre-GA Offerings Terms\" in the General Service Terms section\n| of the [Service Specific Terms](/terms/service-terms#1).\n|\n| Pre-GA products are available \"as is\" and might have limited support.\n|\n| For more information, see the\n| [launch stage descriptions](/products#product-launch-stages).\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n[MySQL](/sql/docs/mysql/model-endpoint-embeddings \"View this page for the MySQL database engine\") \\| PostgreSQL \\| SQL Server\n\n\u003cbr /\u003e\n\nThis page describes how to register an AI model endpoint\nand generate vector embeddings with model endpoint management.\n\nTo use AI models in\nproduction environments, see [Build generative AI applications using\nCloud SQL](/sql/docs/postgres/ai-overview) and [Work with vector embeddings](/sql/docs/postgres/work-with-vectors).\n\n\nAfter the model endpoints are added and registered in model endpoint management, you can\nreference them using the model ID to generate embeddings.\n\nBefore you begin\n----------------\n\nMake sure that you complete the following actions:\n\n- Register your model endpoint with model endpoint management. For more information, see [Register and call remote AI models using model endpoint management](/sql/docs/postgres/model-endpoint-register-model).\n- Create or update your Cloud SQL instance so that the instance can integrate with Vertex AI. For more information, see [Enable database integration with Vertex AI](/sql/docs/postgres/integrate-cloud-sql-with-vertex-ai#enable-database-integration-with-vertex-ai).\n\nGenerate embeddings\n-------------------\n\nUse the `google_ml.embedding()` SQL function to call the registered model endpoint with\nthe text embedding model type to generate embeddings.\n\nTo call the model and generate embeddings, use the following SQL query: \n\n SELECT\n google_ml.embedding(\n model_id =\u003e '\u003cvar translate=\"no\"\u003eMODEL_ID\u003c/var\u003e',\n content =\u003e '\u003cvar translate=\"no\"\u003eCONTENT\u003c/var\u003e');\n\nReplace the following:\n\n- \u003cvar translate=\"no\"\u003eMODEL_ID\u003c/var\u003e: the model ID you defined when registering the model endpoint\n- \u003cvar translate=\"no\"\u003eCONTENT\u003c/var\u003e: the text to translate into a vector embedding\n\nExamples\n--------\n\nSome examples for generating embeddings using registered model endpoints are listed in this section.\n\n### Text embedding models with built-in support\n\nTo generate embeddings for a registered `textembedding-gecko@002` model endpoint,\nrun the following statement: \n\n SELECT\n google_ml.embedding(\n model_id =\u003e 'textembedding-gecko@002',\n content =\u003e 'Cloud SQL is a managed, cloud-hosted SQL database service');"]]