Best practices for customizing the HSTU generative ranking algorithm
Configure the HSTU generative ranking model in PAI-Rec using a public dataset. This tutorial covers feature engineering, model training, and deployment. The current release covers the dlrm-hstu model configuration; additional recall and ranking models will be added in future releases. For other recall and ranking configurations, see Best practices for PAI-Rec modular algorithm customization.
Before you begin, make sure that your PAI-Rec instance is initialized, data is registered, and a recommendation scenario is created. For steps 1–4, see Best practices for PAI-Rec modular algorithm customization.
5. Create and configure an algorithm solution
This section covers only the feature engineering and model configuration required for HSTU. For production use cases that require additional recall strategies, see Best practices for PAI-Rec modular algorithm customization.
Create a recommendation solution. For data table configuration, see sections 5.1 and 5.2 in Best practices for PAI-Rec modular algorithm customization. Important: For HSTU, the behavior table must include the Request ID field.
-
On the Feature Group Configuration page, click Add. Configure the feature module name and version, and then select the user table, item table, and behavior log table in Configure Table.
Click Determine. The system generates multiple statistical features for both users and items. Click Configure Feature in the feature group to view the corresponding validation features. You must modify the feature group to adapt it for the downstream model.
User side: You must configure sequence features. For deduplication ID, select the partition field by default. Enable event pre-aggregation deduplication. Only one sequence can be configured. Select all options under Statistical Behavior. For sub-features, you must select the fields corresponding to itemid, event, and event_time. Additional sub-features can be configured based on your business requirements. Because HSTU supports longer sequences, you can adjust the time period and sequence length.
Item side: Do not configure kv-type features. Remove the behavior count and conversion rate features under Top Preference Attribute. Do not add the Top Category and Numeric Combination feature. Real-time features and Aggregated features are not supported on the item side. Only pure numerical statistical features are supported.
Click Publish in the feature group. Set the task run date to the latest partition date and adjust the maximum parallelism (up to 10). Keep other settings at their defaults and click Determine. This generates nodes and deploys them to DataWorks. Data is backfilled based on the date. Wait until the module status changes to Published before proceeding. Click Online Details to view module details. The Data Refill Task List shows the running status of each task. For failed tasks, click View Task Node to go to DataWorks and view the error details. After fixing the issue, click Data Refill Task List for the node and then click Rerun. After the task passes, click Resume.
-
Go to Label Table Configuration. This module builds sample objectives based on the behavior table. Click Add and select the current module as the label module. Enter a label module name and select the feature module configured in the upstream step. Click Fine-Ranking Objective Settings (Labels) and then click Create to add the following two objectives:
Objective 1: Set Fine-Ranking Objective Name to
is_clickand Fine-Ranking Objective Expression tomax(if(event='click',1,0)). Set Objective Type to Classification (CLASSIFICATION).Objective 2 (note: the "l" in "ln" is a lowercase L): Set Fine-Ranking Objective Name to ln_playtime, Fine-Ranking Objective Expression to
ln(sum(playtime)+1), Fine-Ranking Objective Dependency tois_click, and Objective Type to Regression (REGRESSION). Click OK to save the objective.
Set Generative Recommendation Mode to Generative: DLRM-HSTU. Click Determine and bring the label module online, following the same procedure as the feature module. Wait until the status changes to Published before proceeding.
Go to Sample Configuration. This module associates sample objective tables with features and produces model features in feature-store. Click Add and select the current module as the sample module. Name the model feature, select the upstream feature module, and select the upstream label module. Bring the module online following the same procedure as above. Wait until the status changes to Published before proceeding.
Go to Feature Generation Configuration. This module further derives all features from the sample table. Custom configuration is not supported. Click Add and select the current module as Feature Generation. Set the feature generation type to Ranking and select the model feature module produced by the upstream sample configuration. In Behavior Weight Configuration, configure the behavior permissions one by one. The weight corresponds to a power of 2: for example, set expr to 1, click to 2, and praise to 4. If your business has additional behavior types, use incrementing powers of 2 (8, 16, 32, etc.). Wait until the status changes to Published before proceeding.
Go to Configure Sorting Method. Click Add under Fine-Ranking. Select the feature generation module produced by the upstream step as the feature module output. Keep other settings at their defaults. Select dlrm-hstu as the model and click Determine. Bring the module online following the same procedure as the upstream modules. After the backfill module finishes, the current module status changes to Published and the model service appears in the PAI-EAS console. Note: The instance type used for model export must match the instance type used for model service deployment.