Configure model training, inference, or evaluation nodes
DMS supports model training, model evaluation, and model inference nodes within its task orchestration feature. Use these nodes to train a machine learning model to identify data patterns, and then use the trained model for predictions or classifications on new data.
Usage notes
This feature is currently available by invitation only.
Key concepts
-
Model training
Model training is the first and most critical step in machine learning. During this phase, the system trains a model with specified data to identify patterns and make predictions or classifications on new data. After training, the system automatically registers the model to a model group.
NoteIn real-world business scenarios, you typically schedule training once a week to maintain model performance. If you require higher model performance, you can train the model daily.
-
Model evaluation
You can evaluate a model by using specific metrics. After evaluation completes, DMS automatically registers the evaluation results to the model group, helping you decide whether to run model inference.
-
Model inference
During inference, you can use a trained and deployed model to make predictions or classifications on new data.
NoteIn real-world business scenarios, the trigger frequency varies by use case. For example, some applications run daily, while higher-frequency applications may run hourly or be triggered by specific events.
Prerequisites
You have purchased an AnalyticDB for MySQL or PolarDB for MySQL instance and created AI resources. For more information, see Create an AnalyticDB for MySQL Enterprise Edition or Basic Edition (Lakehouse Edition) cluster, Purchase a PolarDB Enterprise Edition cluster, and Enable PolarDB for AI.
Workflow
Procedure
Step 1: Create a model group
Log in to DMS 5.0.
-
In the upper-left corner of the console, click the
icon and choose .NoteIf you are using the console in a mode other than simple mode, choose from the top navigation bar.
-
In the upper-left corner of the page, click Create Model Group.
-
Specify the Model Group Name and Description, and then click OK.
Step 2: Configure a model training node
-
Create a model training node.
-
Move the pointer over the
icon in the upper-left corner and choose . NoteIf you use the DMS console in normal mode, choose in the top navigation bar.
-
Click the name of the target task flow to open its details page.
To create a new task flow, see Overview.
-
From the Task Type list on the left side of the canvas, drag a Model Training node to a blank area on the canvas.
-
-
Configure the node information.
Configure parameters such as Region, Model Group, Model Name, and AI Resource. Some parameters are described as follows:
-
For Region, select the region where the target model group is located.
-
You can use a variable for the model name. Model names must be unique. If you want to configure a dynamic model name, you can use the built-in variable
modelNameof the model training node. -
Select an AI resource based on your training data volume.
-
For the SQL syntax to create a model, see Model usage workflow and description.
On the Model Configuration page, set the following parameters: Region, Model Group, Model Name, Type (select SQL), Engine Type (select AnalyticDB for MySQL), Instance, and AI Resource. A
CREATE MODELSQL template is automatically generated in the code editor at the bottom of the page. This template includes placeholders such asmodel_class,x_cols,y_cols, andmodel_parameter, along with aSELECT ... FROM table_referencequery structure. Modify the parameter values as needed.
-
-
Configure scheduling for the task flow.
-
Time-based scheduling: Use this option when the task needs to run at a fixed time or on a regular cycle. For more information, see Configure Time-based Scheduling.
-
Event-based scheduling: Use this option when the task needs to be triggered by an external event. For more information, see Configure Event-based Scheduling.
-
-
Run the node.
Click Test Run at the top of the page. If the execution log ends with
status SUCCEEDED, the test run succeeded. DMS records each successful run in the model group.NoteIf the execution log ends with
status FAILED, the test run failed. You can view the failed node and the cause in the execution log, modify the configuration, and try again.
Step 3: (Optional) Configure a model evaluation node
-
Create a model evaluation node.
-
Move the pointer over the
icon in the upper-left corner and choose . NoteIf you use the DMS console in normal mode, choose in the top navigation bar.
-
Click the name of the target task flow to open its details page.
To create a new task flow, see Overview.
-
From the Task Type list on the left side of the canvas, drag a Model Evaluation node to a blank area on the canvas.
-
-
Configure the node information.
Configure the Region, Model Group, Engine Type, and Model information.
NoteSelect the region where the target model group is located.
For Type, select SQL. The SQL editor displays the EVALUATE syntax template:
SELECT ... FROM EVALUATE (MODEL model_name, SELECT ... FROM table_reference) WITH (x_cols, y_cols, metrics). -
Configure scheduling for the task flow.
-
Time-based scheduling: Use this option when the task needs to run at a fixed time or on a regular cycle. For more information, see Configure Time-based Scheduling.
-
Event-based scheduling: Use this option when the task needs to be triggered by an external event. For more information, see Configure Event-based Scheduling.
-
-
Run the node.
Click Test Run at the top of the page. If the execution log ends with
status SUCCEEDED, the test run succeeded.NoteIf the execution log ends with
status FAILED, the test run failed. You can view the failed node and the cause in the execution log, modify the configuration, and try again. -
After the run succeeds, you can view the model's metrics in the model group list or in the execution log.
For a description of model metrics, see Model usage workflow and description.
The execution log shows the execution process and evaluation metrics for the model evaluation task. Example:
running 2024-09-03 18:46:36.650238 2024-09-03 18:47:43[GMT+08:00] INFO - task status:running 2024-09-03 18:47:53[GMT+08:00] INFO - check task status, Query key:ModelevalJob-e174 2024-09-03 18:47:55[GMT+08:00] INFO - Query successful! Result list: taskStatus filePath results startTime endTime errMsg successBatch allBatch xxx xxx xxx xxx xxx xxx xxx xxx xxx {"Fscore": "precision:{0: 0.955, 1: 0.4}; recall:{0: 0.9975, 1: 0.0339};f1score:{0: 0.9758, 1: 0.0625}"} 2024-09-03 18:46:36.650238 2024-09-03 18:47:55[GMT+08:00] INFO - task status:finished 2024-09-03 18:47:55[GMT+08:00] INFO - model evaluation successful, result path: ["http:// xxx"] 2024-09-03 18:47:55[GMT+08:00] INFO - evaluation result:{"Fscore": "precision:{0: 0.955, 1: 0.4}; recall:{0: 0.9975, 1: 0.0339};f1score:{0: 0.9758, 1: 0.0625}"} 2024-09-03 18:47:55[GMT+08:00] INFO - Finishing job j_13320 at xxx with status SUCCEEDED
Step 4: Deploy the model
-
On the Model Management page, find and expand the target model group.
-
Find the target model and click Deploy in the Actions column.
-
In the Deploy Model dialog box, select the target AnalyticDB for MySQL instance and AI Resource.
Select AI resources based on the inference data volume. These resources do not need to match those used for the model training node.
-
Click Deploy.
If the model status changes to Deployed, the deployment is successful.
Step 5: Configure a model inference node
-
Create a model inference node.
-
Move the pointer over the
icon in the upper-left corner and choose . NoteIf you use the DMS console in normal mode, choose in the top navigation bar.
-
Click the name of the target task flow to open its details page. To create a new task flow, see Overview.
-
From the Task Type list on the left side of the canvas, drag a Model Inference node to a blank area on the canvas.
-
-
Configure the node information.
Configure the Region, Model Group, Engine Type, and Model information.
Note-
Select the region where the target model group is located.
-
You can select only deployed models.
-
For the model inference SQL syntax, see Model usage workflow and description.
For Type, select SQL.
-
-
Configure scheduling for the task flow.
-
Time-based scheduling: Use this option when the task needs to run at a fixed time or on a regular cycle. For more information, see Configure Time-based Scheduling.
-
Event-based scheduling: Use this option when the task needs to be triggered by an external event. For more information, see Configure Event-based Scheduling.
-
-
Run the node.
Click Test Run at the top of the page. If the execution log ends with
status SUCCEEDED, the test run succeeded.NoteIf the execution log ends with
status FAILED, the test run failed. You can view the failed node and the cause in the execution log, modify the configuration, and try again.