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 integrates machine learning capabilities into AlloyDB for PostgreSQL and AlloyDB Omni, allowing users to apply ML models to their data.\u003c/p\u003e\n"],["\u003cp\u003eThe \u003ccode\u003evector\u003c/code\u003e extension, a customized version of \u003ccode\u003epgvector\u003c/code\u003e, is available for storing embeddings in vector columns and creating \u003ccode\u003eIVF\u003c/code\u003e, \u003ccode\u003eIVFFlat\u003c/code\u003e, or \u003ccode\u003eHSNW\u003c/code\u003e indexes.\u003c/p\u003e\n"],["\u003cp\u003eAlloyDB AI introduces the \u003ccode\u003ealloydb_scann\u003c/code\u003e extension, which implements a highly efficient nearest-neighbor index using the ScaNN algorithm for PostgreSQL 15 compatible databases.\u003c/p\u003e\n"],["\u003cp\u003eUsers can utilize the \u003ccode\u003egoogle_ml_integration\u003c/code\u003e extension to generate embeddings and invoke predictions through SQL transactions, using functions like \u003ccode\u003eembedding()\u003c/code\u003e and \u003ccode\u003egoogle_ml.embedding()\u003c/code\u003e.\u003c/p\u003e\n"],["\u003cp\u003eAlloyDB Omni can be configured to integrate with Vertex AI, enabling applications to invoke predictions from any model in the Vertex AI Model Garden and generate embeddings using the \u003ccode\u003etext-embedding-005\u003c/code\u003e English models.\u003c/p\u003e\n"]]],[],null,["# Build generative AI applications using AlloyDB AI\n\nSelect a documentation version: 15.7.0keyboard_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-------------------------------\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.7.0/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/15.7.0/docs/ai/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.7.0/docs/ai/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.7.0/docs/ai/invoke-predictions) to call a model using SQL within a\n transaction.\n\n- [Generate embeddings](/alloydb/omni/15.7.0/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/15.7.0/docs/ai/work-with-embeddings) to query Vertex AI\n models, while the [`google_ml.embedding()` function](/alloydb/omni/15.7.0/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](/alloydb/omni/15.7.0/docs/model-endpoint-overview) and [Register and call remote AI models in\n| AlloyDB Omni](/alloydb/docs/omni/model-endpoint-overview).\n\n### Use models in the cloud with Vertex AI\n\nYou can [configure AlloyDB Omni to work with\nVertex AI](/alloydb/docs/omni/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-005` 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.7.0/docs/install-with-alloydb-ai)\n\n- [Create indexes and query vectors](/alloydb/omni/15.7.0/docs/ai/store-index-query-vectors)"]]