Launch X2I recall service

更新时间:
复制 MD 格式

This document describes how to launch an X2I recall service. You will prepare an X2I recall table (`aime_example_x2i`), an item details table (`aime_example_detail`), and a behavior table (`aime_example_expose`). Then, you will register the data in the Intelligent Recall Engine console to launch an X2I recall service.

Data preparation

Prepare the X2I recall table

Prepare offline data in the MaxCompute client

-- Create a data table
CREATE TABLE IF NOT EXISTS aime_example_x2i (
  trigger_id STRING COMMENT "Recall field",
  item_id STRING COMMENT "Item ID",
  score DOUBLE COMMENT "Recall score"
) PARTITIONED BY (
  ds STRING COMMENT "Partition field"
);

-- Write the X2I data. In a real-world scenario, your algorithm logic produces this data.
INSERT OVERWRITE TABLE aime_example_x2i PARTITION (ds = '20210822')
SELECT 'A' AS trigger_id, '10001' AS item_id, 1.12 AS score UNION
SELECT 'A' AS trigger_id, '10002' AS item_id, 1.07 AS score UNION
SELECT 'B' AS trigger_id, '10001' AS item_id, 0.98 AS score UNION
SELECT 'C' AS trigger_id, '10003' AS item_id, 0.87 AS score;

-- Write data to the identity partition.
INSERT OVERWRITE TABLE aime_example_x2i PARTITION (ds = '20210822.done')
SELECT NULL, NULL, NULL UNION;

Register the data in the Intelligent Recall Engine console

Go to the instance details page, select Data Management, and then click Register Data.

Configure basic information.

Click Next to declare the data structure.

Click Next to configure the full scheduling method.

Click Complete and Publish to complete the registration and publish the data.

Prepare the item details table (Optional)

Prepare data in the MaxCompute client

-- Create a data table
CREATE TABLE IF NOT EXISTS aime_example_detail (
  nid STRING COMMENT "Item ID",
  title STRING COMMENT "Item name",
  price DOUBLE COMMENT "Item price"
) PARTITIONED BY (
  ds STRING COMMENT "Partition field"
);

-- Write the item data. In a real-world scenario, write your actual item details data.
INSERT OVERWRITE TABLE aime_example_detail PARTITION (ds = '20210822')
SELECT '10001' AS nid, 'Sweet bubble sleeve bow treasure dress' AS title, 269.00 AS price UNION
SELECT '10002' AS nid, 'Linen French little black dress' AS title, 259.00 AS price UNION
SELECT '10003' AS nid, 'French suit skirt waist-cinching shirt dress' AS title, 599.00 AS price;

-- Write data to the identity partition.
INSERT OVERWRITE TABLE aime_example_detail PARTITION (ds = '20210822.done')
SELECT NULL, NULL, NULL UNION;

Register the data in the Intelligent Recall Engine console

Go to the Instance Details - Data Management page and enter the following information:

Click Next to configure the index.

Click Next to configure the full scheduling method.

Click Complete and Publish to complete the registration and publish the data.

Prepare the behavior table (Optional)

Prepare data in the MaxCompute client

DROP TABLE IF EXISTS aime_example_expose;

-- Create a data table
CREATE TABLE IF NOT EXISTS aime_example_expose (
  user_id STRING COMMENT "User ID",
  item_id STRING COMMENT "Item ID",
  time BIGINT COMMENT "Behavior time"
) PARTITIONED BY (
  ds STRING COMMENT "Partition field"
);

-- Write the behavior data. In a real-world scenario, your algorithm logic produces this data.
INSERT OVERWRITE TABLE aime_example_expose PARTITION (ds = '20210822')
SELECT 'u0001' AS user_id, '10001' AS item_id, 1640275200 AS time UNION -- 20211224
SELECT 'u0001' AS user_id, '10002' AS item_id, 1640275200 AS time UNION -- 20211224
SELECT 'u0002' AS user_id, '10003' AS item_id, 1640275200 AS time UNION -- 20211224
SELECT 'u0002' AS user_id, '10004' AS item_id, 1640275200 AS time UNION -- 20211224
SELECT 'u0003' AS user_id, '10001' AS item_id, 1640275200 AS time UNION -- 20211224
SELECT 'u0003' AS user_id, '10002' AS item_id, 1640188800 AS time UNION -- 20211223
SELECT 'u0003' AS user_id, '10003' AS item_id, 1640102400 AS time UNION -- 20211222
SELECT 'u0003' AS user_id, '10004' AS item_id, 1640016000 AS time UNION -- 20211221
SELECT 'u0003' AS user_id, '10005' AS item_id, 1639929600 AS time UNION -- 20211220
SELECT 'u0003' AS user_id, '10006' AS item_id, 1639843200 AS time UNION -- 20211219
SELECT 'u0003' AS user_id, '10007' AS item_id, 1639756800 AS time UNION -- 20211218
SELECT 'u0003' AS user_id, '10008' AS item_id, 1639670400 AS time UNION -- 20211217
SELECT 'u0003' AS user_id, '10009' AS item_id, 1639584000 AS time UNION -- 20211216
SELECT 'u0003' AS user_id, '10010' AS item_id, 1639497600 AS time;      -- 20211215

-- Write data to the identity partition.
INSERT OVERWRITE TABLE aime_example_expose PARTITION (ds = '20210822.done')
SELECT NULL, NULL, NULL;

Register the data in the Intelligent Recall Engine console

On the Instance Details - Data Management page, complete the fields as follows:

Click Next to configure the index.

Click Next to configure the full scheduling method.

Click Complete and Publish to complete the registration and publish the data.

Register the service

On the instance details page, click Service Management and then click Create Recall Service.

Set Service Type to X2I Recall.

Configure basic information for the service.

Under Configure Data, select the data that you prepared.

Configuration published

Go to the Service Management page. The recall service that you created is displayed. Wait until the service is published before you use it.