Die Standarderweiterung pgvector PostgreSQL wurde für AlloyDB angepasst und wird als vector bezeichnet.
Es unterstützt das Speichern generierter Einbettungen in einer Vektorspalte. Die Erweiterung bietet auch Unterstützung für die skalare Quantisierungsfunktion zum Erstellen von IVF-Indizes. Sie können auch einen IVFFlat-Index oder HSNW-Index erstellen, die mit dem Standard-pgvector verfügbar sind.
Weitere Informationen zum Speichern von Vektoren finden Sie unter Vektoren speichern.
Zusätzlich zur benutzerdefinierten Erweiterung vector enthält AlloyDB die Erweiterung alloydb_scann, die einen hocheffizienten Index für die Suche nach dem nächsten Nachbarn implementiert, der auf dem ScaNN-Algorithmus basiert.
Sie können Ihre Indexe so abstimmen, dass ein Gleichgewicht zwischen Abfragen pro Sekunde und Recall erreicht wird. Weitere Informationen zum Optimieren von Indexen finden Sie unter Leistung von Vektorabfragen optimieren.
Einbettungen und Textvorhersagen generieren
AlloyDB AI erweitert die PostgreSQL-Syntax um zwei Funktionen zum Abfragen von Modellen mit der Erweiterung google_ml_integration:
Vorhersagen aufrufen, um ein Modell mithilfe von SQL innerhalb einer Transaktion aufzurufen.
Mit der embedding()-Funktion können Sie Vertex AI-Modelle abfragen, während die google_ml.embedding()-Funktion zum Abfragen registrierter Vertex AI-, gehosteter und Drittanbietermodelle verwendet werden kann.
Anschließend können Sie diese Vektoreinbettungen als Eingabe für pgvector-Funktionen verwenden. Dazu gehören Methoden zum Vergleichen und Sortieren von Textbeispielen anhand ihrer relativen semantischen Entfernung.
[[["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-08-17 (UTC)."],[[["\u003cp\u003eAlloyDB AI provides machine learning capabilities to your data through its integration with AlloyDB for PostgreSQL and AlloyDB Omni.\u003c/p\u003e\n"],["\u003cp\u003eThe \u003ccode\u003evector\u003c/code\u003e extension, a customized version of \u003ccode\u003epgvector\u003c/code\u003e, allows storing embeddings in a vector column and supports scalar quantization for creating \u003ccode\u003eIVF\u003c/code\u003e indexes.\u003c/p\u003e\n"],["\u003cp\u003eAlloyDB's \u003ccode\u003ealloydb_scann\u003c/code\u003e extension, compatible with PostgreSQL 15, offers a highly efficient nearest-neighbor index utilizing the ScaNN algorithm.\u003c/p\u003e\n"],["\u003cp\u003eThe \u003ccode\u003egoogle_ml_integration\u003c/code\u003e extension offers \u003ccode\u003eInvoke predictions\u003c/code\u003e and \u003ccode\u003eGenerate embeddings\u003c/code\u003e functions to enable model querying and text translation into vectors.\u003c/p\u003e\n"],["\u003cp\u003eAlloyDB Omni can be configured to work with Vertex AI, enabling applications to leverage models from the Vertex AI Model Garden and use the \u003ccode\u003etext-embedding-005\u003c/code\u003e English models for generating embeddings.\u003c/p\u003e\n"]]],[],null,["Select a documentation version: Current (16.8.0)keyboard_arrow_down\n\n- [Current (16.8.0)](/alloydb/omni/current/docs/ai/overview-ai)\n- [16.8.0](/alloydb/omni/16.8.0/docs/ai/overview-ai)\n- [16.3.0](/alloydb/omni/16.3.0/docs/ai/overview-ai)\n- [15.12.0](/alloydb/omni/15.12.0/docs/ai/overview-ai)\n- [15.7.1](/alloydb/omni/15.7.1/docs/ai/overview-ai)\n- [15.7.0](/alloydb/omni/15.7.0/docs/ai/overview-ai)\n\n\u003cbr /\u003e\n\nAlloyDB AI is a suite of features included with AlloyDB for PostgreSQL and AlloyDB Omni that let you apply the semantic and predictive power of machine learning (ML) models to your data. This page provides an overview of the ML-powered AI functions that are available through AlloyDB.\n\n\u003cbr /\u003e\n\n| **Caution:** The `postgres_ann` extension is renamed to `alloydb_scann`. Before you upgrade to AlloyDB Omni version 15.7.0, you must drop any indexes created using the older `postgres_ann` version. Next, upgrade AlloyDB Omni, and then create the indexes again using the `alloydb_scann` extension. This applies only to AlloyDB Omni.\n\nStore, index, and query vectors\n\nThe stock [`pgvector` PostgreSQL\nextension](https://github.com/pgvector/pgvector?tab=readme-ov-file#indexing)\nextension is customized for AlloyDB, and referred to as `vector`.\nIt supports storing generated embeddings in a vector column. The extension also\nadds support for scalar quantization feature to create `IVF` indexes. You can\nalso create an `IVFFlat` index or `HSNW` index that are available with stock\n`pgvector`.\n\nFor more information about storing vectors, see [Store vectors](/alloydb/omni/current/docs/ai/store-embeddings).\n\nIn addition to the customized `vector` extension, AlloyDB\nincludes the `alloydb_scann` extension that implements a highly efficient\nnearest-neighbor index powered by the [ScaNN\nalgorithm](https://github.com/google-research/google-research/blob/master/scann/docs/algorithms.md).\n| **Note:** The `alloydb_scann` extension can be used with PostgreSQL 15 compatible databases.\n\nFor more information about creating indexes and querying vectors, see [Create\nindexes and query vectors](/alloydb/omni/current/docs/ai/store-index-query-vectors).\n\nTune your vector query performance\n\nYou can tune your indexes for a balance between query-per-second (QPS) and recall\nwith your queries. For more information about tuning your indexes, see [Tune\nvector query performance](/alloydb/omni/current/docs/ai/tune-indexes).\n\nGenerate embeddings and text predictions\n\nAlloyDB AI extends PostgreSQL syntax with two functions for\nquerying models using the `google_ml_integration` extension:\n\n- [Invoke predictions](/alloydb/omni/current/docs/ai/invoke-predictions) to call a model using SQL within a\n transaction.\n\n- [Generate embeddings](/alloydb/omni/current/docs/ai/work-with-embeddings) to have an LLM translate text\n prompts into numerical vectors.\n\n You can use the [`embedding()` function](/alloydb/omni/current/docs/ai/work-with-embeddings) to query Vertex AI\n models, while the [`google_ml.embedding()` function](/alloydb/omni/current/docs/ai/model-endpoint-overview) can be used to query registered\n Vertex AI, hosted, and third-party models.\n\n You can then apply these vector embeddings\n as input to `pgvector` functions. This includes methods to compare and sort\n samples of text according to their relative semantic distance.\n\n| **Note:** To generate embeddings for custom hosted or third-party AI models, see [Register and call remote AI models in\n| AlloyDB Omni](/alloydb/omni/current/docs/ai/model-endpoint-overview). This feature is available in [Preview](https://cloud.google.com/products?e=48754805#product-launch-stages).\n\nUse models in the cloud with Vertex AI\n\nYou can [configure AlloyDB Omni to work with\nVertex AI](/alloydb/omni/current/docs/install-with-alloydb-ai).\n\nThis gives your applications the following benefits:\n\n- Your applications can invoke predictions using any model stored in the [Vertex AI Model Garden](/model-garden) that they have\n access to.\n\n- Your applications can generate embeddings using [the\n `text-embedding` English models](/vertex-ai/docs/generative-ai/model-reference/text-embeddings)\n LLM.\n\nWhat's next\n\n- [Install AlloyDB Omni with AlloyDB AI](/alloydb/omni/current/docs/install-with-alloydb-ai).\n\n- [Create indexes and query vectors](/alloydb/omni/current/docs/ai/store-index-query-vectors)."]]