快速拉起向量召回服務(wù)
本文檔為您展示一個(gè)示例,在本例中,我們將準(zhǔn)備一份向量數(shù)據(jù)(假設(shè)數(shù)據(jù)表的表名為aime_example_vector
),一份物品詳情數(shù)據(jù)(假設(shè)數(shù)據(jù)表的表名為aime_example_detail
),及一份行為表(假設(shè)行為表的表名為aime_example_exposure
),然后在智能召回引擎控制臺(tái)上注冊(cè)數(shù)據(jù),最后用這三份數(shù)據(jù)拉起一個(gè)向量召回服務(wù)。
?
數(shù)據(jù)準(zhǔn)備
準(zhǔn)備物品向量表
在MaxCompute客戶端中準(zhǔn)備離線數(shù)據(jù)
-- 創(chuàng)建數(shù)據(jù)表
CREATE TABLE IF NOT EXISTS aime_example_vector (
item_id STRING COMMENT "物品ID",
vector STRING COMMENT "物品向量"
) PARTITIONED BY (
ds STRING COMMENT "分區(qū)字段"
);
-- 寫入向量數(shù)據(jù),實(shí)際業(yè)務(wù)場(chǎng)景下,具體的寫入數(shù)據(jù)由您的算法邏輯產(chǎn)出
INSERT OVERWRITE TABLE aime_example_vector PARTITION (ds = '20210822')
SELECT '10001' AS item_id, '0.4426,0.0724,0.0210,0.4353,0.6385,0.0770,0.0158,0.4417' AS vector UNION
SELECT '10002' AS item_id, '0.2119,0.3770,0.5210,0.0279,0.5151,0.3806,0.3244,0.1590' AS vector UNION
SELECT '10003' AS item_id, '0.2829,0.0720,0.1324,0.2817,0.4565,0.6583,0.0338,0.4183' AS vector;
-- 寫入標(biāo)識(shí)分區(qū)
INSERT OVERWRITE TABLE aime_example_vector PARTITION (ds = '20210822.done')
SELECT NULL, NULL UNION;
在智能召回引擎控制臺(tái)上注冊(cè)數(shù)據(jù)
進(jìn)入實(shí)例詳情-數(shù)據(jù)管理頁(yè)面,點(diǎn)擊“注冊(cè)數(shù)據(jù)”
配置基礎(chǔ)信息:
點(diǎn)擊“下一步”,開始配置索引
點(diǎn)擊“下一步”,配置全量調(diào)度方式
點(diǎn)擊“配置完成并上線”,完成注冊(cè)并發(fā)布
?
準(zhǔn)備物品詳情表(可選)
在MaxCompute客戶端中準(zhǔn)備數(shù)據(jù)
-- 創(chuàng)建數(shù)據(jù)表
CREATE TABLE IF NOT EXISTS aime_example_detail (
nid STRING COMMENT "物品ID",
title STRING COMMENT "物品名稱",
price DOUBLE COMMENT "物品價(jià)格"
) PARTITIONED BY (
ds STRING COMMENT "分區(qū)字段"
);
-- 寫入物品數(shù)據(jù),實(shí)際業(yè)務(wù)場(chǎng)景下,具體應(yīng)該寫入您實(shí)際的物品詳情數(shù)據(jù)
INSERT OVERWRITE TABLE aime_example_detail PARTITION (ds = '20210822')
SELECT '10001' AS nid, '甜美泡泡袖蝴蝶結(jié)寶藏連衣裙' AS title, 269.00 AS price UNION
SELECT '10002' AS nid, '亞麻法式小黑裙連衣裙' AS title, 259.00 AS price UNION
SELECT '10003' AS nid, '法式西裝裙收腰襯衫裙子' AS title, 599.00 AS price;
-- 寫入標(biāo)識(shí)分區(qū)
INSERT OVERWRITE TABLE aime_example_detail PARTITION (ds = '20210822.done')
SELECT NULL, NULL, NULL UNION;
在智能召回引擎控制臺(tái)上注冊(cè)數(shù)據(jù)
進(jìn)入實(shí)例詳情-數(shù)據(jù)管理頁(yè)面,按照如下方式填寫:
點(diǎn)擊“下一步”,開始配置索引
點(diǎn)擊“下一步”,開始配置全量調(diào)度方式
點(diǎn)擊“配置完成并上線”,完成注冊(cè)并發(fā)布
準(zhǔn)備行為表(可選)
在MaxCompute客戶端中準(zhǔn)備數(shù)據(jù)
DROP TABLE IF EXISTS aime_example_expose;
-- 創(chuàng)建數(shù)據(jù)表
CREATE TABLE IF NOT EXISTS aime_example_expose (
user_id STRING COMMENT "用戶ID",
item_id STRING COMMENT "物品ID",
time BIGINT COMMENT "行為時(shí)間"
) PARTITIONED BY (
ds STRING COMMENT "分區(qū)字段"
);
-- 寫入向量數(shù)據(jù),實(shí)際業(yè)務(wù)場(chǎng)景下,具體的寫入數(shù)據(jù)由您的算法邏輯產(chǎn)出
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
-- 寫入標(biāo)識(shí)分區(qū)
INSERT OVERWRITE TABLE aime_example_expose PARTITION (ds = '20210822.done')
SELECT NULL, NULL, NULL;
在智能召回引擎控制臺(tái)上注冊(cè)數(shù)據(jù)
進(jìn)入實(shí)例詳情-數(shù)據(jù)管理頁(yè)面,按照如下方式填寫:
點(diǎn)擊“下一步”,開始配置索引
點(diǎn)擊“下一步”,開始配置全量調(diào)度方式
點(diǎn)擊“配置完成并上線”,完成注冊(cè)并發(fā)布
服務(wù)注冊(cè)
在實(shí)例詳情-服務(wù)管理中,點(diǎn)擊“創(chuàng)建召回服務(wù)”按鈕,開始創(chuàng)建召回服務(wù)。
選擇注冊(cè)“向量召回”服務(wù)
點(diǎn)擊“下一步”,填寫基礎(chǔ)配置信息:
點(diǎn)擊“下一步”,選擇我們剛剛注冊(cè)的兩張表
配置完成并上線
進(jìn)入服務(wù)管理,可以看到我們剛才創(chuàng)建的召回服務(wù),等待其發(fā)布完成,就可以使用了。