AI functions overview

Run powerful AI models registered through model endpoint management directly within your database using SQL operators. The AlloyDB AI functions integrate with Vertex AI to bring intelligent filtering, semantic ranking, and text generation to your operational data in real time.

AI-powered filtering thumbnail

Use simple SQL functions for powerful AI tasks. The google_ml_integration extension provides operators like ai.if() for intelligent filtering and ai.rank() for semantic reranking.

In-database text generation thumbnail

Perform transformations for rows in your database. Using the ai.generate() operator, you can ask a foundation model to summarize a product review, or to transform data directly in your query.

Embedding and prediction functions thumbnail

Use SQL functions like google_ml.embedding() to generate vector embeddings or google_ml.predict_row( to invoke predictions from any registered model, all within your database.

How the AI functions works

When you embed an AI operator like ai.if() , ai.rank() , or ai.generate() into your SQL query, the AI functionsdetect it. This engine, available using the google_ml_integration extension, orchestrates the entire process. It securely packages the relevant row data and calls a pre-registered ML model from providers, such as Gemini, OpenAI, or Anthropic. The ML model evaluates the data and returns a prediction—like true/false for a filter or a score for ranking. The AI functions seamlessly integrates this prediction back into your query's execution, returning a standard SQL result set. You get AI-powered insights without ever moving your data.

Visual overview of AI functions

Benefits of AlloyDB AI functions

Traditional database query mechanisms are often rigid, forcing developers to hardcode all potential user interaction paths. AlloyDB AI functions enable a significant change in the user experience by doing the following:

  • Infuse enterprise data with world knowledge: you can bring the real-world knowledge of Large Language Models (LLMs) directly to your AlloyDB for PostgreSQL database. The following are examples of how you can use AI functions:

    • Process unstructured data using ai.generate : you can manage raw, noisy, or unstructured user feedback—like reviews or logs—using Gemini with SQL.
    • Determine if transactions are fraudulent using ai.if : give the function a sequence of user actions, transaction notes, or chat summaries and ask it to evaluate a binary outcome: Is this fraudulent?
  • High-performance intelligence: use the following to accelerate performance and handle intelligence at scale with AI functions:

    • Use array-based processing to handle up to thousands of rows per second, which is 2,000x faster than row-at-a-time calls. Array-based processing is available for all AI functions. For more information, see Perform intelligent SQL queries using AI functions .
    • Use AI function acceleration to achieve significantly higher throughput than row-at-a-time calls. This is available for ai.if and ai.rank . For more information, see Perform intelligent SQL queries using AI functions .
    • Use optimized ai.if to eliminate the costs of using the LLM through improved efficiency, achieving 100,000 rows per second (a 23,000x improvement over row-at-a-time calls) and reducing costs by 6,000x to 1/10th of one cent.

AlloyDB AI functions use cases

The following table describes use cases for AlloyDB AI functions.


Function

Description

Use case
ai.if

Intelligent, cognitive filtering based on natural language.

Determine which customer transactions appear fraudulent based on behavior patterns.
ai.rank

Reranks vector search results based on deep contextual nuance.

Prioritize breathable fabrics for a tropical wedding search even if your database doesn't know what "breathable fabrics" means.
ai.generate

Generates new content or transforms data formats.

Convert raw server log data into a structured JSON format for easier analysis.
ai.analyze_sentiment

Classifies the emotional tone of text as positive, negative, or neutral.

Classify thousands of product reviews to gauge overall customer satisfaction.
ai.summarize

Condenses lengthy text into essential information.

Extract key decisions and action items from conversational transcripts.
ai.forecast

Enables time-series forecasting using the TimesFM model .

Predict future inventory needs based on historical sales data.

Learn more

Explore developer resources to build your own natural language query applications with AlloyDB AI.

Video

Empower small IT teams to harness generative AI with Google Cloud databases.

Codelab

Deploy AlloyDB AI with AI operators. Use them for tasks such as semantic search, joins, and result ranking.

Blog

Build richer generative AI experiences using model endpoint management.

Create a Mobile Website
View Site in Mobile | Classic
Share by: