Ekstensi pgvector PostgreSQL
extension
standar disesuaikan untuk AlloyDB, dan disebut sebagai vector.
Fitur ini mendukung penyimpanan embedding yang dihasilkan dalam kolom vektor. Ekstensi ini juga menambahkan dukungan untuk fitur kuantisasi skalar guna membuat indeks IVF. Anda juga dapat membuat indeks IVFFlat atau indeks HSNW yang tersedia dengan pgvector saham.
Untuk mengetahui informasi selengkapnya tentang menyimpan vektor, lihat Menyimpan vektor.
Selain ekstensi vector yang disesuaikan, AlloyDB
mencakup ekstensi alloydb_scann yang menerapkan indeks tetangga terdekat yang sangat efisien yang didukung oleh algoritma ScaNN.
Anda dapat menyesuaikan indeks untuk menyeimbangkan kueri per detik (QPS) dan perolehan
dengan kueri Anda. Untuk mengetahui informasi selengkapnya tentang cara menyesuaikan indeks, lihat Menyesuaikan performa kueri vektor.
Membuat embedding dan prediksi teks
AlloyDB AI memperluas sintaksis PostgreSQL dengan dua fungsi untuk
mengueri model menggunakan ekstensi google_ml_integration:
Panggil prediksi untuk memanggil model menggunakan SQL dalam
transaksi.
Buat embedding agar LLM menerjemahkan perintah teks menjadi vektor numerik.
Anda dapat menggunakan fungsi embedding() untuk membuat kueri model Vertex AI, sedangkan fungsi google_ml.embedding() dapat digunakan untuk membuat kueri model terdaftar Vertex AI, yang dihosting, dan pihak ketiga.
Anda kemudian dapat menerapkan embedding vektor ini
sebagai input ke fungsi pgvector. Hal ini mencakup metode untuk membandingkan dan mengurutkan sampel teks berdasarkan jarak semantik relatifnya.
[[["Mudah dipahami","easyToUnderstand","thumb-up"],["Memecahkan masalah saya","solvedMyProblem","thumb-up"],["Lainnya","otherUp","thumb-up"]],[["Sulit dipahami","hardToUnderstand","thumb-down"],["Informasi atau kode contoh salah","incorrectInformationOrSampleCode","thumb-down"],["Informasi/contoh yang saya butuhkan tidak ada","missingTheInformationSamplesINeed","thumb-down"],["Masalah terjemahan","translationIssue","thumb-down"],["Lainnya","otherDown","thumb-down"]],["Terakhir diperbarui pada 2025-09-04 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)."]]