Model export
Export a trained EasyRec model to an OSS path so it can be consumed by the Model Deployment component.
There are two ways to run model export: via the Designer component (GUI) or via the PAI command (CLI). Jump to the section that matches your setup.
Prerequisites
Before you begin, ensure that you have:
Completed model training, which produces the training model directory in OSS
Configure the Designer component
Input ports
| Input port | Data type / Upstream component | PAI command parameter | Required |
|---|---|---|---|
| Training model directory | OSS path / Model training | model_dir | Yes |
Component parameters
Parameters setting
The component reads from the training model directory by default. Use the parameters below to override the source or destination.
When both the training model directory (input port) and the EasyRec configuration file (config) are specified, the training model directory takes precedence. The Specify checkpoint path (checkpoint_path) overrides the upstream training model path.
| Parameter | Required | PAI command parameter | Default value | Description |
|---|---|---|---|---|
| EasyRec configuration file | No | config | None | The pipeline.config file from Model Training. Specify either this or the training model directory; the training model directory takes precedence. |
| Specify checkpoint path | No | checkpoint_path | None | Full OSS path to a specific checkpoint. Overrides the upstream training model path. |
| export_dir | No | export_dir | Random folder in pipeline data path | OSS path where the exported model is saved. |
| extra_params | No | extra_params | None | Additional parameters not defined in the workflow. Example: --asset_files oss://xxx |
| Specify algorithm version | No | script | Empty | Custom EasyRec version to use. Select Advanced options to configure. Steps: 1. Generate a TAR package—see EasyRec Release Notes. 2. Upload it to OSS—see Upload files. 3. Select the uploaded file for this parameter. |
Execution tuning
Execution tuning parameters are assembled into the cluster PAI command parameter.
| Parameter | Required | Default value | Description |
|---|---|---|---|
| Worker Count | No | 1 | Number of workers. |
| Worker CPU Usage | No | 8 | CPU cores per worker. A value of 1 equals one CPU core. |
| Worker Memory Usage (MB) | No | 40000 | Memory per worker in MB. A value of 100 equals 100 MB. |
| Number of Worker GPUs | No | — | GPUs are not typically required for EasyRec model export. |
Output ports
| Output port | Data type | Downstream component |
|---|---|---|
| Model export path | OSS path | Model Deployment |
Run the PAI command
Use the following command to run model export from the CLI.
PAI -project algo_public -name easy_rec_ext
-Dcmd="export"
-Dconfig="oss://rec_sln_demo/EasyRec/deploy/rec_sln_demo_rec_sln_demo_sorting_v2/20230425/pipeline.config"
-Dmodel_dir="oss://rec_sln_demo/EasyRec/deploy/rec_sln_demo_rec_sln_demo_sorting_v2/20230425"
-Dexport_dir="oss://lcl-hz/rec_sln_demo/EasyRec/deploy/rec_sln_demo_rec_sln_demo_sorting_v2/export/20230425/final_witn_fg"
-Darn="acs:ram::xxxx:role/aliyunodpspaidefaultrole"
-Dbuckets="oss://rec_sln_demo/"
-Dcluster="{\"worker\": {\"count\": 1, \"cpu\": 800, \"gpu\": 0, \"memory\": 40000}}"
-Dextra_params="--asset_files oss://rec_sln_demo/EasyRec/deploy/rec_sln_demo_rec_sln_demo_sorting_v2/fg.json"
-Dlifecycle="28"
-DossHost="oss-cn-hangzhou-internal.aliyuncs.com";PAI command parameters
| Parameter | Required | Description |
|---|---|---|
cmd | Yes | Set to export to run model export. |
export_dir | Yes | OSS path where the exported model is saved. |
arn | Yes | Resource group authorization string. Get it from the PAI console: go to Activation and Authorization > All Cloud Product Dependencies > Designer section > View Authorization Information. |
ossHost | Yes | OSS endpoint for the region where your buckets reside. See Regions and endpoints. |
buckets | Yes | Buckets containing the config file and the trained model. For multiple buckets, separate with commas: oss://xxxx/,oss://xxxx/. |
config | No | The pipeline.config file from training. If model_dir is also set, model_dir takes precedence. Useful for periodic workflow scheduling. |
model_dir | No | OSS path of the trained model directory. Overrides model_dir in config. Useful for periodic workflow scheduling. |
extra_params | No | Additional parameters not defined in the workflow. |
Example
The following example shows a complete Designer workflow that runs model training and then exports the model.
Build the workflow. Areas 1–3 contain the model training components (see model training example instances). Area 4 is the Model Export component with
export_dirconfigured.
Run the workflow. After it completes, the exported model appears in the OSS path specified for
export_dir.
For a complete end-to-end example, see component 8_rec_sln_demo_rec_sln_demo_sorting_v2_train in the Recommendation Solutions - Sorting workflow.
What's next
Model Deployment — connect the Model Export output port to the Model Deployment component to deploy your exported model.