Model export

Updated at:

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 portData type / Upstream componentPAI command parameterRequired
Training model directoryOSS path / Model trainingmodel_dirYes

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.

ParameterRequiredPAI command parameterDefault valueDescription
EasyRec configuration fileNoconfigNoneThe pipeline.config file from Model Training. Specify either this or the training model directory; the training model directory takes precedence.
Specify checkpoint pathNocheckpoint_pathNoneFull OSS path to a specific checkpoint. Overrides the upstream training model path.
export_dirNoexport_dirRandom folder in pipeline data pathOSS path where the exported model is saved.
extra_paramsNoextra_paramsNoneAdditional parameters not defined in the workflow. Example: --asset_files oss://xxx
Specify algorithm versionNoscriptEmptyCustom 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.

ParameterRequiredDefault valueDescription
Worker CountNo1Number of workers.
Worker CPU UsageNo8CPU cores per worker. A value of 1 equals one CPU core.
Worker Memory Usage (MB)No40000Memory per worker in MB. A value of 100 equals 100 MB.
Number of Worker GPUsNo—GPUs are not typically required for EasyRec model export.

Output ports

Output portData typeDownstream component
Model export pathOSS pathModel 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

ParameterRequiredDescription
cmdYesSet to export to run model export.
export_dirYesOSS path where the exported model is saved.
arnYesResource group authorization string. Get it from the PAI console: go to Activation and Authorization > All Cloud Product Dependencies > Designer section > View Authorization Information.
ossHostYesOSS endpoint for the region where your buckets reside. See Regions and endpoints.
bucketsYesBuckets containing the config file and the trained model. For multiple buckets, separate with commas: oss://xxxx/,oss://xxxx/.
configNoThe pipeline.config file from training. If model_dir is also set, model_dir takes precedence. Useful for periodic workflow scheduling.
model_dirNoOSS path of the trained model directory. Overrides model_dir in config. Useful for periodic workflow scheduling.
extra_paramsNoAdditional parameters not defined in the workflow.

Example

The following example shows a complete Designer workflow that runs model training and then exports the model.

  1. 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_dir configured.

    image..png

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