Configure model training, inference, or evaluation nodes

Updated at:

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.

    Note

    In 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.

    Note

    In 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

image

Procedure

Step 1: Create a model group

  1. Log in to DMS 5.0.

  2. In the upper-left corner of the console, click the 2023-01-28_15-57-17.png icon and choose All Functions > Data Assets > Model Management.

    Note

    If you are using the console in a mode other than simple mode, choose Data Assets > Model Management from the top navigation bar.

  3. In the upper-left corner of the page, click Create Model Group.

  4. Specify the Model Group Name and Description, and then click OK.

Step 2: Configure a model training node

  1. Create a model training node.

    1. Move the pointer over the 2023-01-28_15-57-17.png icon in the upper-left corner and choose All Features > Data+AI > Data Development > Task Orchestration.

      Note

      If you use the DMS console in normal mode, choose Data+AI > Data Development > Task Orchestration in the top navigation bar.

    2. Click the name of the target task flow to open its details page.

      To create a new task flow, see Overview.

    3. From the Task Type list on the left side of the canvas, drag a Model Training node to a blank area on the canvas.

  2. 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 modelName of 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 MODEL SQL template is automatically generated in the code editor at the bottom of the page. This template includes placeholders such as model_class, x_cols, y_cols, and model_parameter, along with a SELECT ... FROM table_reference query structure. Modify the parameter values as needed.

  3. 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.

  4. 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.

    Note

    If 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

  1. Create a model evaluation node.

    1. Move the pointer over the 2023-01-28_15-57-17.png icon in the upper-left corner and choose All Features > Data+AI > Data Development > Task Orchestration.

      Note

      If you use the DMS console in normal mode, choose Data+AI > Data Development > Task Orchestration in the top navigation bar.

    2. Click the name of the target task flow to open its details page.

      To create a new task flow, see Overview.

    3. From the Task Type list on the left side of the canvas, drag a Model Evaluation node to a blank area on the canvas.

  2. 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.

    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).

  3. 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.

  4. Run the node.

    Click Test Run at the top of the page. If the execution log ends with status SUCCEEDED, the test run succeeded.

    Note

    If 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.

  5. 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

  1. On the Model Management page, find and expand the target model group.

  2. Find the target model and click Deploy in the Actions column.

  3. 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.

  4. Click Deploy.

    If the model status changes to Deployed, the deployment is successful.

Step 5: Configure a model inference node

  1. Create a model inference node.

    1. Move the pointer over the 2023-01-28_15-57-17.png icon in the upper-left corner and choose All Features > Data+AI > Data Development > Task Orchestration.

      Note

      If you use the DMS console in normal mode, choose Data+AI > Data Development > Task Orchestration in the top navigation bar.

    2. Click the name of the target task flow to open its details page. To create a new task flow, see Overview.

    3. From the Task Type list on the left side of the canvas, drag a Model Inference node to a blank area on the canvas.

  2. Configure the node information.

    Configure the Region, Model Group, Engine Type, and Model information.

    Note

    For Type, select SQL.

  3. 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.

  4. Run the node.

    Click Test Run at the top of the page. If the execution log ends with status SUCCEEDED, the test run succeeded.

    Note

    If 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.