Recommendation diagnostics

Updated at:

Recommendation diagnostics provides a visual platform to inspect results generated by the recommendation API and their corresponding item_id details, helping you evaluate the reliability of your recommendation policy.

Data table management

Item information is stored in a separate data table. After the system retrieves an item_id from the recommendation results, it looks up the corresponding item details, such as titles, images, and videos.

During configuration, you can select the data table type, name the data table, and define its fields.

On the Data Registration page, select the Hologres Table tab and click Add Table. In the Add Hologres Table panel, configure parameters such as Hologres Instance ID and Database and Hologres Table Name.

Diagnostic methods

Recommendation result diagnostics

Before using recommendation result diagnostics, go to the PAI-Rec console. On the System Configuration > Cloud Service Configuration page, open the Engine tab to configure the PAI-EAS resource group if you use a dedicated one. Then, navigate to Engine Service Management > Service Management to set up your recommendation engine.

When you call the recommendation API, ensure the response is in JSON format. The response must include an items list, and each item must contain at least the item_id field. If the response is missing these fields, call the API in debug mode to have the system append the necessary information.

You must register the item table separately. If you use PAI-FeatureStore, go to the PAI > FeatureStore console, create an offline Feature View from your original MaxCompute item table, and use Data Synchronization to sync one day of data to the online store. Then, in the PAI-Rec Troubleshooting Tool, go to Data Registration and register the FeatureStore View. You can then select the registered item table on the Recommendation Result Diagnostics page.

The Recommendation Result Diagnostics page includes the following configuration items: Associate PAI-Rec Service (select a created service), Environment Settings (such as pre-release or production), Routing Information (such as /api/rec/feed), and Item Table. In the request data editing area, enter the request JSON content. You can enable the Debug Mode switch. Click the Diagnose button to run the diagnostics. The results are displayed in a table with columns for sequence number, primary key value, image/video, and detailed information.

The following tables describe the required response structure.

  • Response data

    Parameter

    Type

    Required

    Description

    code

    Integer

    No

    The error code.

    A value of 200 indicates success.

    message

    String

    No

    The error message. If the request is successful, the value is success.

    request_id

    String

    No

    The unique request ID.

    experiment_id

    String

    No

    The experiment ID.

    size

    Integer

    No

    The number of items returned.

    items

    JSON array

    Yes

    The list of recommended items.

  • Individual item data

    Parameter

    Type

    Required

    Description

    item_id

    String

    Yes

    The recommended item ID.

    retrieve_id

    String

    No

    The retrieval data source ID.

    score

    Float

    No

    The final score of the recommended item.

Recall ID string diagnostics

Recall ID string diagnostics evaluates the reliability of a recall ID list. When you enter an item_id, it retrieves and displays the basic information for that item in the same format as recommendation result diagnostics.

On the recall string parsing page, in addition to entering the recall ID string, you must also select the Recall String Format and Item Table, then click Query. If the data is not registered, click the Register Data link to register it.

User behavior analysis

User behavior analysis extracts and displays a list of related item_ids from a user behavior table based on user behavior data.

On the Troubleshooting Tool > Data Registration page, configure the user behavior table, using uid (user ID) as the primary key.

Click Add Table. In the Add Hologres Table panel, select user behavior table as the table type, configure Hologres Instance ID and Database, Hologres Table Name, and Data Table Name. Then, map the corresponding columns for the user_id field, item_id field, and timestamp field.

Then, go to the Troubleshooting Tool > User Behavior Query page to associate the user behavior table with the item table, set filter conditions, and run your query.

On the User Behavior Query page, in addition to the user ID, user behavior table, item table, and filter conditions, you can also set a Time Range (start date and end date) and the Number of Results (100 by default). The Register Data link next to each drop-down list opens the data registration page to complete the table configuration.

User behavior data is stored in Hologres. The following SQL statement creates a user behavior table. You can add more fields as needed:

BEGIN;
DROP TABLE IF EXISTS "sv_rec"."user_behavior";
CREATE TABLE "sv_rec"."user_behavior" (
 "uid" text NOT NULL,
 "itemid" text NOT NULL,
 "event" text NOT NULL,
 "timestamp" timestamptz NOT NULL
);
CALL SET_TABLE_PROPERTY('"sv_rec"."user_behavior"', 'orientation', 'row');
CALL SET_TABLE_PROPERTY('"sv_rec"."user_behavior"', 'clustering_key', '"uid","timestamp:desc"');
CALL SET_TABLE_PROPERTY('"sv_rec"."user_behavior"', 'time_to_live_in_seconds', '2592000');
comment on column "sv_rec"."user_behavior"."uid" is 'User ID';
comment on column "sv_rec"."user_behavior"."itemid" is 'Item ID';
comment on column "sv_rec"."user_behavior"."event" is 'User behavior events, such as click, add to favorites, and share.';
comment on column "sv_rec"."user_behavior"."timestamp" is 'The time when the event occurred.';
COMMIT;