Mit der SQL-Funktion google_ml.embedding() können Sie den registrierten Modellendpunkt mit dem Texteinbettungsmodelltyp aufrufen, um Einbettungen zu generieren.
Verwenden Sie die folgende SQL-Abfrage, um das Modell aufzurufen und Einbettungen zu generieren:
Führen Sie die folgende Anweisung aus, um Einbettungen für registrierte text-embedding-3-small- oder text-embedding-3-large-Modellendpunkte von OpenAI zu generieren:
SELECTgoogle_ml.embedding(model_id=>'text-embedding-3-small',content=>'Vector embeddings in AI');
[[["Leicht verständlich","easyToUnderstand","thumb-up"],["Mein Problem wurde gelöst","solvedMyProblem","thumb-up"],["Sonstiges","otherUp","thumb-up"]],[["Schwer verständlich","hardToUnderstand","thumb-down"],["Informationen oder Beispielcode falsch","incorrectInformationOrSampleCode","thumb-down"],["Benötigte Informationen/Beispiele nicht gefunden","missingTheInformationSamplesINeed","thumb-down"],["Problem mit der Übersetzung","translationIssue","thumb-down"],["Sonstiges","otherDown","thumb-down"]],["Zuletzt aktualisiert: 2025-09-03 (UTC)."],[[["\u003cp\u003eThis page provides instructions on how to generate embeddings by utilizing registered model endpoints.\u003c/p\u003e\n"],["\u003cp\u003eThe \u003ccode\u003egoogle_ml.embedding()\u003c/code\u003e SQL function is used to interact with the registered model endpoint, specifically for text embedding models.\u003c/p\u003e\n"],["\u003cp\u003eTo call the model, you must define the \u003ccode\u003eMODEL_ID\u003c/code\u003e and the \u003ccode\u003eCONTENT\u003c/code\u003e you wish to process in a SQL query.\u003c/p\u003e\n"],["\u003cp\u003eThe page provides examples of generating embeddings for \u003ccode\u003etext-embedding-005\u003c/code\u003e, \u003ccode\u003etext-embedding-ada-002\u003c/code\u003e, \u003ccode\u003etext-embedding-3-small\u003c/code\u003e, and \u003ccode\u003etext-embedding-3-large\u003c/code\u003e model endpoints.\u003c/p\u003e\n"]]],[],null,["# Generate vector embeddings with model endpoint management\n\nSelect a documentation version: 15.7.0keyboard_arrow_down\n\n- [Current (16.8.0)](/alloydb/omni/current/docs/ai/model-endpoint-embeddings)\n- [16.8.0](/alloydb/omni/16.8.0/docs/ai/model-endpoint-embeddings)\n- [16.3.0](/alloydb/omni/16.3.0/docs/ai/model-endpoint-embeddings)\n- [15.12.0](/alloydb/omni/15.12.0/docs/ai/model-endpoint-embeddings)\n- [15.7.1](/alloydb/omni/15.7.1/docs/ai/model-endpoint-embeddings)\n- [15.7.0](/alloydb/omni/15.7.0/docs/ai/model-endpoint-embeddings)\n\n\u003cbr /\u003e\n\nThis page describes how to generate embeddings using registered model endpoints.\n\n\u003cbr /\u003e\n\nBefore you begin\n----------------\n\nMake sure that you have registered your model endpoint with Model endpoint management. For\nmore information, see [Register a model endpoint with\nmodel endpoint management](/alloydb/docs/ai/register-model-endpoint)\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 endpoint are listed in this section.\n\n#### Text embedding models with built-in support\n\nTo generate embeddings for a registered `text-embedding-005` model endpoint, run the following statement: \n\n SELECT\n google_ml.embedding(\n model_id =\u003e 'text-embedding-005',\n content =\u003e 'AlloyDB is a managed, cloud-hosted SQL database service');\n\nTo generate embeddings for a registered `text-embedding-ada-002` model endpoint by OpenAI, run the following statement: \n\n SELECT\n google_ml.embedding(\n model_id =\u003e 'text-embedding-ada-002',\n content =\u003e 'e-mail spam');\n\nTo generate embeddings for a registered `text-embedding-3-small` or `text-embedding-3-large` model endpoints by OpenAI, run the following statement: \n\n SELECT\n google_ml.embedding(\n model_id =\u003e 'text-embedding-3-small',\n content =\u003e 'Vector embeddings in AI');"]]