AlloyDB AI Integrates ai.classify and ai.extract in SQL

AlloyDB AI is previewing two SQL functions, ai.classify and ai.extract, to process unstructured text without leaving the database. A smart batching feature groups requests to the Gemini Enterprise Agent to accelerate inference and optimize tokens.
Smart Batching to Accelerate and Reduce Tokens
AlloyDB applies smart batching to AI functions, which automatically groups inputs when they appear in WHERE clause expressions. These micro-batches are then sent to the models via the Gemini Enterprise Agent platform. This mechanism allows for faster execution than line-by-line evaluation and reduces overall token expenditure by optimizing input overhead. Smart batching was previously known as AI Function Acceleration. By bringing data processing closer together, this approach also limits application complexity and risks associated with transferring sensitive information.
Operational Use Cases Across Multiple Sectors
The functions were developed to meet practical needs in the healthcare sector, particularly for transforming clinical notes into structured records while keeping the data within the database. In the financial services sector, they are used to extract elements such as supplier information, billing dates, and line amounts from digitized documents. In the legal field, they enable the identification of applicable legislation, liability limits, and notice periods for termination in contracts. For real estate, they facilitate the extraction of property categories, the number of rooms, and price ranges from listing descriptions. They are also capable of populating knowledge graphs with entities and relationships in PostgreSQL Property Graph.
ai.classify Categorizes Text Without Custom Prompts
The ai.classify function allows for categorizing text according to user-defined classes, without requiring prompt engineering. Categories can be provided as simple labels or enriched with descriptions to clarify context. It offers a single-label mode via output_mode = 'single' and a multi-label mode via output_mode = 'multi'. Category descriptions can be structured in 2D tables, and it is possible to provide inline examples for few-shot prompting. The execution accepts TEXT inputs, TEXT[] arrays, and REFCURSOR cursors, with the option to specify a batch_size during array calls. These functions enable classifications and structured extractions directly in standard SQL within the database.
Le brief IA que les pros lisent chaque soir
Les 7 actus IA du jour, décryptées en 5 min. Gratuit.
Inclus dès l'inscription : notre sélection des meilleurs guides & comparatifs IA.
Choisissez votre rythme
Gratuit · Pas de spam · Désabonnement en 1 clic
ai.extract Produces JSON Compliant with a Provided Schema
The ai.extract function converts free text into structured JSON that conforms to a target schema. This schema can be defined in standard JSON or as a list of fields in text. System instructions are handled internally, eliminating the need to write prompts or response parsers. Several signatures are offered to process a single row, arrays, or cursors in batching. An example of extraction demonstrates retrieving clinical fields such as the patient's name, age, symptoms, and medications from a medical note.
Availability, Integration, and Roadmap
The ai.classify and ai.extract functions are available in preview within AlloyDB AI. They can be accessed via the google_ml_integration extension starting from version 1.6.1 and are compatible with PostgreSQL 18. The capabilities of Gemini are directly embedded in the database engine, without relying on an external service. According to the roadmap, several enhancements are planned, including advanced cost management, line-level provenance tracking, and the ability to perform pushdowns of queries exceeding WHERE clauses. To access the preview functions, one simply needs to set a specific session parameter. The AlloyDB AI engine documentation and release notes are recommended starting resources. This integration aims to simplify historically complex application chains that involved exports, calls to model endpoints, prompt management and retries, and database updates, with latency effects and compliance issues related to data transfers.
Brief IA — L'actualité IA en français
L'essentiel de l'actualité de l'intelligence artificielle, décrypté et expliqué chaque jour.