Model scoring consistency
Run a feature consistency check before deploying a ranking model to verify that the online service retrieves all required offline features and that online feature processing logic matches the offline training logic. This check evaluates only offline features because real-time features cannot be reliably compared.
Prerequisites
A fine-ranking model service and a PAI-Rec engine service have been deployed.
Configure and enable feature consistency
-
In the navigation pane on the left, click Model Scoring Consistency, and then click Create Task. Configure the following key parameters.
-
PAI-EAS Model Service Name: Select a model service, not an engine service.
-
Sampling Ratio: Set this parameter based on the traffic volume. If the traffic is high, set a smaller value to avoid overloading the online service.
-
FeatureStore: Enter the required configurations.
-
Item Feature View Associated with Sequence Features: If the model uses sequence features, configure this option.
-
Generate ZIP package: Select Yes. This action generates a package for the consistency task in the specified OSS path. The package contains node details to help you troubleshoot issues.
In Advanced Configuration, if you use a non-standard EasyRec or TorchEasyRec package, enter a custom EasyRec package path.
-
-
After the task is created, click Run Task. Select the runtime environment and specify the duration for log collection.
ImportantIf the runtime environment has no traffic, you must manually send some requests to the environment after the task starts. Otherwise, the system cannot receive online logs, and downstream evaluation tasks cannot be executed.
View and locate results
Task failed
If a task fails, contact the PAI-Rec helpdesk to identify and resolve the issue.
Task succeeded, offline and online features are identical
Click the task to view the results. If the offline score has a value but the online score is 0, this is usually caused by a timeout.
If both offline and online scores have values, check the ScoreDiff. A small difference indicates that the offline and online features are identical. Click Feature Comparison to view the details.
If sequence features have different delimiters but are otherwise identical, this is normal.
Task succeeded, but offline and online features are different
If offline and online features are inconsistent, further analysis is required.
Import the ZIP package of the consistency task
-
Click the view configuration button for the task to obtain the task ID.
-
Find and download the ZIP package for the task from OSS. The package is located in the
feature_consistency/{task_id}path. This ZIP package contains the workflow for the feature consistency task. -
Import the ZIP package using the DataWorks Migration Assistant.
Go to DataStudio. Under `consistency`, find the imported consistency task. The task name is suffixed with the task ID.
Role of different nodes
The nodes imported into DataStudio have the following roles:
-
01_consistency_create_intersection_table_xxx: Cleans the feature backflow data. -
04_consistency_create_label_table_xxx: Builds samples and identifies which features are retrieved from the feature backflow table. -
05_consistency_create_sample_table_xxx: Exports the sample table. This node builds a model and lets you view the source data table for each feature. -
07_consistency_create_predict_script_xxx: Runs offline prediction on the exported samples. -
08_consistency_create_score_diff_table_xxx: Retrieves the top-k samples with the largest difference between offline and online scores. -
10_consistency_create_compare_fg_feature_table_xxx: For the samples with the largest score differences, this node retrieves the names of the inconsistent features and their corresponding online values.
If other nodes exist, view their content to understand their roles.
Backflow features
Open the 01_consistency_create_intersection_table_xxx node. It contains two tables: feature_backflow_xxxx and feature_reply_xxxx.
-
The
feature_backflow_xxxxtable records the features that the PAI-Rec engine uses to call the model service.user_featurerecords the user features sent during the model service call.item_featurerecords the features of the retrieved item passed from the interface and the resulting score from the model service call. -
The
feature_reply_xxxxtable records features from different stages of the model service.raw_featurescontains the features before they are encoded by Feature Generation (FG).generate_featurescontains the features after they are encoded by FG.
Get feature sources
View the 05_consistency_create_sample_table_xxx node to find the model_name.
Find this model in the model features section of the corresponding FeatureStore. Click Export to view the SQL script that shows the feature sources.
Find and compare inconsistent features
The preceding information helps you determine whether inconsistent features originate from the label table or other offline tables.
Inconsistent features usually do not come from the label table. For special cases, contact the PAI-Rec helpdesk.
If the source is an offline table, first check the corresponding feature view. The feature primary key is usually displayed on the feature comparison page. If not, search the feature_reply table to retrieve the other feature primary keys and verify that the features in the feature view match the backflow data. Then compare the features of the offline table with the backflow data. If both are present, verify that the sync task is running correctly.
Common causes of feature inconsistency
-
The offline feature table is not generated.
-
The offline feature table is scheduled for a dry-run. It has partitions but no data, or the input data is missing.
-
The offline feature table is generated but not synchronized in a timely manner.
-
The model features configured in the engine or A/B testing experiment are inconsistent with those used for the actual training.