The stock pgvector PostgreSQL
extension
extension is customized for AlloyDB, and referred to as vector.
It supports storing generated embeddings in a vector column. The extension also
adds support for scalar quantization feature to create IVF indexes. You can
also create an IVFFlat index or HSNW index that are available with stock
pgvector.
For more information about storing vectors, see Store vectors.
In addition to the customized vector extension, AlloyDB
includes the alloydb_scann extension that implements a highly efficient
nearest-neighbor index powered by the ScaNN
algorithm.
You can tune your indexes for a balance between query-per-second (QPS) and recall
with your queries. For more information about tuning your indexes, see Tune
vector query performance.
Generate embeddings and text predictions
AlloyDB AI extends PostgreSQL syntax with two functions for
querying models using the google_ml_integration extension:
You can then apply these vector embeddings
as input to pgvector functions. This includes methods to compare and sort
samples of text according to their relative semantic distance.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Hard to understand","hardToUnderstand","thumb-down"],["Incorrect information or sample code","incorrectInformationOrSampleCode","thumb-down"],["Missing the information/samples I need","missingTheInformationSamplesINeed","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2025-08-25 UTC."],[[["\u003cp\u003eAlloyDB AI enhances AlloyDB for PostgreSQL and AlloyDB Omni with machine learning capabilities, allowing users to leverage ML models for data analysis and predictions.\u003c/p\u003e\n"],["\u003cp\u003eAlloyDB offers two extensions for vector operations: a customized \u003ccode\u003evector\u003c/code\u003e extension, which is an enhanced version of \u003ccode\u003epgvector\u003c/code\u003e, and \u003ccode\u003ealloydb_scann\u003c/code\u003e, a highly efficient nearest-neighbor index powered by the ScaNN algorithm.\u003c/p\u003e\n"],["\u003cp\u003eThe \u003ccode\u003egoogle_ml_integration\u003c/code\u003e extension provides SQL functions to interact with models, enabling users to generate embeddings from text and invoke model predictions within database transactions.\u003c/p\u003e\n"],["\u003cp\u003eAlloyDB can be configured to work with Vertex AI, providing access to models in the Vertex AI Model Garden and the ability to use \u003ccode\u003etextembedding-gecko\u003c/code\u003e English models for embedding generation.\u003c/p\u003e\n"],["\u003cp\u003eThe \u003ccode\u003ealloydb_scann\u003c/code\u003e extension, which was previously known as \u003ccode\u003epostgres_ann\u003c/code\u003e requires users to drop indexes made with \u003ccode\u003epostgres_ann\u003c/code\u003e, upgrade to AlloyDB Omni version 15.5.5, and recreate them with \u003ccode\u003ealloydb_scann\u003c/code\u003e before use.\u003c/p\u003e\n"]]],[],null,["# Build generative AI applications using AlloyDB AI\n\nSelect a documentation version: 15.5.5keyboard_arrow_down\n\n- [15.5.5](/alloydb/omni/15.5.5/docs/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.5.5, 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-------------------------------\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/15.5.5/docs/store-embeddings).\n|\n| **Preview\n| --- AlloyDB ScaNN index**\n|\n|\n| This feature 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 features 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\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/15.5.5/docs/store-index-query-vectors).\n\nTune your vector query performance\n----------------------------------\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/15.5.5/docs/tune-indexes).\n\nGenerate embeddings and text predictions\n----------------------------------------\n\nAlloyDB AI extends PostgreSQL syntax with two functions for\nquerying models using the `google_ml_integration` extension:\n\n- [Invoke predictions](/alloydb/omni/15.5.5/docs/invoke-predictions) to call a model using SQL within a\n transaction.\n\n- [Generate embeddings](/alloydb/omni/15.5.5/docs/work-with-embeddings) to have an LLM translate text\n prompts into numerical vectors.\n\n You can use the [`embedding()` function](/alloydb/omni/15.5.5/docs/work-with-embeddings) to query Vertex AI\n models, while the [`google_ml.embedding()` function](/alloydb/omni/15.5.5/docs/model-endpoint-overview#how-it-works) 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 using model endpoint management](/alloydb/docs/ai/register-model-endpoint) and [Register and call remote AI models in\n| AlloyDB for PostgreSQL](/alloydb/docs/ai/model-endpoint-overview). This feature is available in [Preview](https://cloud.google.com/products?e=48754805#product-launch-stages).\n\n### Use models in the cloud with Vertex AI\n\nYou can [configure AlloyDB Omni to work with\nVertex AI](/alloydb/omni/15.5.5/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 `textembedding-gecko` English models](/vertex-ai/docs/generative-ai/model-reference/text-embeddings)\n LLM.\n\nWhat's next\n-----------\n\n- [Install AlloyDB Omni with AlloyDB AI](/alloydb/omni/15.5.5/docs/install-with-alloydb-ai)\n\n- [Create indexes and query vectors](/alloydb/omni/15.5.5/docs/store-index-query-vectors)"]]