本頁面說明 AlloyDB AI 自然語言,可讓您使用自然語言查詢資料庫,建立面向使用者的生成式 AI 應用程式。
AlloyDB AI 自然語言可根據應用程式使用者的自然語言問題,生成具備情境意識的 SQL 查詢,並提供安全 API 來執行這些查詢。自然語言可將自然語言轉換為 SQL 的複雜度從應用程式層轉移至資料庫層,進而簡化生成式 AI 應用程式的開發作業。自然語言轉 SQL (NL2SQL) 編排作業會嵌入資料庫中。您可以查詢結構化和非結構化資料。
AlloyDB AI 自然語言也提供直覺式介面,可供 SQL 開發人員將自然語言翻譯為 SQL,如下列範例所示:
SELECTalloydb_ai_nl.get_sql(...,'What is the sum that client number 4''s account has following transaction 851?');
[[["容易理解","easyToUnderstand","thumb-up"],["確實解決了我的問題","solvedMyProblem","thumb-up"],["其他","otherUp","thumb-up"]],[["難以理解","hardToUnderstand","thumb-down"],["資訊或程式碼範例有誤","incorrectInformationOrSampleCode","thumb-down"],["缺少我需要的資訊/範例","missingTheInformationSamplesINeed","thumb-down"],["翻譯問題","translationIssue","thumb-down"],["其他","otherDown","thumb-down"]],["上次更新時間:2025-09-04 (世界標準時間)。"],[],[],null,["# AlloyDB AI natural language overview\n\n| **Preview**\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|\n|\n| For information about access to this\n| release, see the\n| [access request page](https://docs.google.com/forms/d/16wliam2vok6sdBjYwJIgWV4hw7MW9x5iQ29UwPAKqB0/viewform).\n\nThis page describes AlloyDB AI natural language, which lets you\ncreate user-facing generative AI applications using natural language to query\ndatabases.\n\nAlloyDB AI natural language generate context-aware SQL queries\nfor application end users' natural language questions, and it provides a\nsecurity API to execute these queries. Natural\nlanguage streamlines the development of generative AI applications by\ntransferring the complexity of converting natural language to SQL from the\napplication layer to the database layer. Natural language-to-SQL (NL2SQL)\norchestration is embedded in the database. You can query structured and\nunstructured data.\n\nAlloyDB AI natural language also provides an intuitive interface\nto SQL developers that translates natural language to SQL, as shown in the\nfollowing example: \n\n SELECT\n alloydb_ai_nl.get_sql(\n ...,\n 'What is the sum that client number 4''s account has following transaction 851?'\n );\n\nAlloyDB AI natural language support is provided through\n`alloydb_ai_nl,` which is an AlloyDB for PostgreSQL extension. The extension has a\ndependency on PostgreSQL extensions like `google_ml_integration`, `vector,` and\n`pg_trgm`.\n| **Note:** The `alloydb_ai_nl` extension issues prediction requests to Vertex AI models. For more information, see [Integrate with Vertex AI](/alloydb/docs/ai/configure-vertex-ai).\n\n### Use cases\n\nAlloyDB AI natural language is well-suited for developers who\nwant to do the following:\n\n- Rapidly build a customer chat interface by using query generation from natural language.\n- Refine automatically generated queries and perform thorough testing to provide accurate responses.\n- Tune generated results by adding templates and context information.\n- Deploy an intuitive, accurate chat experience that lets customers ask natural language questions about their relational data.\n\nKey capabilities\n----------------\n\nLimitations\n-----------\n\nYou must enable the AlloyDB AI natural language flag\non every instance of AlloyDB for PostgreSQL.\nAlloyDB AI natural\nlanguage objects created on the primary instance are propagated to read-only\nreplicas and cross-region replicas. However, the\n`alloydb_ai_nl.enabled` flag setting isn't replicated automatically, so you must replicate\nit manually on each instance. For more information, see [Generate SQL queries that answer natural language questions](/alloydb/docs/ai/generate-sql-queries-natural-language#before-you-begin).\n\nWhat's next\n-----------\n\n- [Generate SQL queries that answer natural language questions](/alloydb/docs/ai/generate-sql-queries-natural-language).\n- [Use AlloyDB AI natural language to generate SQL](/alloydb/docs/ai/use-natural-language-generate-sql-queries).\n- Learn how to [search your relational data stored in AlloyDB in Google Agentspace using AlloyDB AI natural language](/agentspace/agentspace-enterprise/docs/create-data-store#alloydb-ai-nl-setup) ([Preview](https://cloud.google.com/products#product-launch-stages))."]]