PolarDB for AI

Updated at:

PolarDB for AI is a distributed machine learning component of PolarDB for MySQL that comes with built-in AI models. You can use SQL statements to call built-in AI models to complete complex analysis tasks without the need to synchronize data from PolarDB to other AI platforms. PolarDB for AI also supports building custom models and loading external models by using SQL statements.

With PolarDB for AI, you can:

Use Qwen foundation models

You can use built-in Qwen foundation models to run inference on and interact with data in PolarDB. Choose a model based on your scenario.

Sentiment analysis model: Analyzes the sentiment of a sentence.

/*polar4ai*/SELECT * FROM PREDICT (MODEL _polar4ai_tongyi_sa, SELECT content FROM textinfo LIMIT 1) WITH ();
-- Query result from the textinfo table: This item only looks decent; the actual experience is very poor. I do not recommend purchasing it. 
Output: Negative

Chat model: Generates an answer based on a given prompt.

/*polar4ai*/SELECT * FROM PREDICT (MODEL _polar4ai_tongyi, SELECT 'Who are you') WITH ();
Output: I am a large language model created by Alibaba Cloud. My name is Qwen.

Summarization model: Generates a summary of an article.

/*polar4ai*/SELECT * FROM PREDICT (MODEL _polar4ai_tongyi_summarize, SELECT content FROM textinfo WHERE id = 3) WITH ();
-- Query result from the textinfo table: In recent years, the Chinese film market has gradually shifted towards realistic themes. In 2018, "Dying to Survive" became the summer box office champion with 3.1 billion in revenue. Subsequently, films such as "The White Storm 2: Drug Lords," "Raging Fire," and "Chinese Doctors" also achieved success. This summer, realistic films like "Lost in the Stars," "Octagonal," and "No More Bets" have been highly popular, reflecting the audience's interest in content that is close to real life.
Output: In recent years, the Chinese film market has favored realistic themes. In 2018, "Dying to Survive" topped the box office with 3.1 billion. Later, "The White Storm 2," "Raging Fire," and "Chinese Doctors" also achieved great success. This sum...

Translation model: Translates Chinese text into English.

/*polar4ai*/SELECT * FROM PREDICT (MODEL _polar4ai_tongyi_tran_2_en, SELECT content FROM textinfo ORDER BY id ASC LIMIT 1) WITH ();
-- Query result from the textinfo table: This item only looks decent; the actual experience is very poor. I do not recommend purchasing it. 
Output: This item only looks decent; the actual experience is very poor. I do not recommend purchasing it.

Generate SQL from natural language (NL2SQL)

You can call the built-in NL2SQL model by using SQL statements to convert natural language into SQL statements.

/*polar4ai*/SELECT * FROM PREDICT (MODEL _polar4ai_nl2sql, SELECT 'Find the top 2 students with the most leave requests, sort them in descending order of leave count, and display their names and leave counts.') WITH (basic_index_name='schema_index');
Output: SELECT s.student_name, COUNT(sc.id) AS leave_count FROM students s JOIN student_courses sc ON s.id = sc.student_id WHERE sc.status = 0 GROUP BY s.student_name ORDER BY leave_count DESC LIMIT 2;

Build a knowledge-based Q&A system (RAG application)

You can vectorize data in PolarDB and call the built-in RAG model by using SQL statements to retrieve relevant documents or information snippets from a knowledge base. This improves response accuracy and overcomes the limitations of large language models in customer service or Q&A scenarios.

In the DMS SQL query console, select the View Vectors and Tokens… tab and run /*polar4ai*/SELECT * FROM file_index_table; to view the vector and token index tables. Query history appears in the Execution List.

Benefits

End-to-end data intelligence: Provides full lifecycle management from model creation and evaluation to inference, eliminating the issues caused by moving data across systems.

MySQL-compatible syntax: Use familiar SQL for machine learning MLOps operations with a minimal learning curve.

Built-in algorithm library: Includes machine learning and AI algorithms for classification, regression, clustering, and more.

Data protection: All data processing and model operations are performed within the database to ensure end-to-end security.

Scope of application

Your cluster must meet the following requirements:

  • Edition is Enterprise Edition and Series is Cluster Edition.

  • Engine version is MySQL 8.0.1 or later.

  • PolarProxy version is 2.7.5 or later.

For information about how to view or upgrade the Engine version and PolarProxy version, see Minor version management.

Billing

To use PolarDB for AI, you must create an AI node. The feature itself is free of charge, but you are billed for the AI node. AI nodes are billed at the same rates as standard compute nodes.

In addition to standard compute node specifications, AI nodes support two GPU specifications that are mainly used for model creation and inference.

  • 8 cores, 30 GB + one GU30 (polar.mysql.g8.2xlarge.gpu)

  • 16 cores, 125 GB + one GU100 (polar.mysql.x8.2xlarge.gpu)

For compute node billing rules, see Compute nodes.

Get started

  1. Add an AI node and configure a database account for the AI node: Enable the PolarDB for AI feature

    If you already added an AI node when purchasing the cluster, you can directly configure a database account for the AI node.
  2. Connect to the PolarDB cluster by using a cluster endpoint: Connect to PolarDB for AI

  3. Explore the built-in models:

    1. Data-Agent

    2. Labeling unstructured data

    3. Qianwen Large Model Inference Service

    4. Search and RAG

  4. Advanced usage:

    1. Model as a service

    2. Build a custom model

For more information about model usage, see Model workflow and instructions.