召回配置項對應配置總覽中的RecallConfs。
如何配置
PAI-Rec引擎已經內置了多個召回模板,包括協同過濾(UserCollaborativeFilterRecall),向量召回(HologresVectorRecall),U2I 召回(UserCustomRecall)等等,并且支持 mysql、hologres、OTS(Tablestore)等多個數據源。
召回公共配置一覽
每種召回配置,都會用到公共配置中的一部分,在此統一解釋,單獨的召回配置中則不再贅述。
配置示例:
"RecallConfs" :[
{
"Name": "collaborative_filter",
"RecallType": "UserCollaborativeFilterRecall",
"RecallCount": 1000,
"RecallAlgo":"",
"ItemType":"",
"CacheAdapter":"",
"CacheConfig":"",
"CachePrefix":"",
"CacheTime":0
}
]
字段 | 類型 | 是否必填 | 描述 |
Name | string | 是 | 召回的自定義名稱,可以在SceneConfs中引用。 |
RecallType | string | 是 | 引擎內置召回類型,枚舉值,目前支持:
|
RecallCount | string | 是 | 召回數量 |
RecallAlgo | string | 否 | 調用的向量模型名稱,需要先在AlgoConfs里配置,只在實時向量召回中使用。 |
ItemType | string | 否 | 推薦物品類型。 |
CacheAdapter | string | 否 | 這里可以將召回的結果進行緩存,枚舉值,目前支持Redis和localCache。 |
CacheConfig | string | 否 | 緩存的一些配置。 當使用Redis緩存時,參考配置:"{\"host\":\"xxx.redis.rds.aliyuncs.com\", \"port\":6379,\"maxIdle\":10, \"password\":\"xxxx\"}" 當使用localCache時,參考配置 "{\"defaultExpiration\":600, \"cleanupInterval\":600}"。 |
CachePrefix | string | 否 | 這里可以對當前召回結果的key加一個前綴。 當選擇使用緩存時,為必填項。為了避免不同召回之間的緩存互相影響。如 "group_hot_",代表組熱門召回的某個user的緩存結果。 |
CacheTime | string | 否 | 緩存時長,默認1800秒。 |
協同過濾(UserCollaborativeFilterRecall)
協同過濾需要有兩張表,一張u2i表,根據user_id獲取item列表,一張i2i表,獲取相似的item,這兩張表的 schema是固定格式的。
u2i 表
表字段 | 類型 | 描述 |
user_id | string | 用戶id,保持其唯一性 |
item_ids | string | 用戶瀏覽的item id列表,支持格式: item_id1,item_id2,item_id3..... 或者 item_id1:score1,item_id2:score,item_id3:score2...... |
i2i 表
表字段 | 類型 | 描述 |
item_id | string | item id,保持其唯一性 |
similar_item_ids | string | 和item_id相似的item列表,支持格式:item_id1:score1,item_id2:score2,item_id3:score3...... |
協同過濾不同召回源的配置都是類似的,都在UserCollaborativeDaoConf中進行配置
hologres
配置示例:
"RecallConfs" :[
{
"Name": "collaborative_filter",
"RecallType": "UserCollaborativeFilterRecall",
"RecallCount": 1000,
"UserCollaborativeDaoConf": {
"AdapterType": "hologres",
"HologresName": "holo-info",
"User2ItemTable": "u2i_table",
"Item2ItemTable": "i2i_table",
"Normalization" : "on"
}
}
]
UserCollaborativeDaoConfig:
字段 | 類型 | 是否必填 | 描述 |
AdapterType | string | 是 | 數據源的類型,枚舉值,如hologres、mysql、tablestore等 |
HologresName | string | 是 | 在數據源配置(HologresConfs)中配置好的holo的自定義名稱,如數據源配置中的holo_info |
User2ItemTable | string | 是 | u2i表 |
Item2ItemTable | string | 是 | i2i表 |
Normalization | string | 否 | 枚舉值:on/off。是否對召回的item進行歸一化,默認為"on" |
ots(tablestore)
"RecallConfs" :[
{
"Name": "collaborative_filter",
"RecallType": "UserCollaborativeFilterRecall",
"RecallCount": 1000,
"UserCollaborativeDaoConf": {
"AdapterType": "tablestore",
"TableStoreName": "tablestore_info",
"User2ItemTable": "u2i_table",
"Item2ItemTable": "i2i_table",
"Normalization" : "on"
}
}
]
字段 | 類型 | 是否必填 | 描述 |
AdapterType | string | 是 | 數據源的類型,枚舉值,如hologres、mysql、tablestore等 |
TableStoreName | string | 是 | 在數據源配置(TableStoreConfs)中配置好的tablestore的自定義名稱,如數據源配置中的tablestore_info |
User2ItemTable | string | 是 | u2i表 |
Item2ItemTable | string | 是 | i2i表 |
Normalization | string | 否 | 枚舉值:on/off。是否對召回的item進行歸一化,默認為"on" |
redis
Redis進行collaborative_filter流程比較特殊,單獨說明。 實際上也是分兩步:
根據RedisPrefix + uid構造key , 查詢U2I列表, 是個string, 支持格式: item_id1,item_id2,item_id3..... 或者 item_id1:score1,item_id2:score,item_id3:score2......
然后查詢I2I列表, 根據上步查詢到的多個item_id,使用MGET進行查詢。 I2I的數據也是string , 格式如下:item_id1:score1,item_id2:score2,item_id3:score3......
配置示例:
"RecallConfs" :[
{
"Name": "collaborative_filter",
"RecallType": "UserCollaborativeFilterRecall",
"RecallCount": 1000,
"UserCollaborativeDaoConf": {
"AdapterType": "redis",
"RedisName": "redis_info",
"RedisPrefix": "cr_",
"Normalization" : "on"
}
}
]
字段 | 類型 | 是否必填 | 描述 |
AdapterType | string | 是 | 數據源的類型,枚舉值,如 hologres、mysql、tablestore等 |
RedisName | string | 是 | 在數據源配置(RedisConfs)中配置好的Redis的自定義名稱,如數據源配置中的redis_info |
RedisPrefix | string | 否 | U2I數據的前綴,key通過RedisPrefix + uid進行構造 |
實時 U2I2I(RealTimeU2IRecall)
獲取數據的思路和協同過濾中的是一樣的,只不過U2I的數據獲取是通過user歷史行為表實時計算的。
user歷史行為表是根據實時日志來同步更新的,這樣的召回是實時的召回。
user歷史行為表
字段 | 類型 | 描述 |
user_id | string | 用戶id |
item_id | string | 用戶瀏覽的item id |
event | string | 事件名稱 |
play_time | float | 事件的耗時,比如視頻觀看的時長,不存在可以設置為0 |
timestamp | int | 事件發生的時間戳,單位為秒 |
i2i 表
表字段 | 類型 | 描述 |
item_id | string | item id,保持其唯一性 |
similar_item_ids | string | 和item_id相似的item列表,支持格式:item_id1:score1,item_id2:score2,item_id3:score3...... |
hologres
行為表建表語句:
BEGIN;
CREATE TABLE "sv_rec"."user_behavior_seq" (
"user_id" text NOT NULL,
"item_id" text NOT NULL,
"event" text NOT NULL,
"play_time" float8 NULL,
"timestamp" int8 NOT NULL
);
CALL SET_TABLE_PROPERTY('"sv_rec"."user_behavior_seq"', 'orientation', 'column');
call set_table_property('table_name', 'distribution_key', '"user_id"');
CALL SET_TABLE_PROPERTY('"sv_rec"."user_behavior_seq"', 'clustering_key', '"user_id:asc","timestamp:desc"');
CALL SET_TABLE_PROPERTY('"sv_rec"."user_behavior_seq"', 'bitmap_columns', '"user_id","event"');
CALL SET_TABLE_PROPERTY('"sv_rec"."user_behavior_seq"', 'dictionary_encoding_columns', '"user_id:auto","item_id:auto","event"');
CALL SET_TABLE_PROPERTY('"sv_rec"."user_behavior_seq"', 'time_to_live_in_seconds', '2592000');
comment on table "sv_rec"."user_behavior_seq" is '用戶實時行為序列';
comment on column "sv_rec"."user_behavior_seq"."user_id" is '用戶id';
comment on column "sv_rec"."user_behavior_seq"."item_id" is 'item id';
comment on column "sv_rec"."user_behavior_seq"."event" is '事件類型';
comment on column "sv_rec"."user_behavior_seq"."play_time" is '閱讀時長,播放時長';
comment on column "sv_rec"."user_behavior_seq"."timestamp" is '時間戳,單位秒';
COMMIT;
配置示例:
"RecallConfs" :[
{
"Name": "RealTimeEtrecRecall",
"RecallType": "RealTimeU2IRecall",
"RecallCount": 200,
"RealTimeUser2ItemDaoConf": {
"UserTriggerDaoConf": {
"AdapterType": "hologres",
"HologresName": "holo_info",
"HologresTableName": "user_behavior_table",
"WhereClause": "event='xxx'",
"Limit": 200,
"EventPlayTime": "playback:5000;playvslide:5000",
"EventWeight": "playback:1;playvslide:2",
"WeightExpression": "(-0.2)*((currentTime-eventTime)/3600/24)",
"WeightMode": "sum",
"NoUsePlayTimeField": false
},
"Item2ItemTable": "i2i_table"
}
}
]
RealTimeUser2ItemDaoConf:
字段 | 類型 | 是否必填 | 描述 |
AdapterType | string | 是 | 數據源的類型,枚舉值,如hologres、mysql、tablestore等 |
HologresName | string | 是 | 在數據源配置(HologresConfs)中配置好的holo的自定義名稱,如數據源配置中的holo_info |
HologresTableName | string | 是 | holo中user歷史行為表的表名 |
WhereClause | string | 否 | 過濾條件,相當于sql中的where條件 |
Limit | int | 否 | 查詢數量限制,相當于sql中的limit |
EventPlayTime | string | 否 | 事件播放時間的過濾。可以針對每個事件,進行過濾e_sv_func_svplayback:5000表示針對事件 e_sv_func_svplayback,play_time的值必須大于5000 , 不符合條件則被過濾掉。可以設置多個事件,以 ; 分隔 |
EventWeight | string | 否 | 事件的權重, 可以定義每個事件的權重, 不設置的話,默認值為1 |
WeightExpression | string | 否 | 權重表達式。 以時間衰減來計算事件的權重。currentTime代表當前的時間戳,eventTime代表行為表的里timestamp |
WeightMode | string | 否 | 計算trigger權重的方式,取值為sum或者max 。 默認是sum |
NoUsePlayTimeField | bool | 否 | 如果不使用play_time字段,可以設置為true |
Item2ItemTable | string | 是 | holo中的i2i表名稱 |
向量召回(HologresVectorRecall)
目前向量召回只能使用hologres數據源,向量數據都存在hologres表中
配置示例:
"RecallConfs" :[
{
"Name": "vector_recall",
"RecallType": "HologresVectorRecall",
"RecallCount": 100,
"VectorDaoConf" :{
"AdapterType": "hologres",
"HologresName": "holo_info",
"HologresTableName": "user_embedding_table",
"KeyField": "user_id",
"EmbeddingField" :"emb"
},
"HologresVectorConf" :{
"VectorTable" :"item_embedding_table",
"VectorEmbeddingField" :"emb",
"VectorKeyField" :"item_id"
}
}
]
VectorDaoConf:
字段 | 類型 | 是否必填 | 描述 |
AdapterType | string | 是 | 數據源的類型,取值hologres |
HologresName | string | 是 | 在數據源配置(HologresConfs)中配置好的holo的自定義名稱,如數據源配置中的holo_info |
HologresTableName | string | 是 | holo中對應的向量表名稱 |
KeyField | string | 是 | 向量表中的主鍵字段 |
EmbeddingField | string | 是 | 向量表中存儲向量的字段 |
HologresVectorConf:
字段 | 類型 | 是否必填 | 描述 |
VectorTable | string | 是 | holo中item向量表 |
VectorEmbeddingField | string | 是 | item向量表中的主鍵字段 |
VectorKeyField | string | 是 | item向量表中存儲向量的字段 |
VectorDaoConf里記錄的是user向量信息,表的定義如下
BEGIN;
CREATE TABLE "public"."graphsage_user_embedding" (
"user_id" text NOT NULL,
"emb" float4[] NOT NULL,
"dt" text,
PRIMARY KEY ("user_id")
);
CALL SET_TABLE_PROPERTY('"public"."graphsage_user_embedding"', 'orientation', 'row');
CALL SET_TABLE_PROPERTY('"public"."graphsage_user_embedding"', 'clustering_key', '"user_id:asc"');
CALL SET_TABLE_PROPERTY('"public"."graphsage_user_embedding"', 'time_to_live_in_seconds', '3153600000');
comment on column "public"."graphsage_user_embedding"."user_id" is '用戶ID';
comment on column "public"."graphsage_user_embedding"."emb" is '用戶特征向量';
comment on column "public"."graphsage_user_embedding"."dt" is '日期 yyyyMMdd';
COMMIT;
HologresVectorConf記錄的是item向量, 表定義如下
BEGIN;
CREATE TABLE "public"."graphsage_item_embedding" (
"item_id" text NOT NULL,
"emb" float4[] NOT NULL,
PRIMARY KEY ("item_id")
);
CALL SET_TABLE_PROPERTY('"public"."graphsage_item_embedding"', 'orientation', 'column');
CALL SET_TABLE_PROPERTY('"public"."graphsage_item_embedding"', 'bitmap_columns', '"item_id"');
CALL SET_TABLE_PROPERTY('"public"."graphsage_item_embedding"', 'time_to_live_in_seconds', '3153600000');
comment on column "public"."graphsage_item_embedding"."item_id" is '物品ID';
comment on column "public"."graphsage_item_embedding"."emb" is '物品特征向量';
COMMIT;
實時向量召回(OnlineHologresVectorRecall)
實時向量召回和向量召回的實現方式是一致的,也是基于hologres的表數據,不同的是,user向量不是從表里獲取的,而是實時通過模型獲取到的,然后去item向量表查數據。實現思路基本上分為三步:
獲取user相關特征,user特征可以從數據表里查詢
調用向量模型,獲取user向量。在我們的支持中,模型是部署在EAS上的
和向量召回一樣,通過item向量表進行查詢
配置示例:
"RecallConfs" :[
{
"Name": "online_vector_recall",
"RecallType": "OnlineHologresVectorRecall",
"RecallCount": 500,
"UserFeatureConfs": [
{
"FeatureDaoConf": {
"AdapterType": "hologres",
"HologresName": "holo_info",
"FeatureKey": "user:uid",
"UserFeatureKeyName": "userid",
"HologresTableName": "user_all_feature_table",
"UserSelectFields": "*",
"FeatureStore": "user"
},
"Features": []
}
],
"RecallAlgo": "sv_v2_mind",
"HologresVectorConf": {
"HologresName": "holo_info",
"VectorTable": "item_embedding_table",
"VectorEmbeddingField": "item_emb",
"VectorKeyField": "item_id"
}
}
]
字段 | 類型 | 是否必填 | 描述 |
Name | string | 是 | 自定義召回名稱 |
RecallType | string | 是 | 召回類型,固定值OnlineHologresVectorRecall |
RecallCount | int | 是 | 召回數量 |
RecallAlgo | string | 是 | 調用的向量模型名稱,需要在AlgoConfs里配置,具體配置參考算法配置。 |
UserFeatureConfs:
字段 | 類型 | 是否必填 | 描述 |
AdapterType | string | 是 | 數據源的類型,取值hologres |
HologresName | string | 是 | 在數據源配置(HologresConfs)中配置好的holo的自定義名稱,如數據源配置中的holo_info |
FeatureKey | string | 是 | 這里為引擎中user_id的來源,user:uid代表user中的uid特征 |
UserFeatureKeyName | string | 是 | user特征表中的主鍵字段 |
HologresTableName | string | 是 | user特征表 |
UserSelectFields | string | 是 | 要選擇哪些特征,支持"*"的寫法,也可以 "f1,f2...."逗號分隔的寫法 |
FeatureStore | string | 是 | 在引擎中特征存儲的位置,枚舉值:user/item |
HologresVectorConf:
字段 | 類型 | 是否必填 | 描述 |
HologresName | string | 是 | 在數據源配置(HologresConfs)中配置好的holo的自定義名稱,如數據源配置中的holo_info |
VectorTable | string | 是 | holo中item向量表的表名 |
VectorEmbeddingField | string | 是 | item向量表中存儲向量的字段 |
VectorKeyField | string | 是 | item向量表中的主鍵字段 |
模型sv_v2_mind在AlgoConfs里定義如下
{
"AlgoConfs": [
{
"Name": "sv_v2_mind",
"Type": "EAS",
"EasConf": {
"Processor": "EasyRec",
"Timeout": 100,
"ResponseFuncName": "easyrecUserEmbResponseFunc",
"Url": "http://xxx.vpc.cn-beijing.pai-eas.aliyuncs.com/api/predict/sv_v2_mind",
"Auth": "xxx"
}
}
]
}
和排序模型的配置是一樣的,不同點是ResponseFuncName需要固定為easyrecUserEmbResponseFunc
U2I召回
根據user id來找到對應的item列表。這里的表定義是約定好的
u2i 表
字段 | 類型 | 描述 |
user_id | string | 用戶id |
item_ids | string | item id列表,支持格式:item_id1,item_id2,item_id3..... 或 item_id1:recall_id1,item_id2:recall_id2..... 或 item_id1:recall_id1:score1,item_id2:recall_id2:score2..... |
hologres
配置示例:
"RecallConfs" :[
{
"Name": "user2item_recall",
"RecallType": "UserCustomRecall",
"RecallCount": 500,
"DaoConf" :{
"AdapterType": "hologres",
"HologresName": "holo_info",
"HologresTableName": "user_item_table"
}
}
]
字段 | 類型 | 是否必填 | 描述 |
Name | string | 是 | 自定義召回名稱 |
RecallType | string | 是 | 召回類型,固定值UserCustomRecall |
RecallCount | int | 是 | 召回數量 |
DaoConf | json object | 是 | Dao定義 |
AdapterType | string | 是 | 數據源類型,取值hologres |
HologresName | string | 在數據源配置(HologresConfs)中配置好的holo的自定義名稱,如數據源配置中的holo_info | |
HologresTableName | string | 是 | 數據表名稱 |
OTS(Tablestore)
配置示例:
"RecallConfs" :[
{
"Name": "user2item_recall",
"RecallType": "UserCustomRecall",
"RecallCount": 500,
"DaoConf" :{
"AdapterType": "tablestore",
"TableStoreName": "ots_info",
"TableStoreTableName": "user_item_table"
}
}
]
字段 | 類型 | 是否必填 | 描述 |
Name | string | 是 | 自定義召回名稱 |
RecallType | string | 是 | 召回類型,固定值UserCustomRecall |
RecallCount | int | 是 | 召回數量 |
DaoConf | json object | 是 | Dao定義 |
AdapterType | string | 是 | 數據源類型,取值tablestore |
TableStoreName | string | 在數據源配置(TableStoreConfs)中配置好的 tablestore的自定義名稱,如數據源配置中的tablestore_info | |
TableStoreTableName | string | 是 | 數據表名稱 |
Redis
配置示例:
"RecallConfs" :[
{
"Name": "user2item_recall",
"RecallType": "UserCustomRecall",
"RecallCount": 500,
"DaoConf" :{
"AdapterType": "redis",
"RedisName": "redis_info",
"RedisPrefix": ""
}
}
]
字段 | 類型 | 是否必填 | 描述 |
Name | string | 是 | 自定義召回名稱 |
RecallType | string | 是 | 召回類型,固定值UserCustomRecall |
RecallCount | int | 是 | 召回數量 |
DaoConf | json object | 是 | Dao定義 |
AdapterType | string | 是 | 數據源類型,取值redis |
RedisName | string | 在數據源配置(RedisConfs)中配置好的Redis的自定義名稱,如數據源配置中的redis_info | |
RedisPrefix | string | 是 | U2I數據的前綴,通過RedisPrefix + uid構造key獲取 |
圖召回(GraphRecall)
圖召回也屬于U2I召回的一種。通過GraphCompute圖數據庫進行召回。GraphCompute文檔參考概覽。
配置示例:
"RecallConfs" :[
{
"Name": "graph_recall",
"RecallType": "GraphRecall",
"RecallCount": 500,
"GraphConf": {
"GraphName": "graph_test",
"ItemId": "item_id",
"QueryString": "g(\"test\").V(\"$1\").hasLabel(\"user\").outE().inV()",
"Params": ["user.uid"]
}
}
]
GraphConf:
字段 | 類型 | 是否必填 | 描述 |
Name | string | 是 | 自定義召回名稱 |
RecallType | string | 是 | 召回類型,固定值GraphRecall |
RecallCount | int | 是 | 召回數量 |
GraphName | string | 是 | 在數據源配置(GraphConfs)中配置好的graph的自定義名稱,如數據源配置中的graph_info |
ItemId | string | 是 | graph返回結果中,item的主鍵字段 |
QueryString | string | 是 | 圖召回的查詢語句,其中$1為占位符,需要從Params里面取,詳細語法可以參考Gremlin查詢語法。 |
Params | string | 是 | 填充參數的來源。具體格式如:
|
用戶分組熱門召回(UserGroupHotRecall)
分組熱門召回的表的格式也是約定好的
group_hot_table
表字段 | 類型 | 描述 |
trigger_id | string | trigger信息,多個特征組裝 |
item_ids | string | item id 列表,支持格式:item_id1,item_id2,item_id3..... 或 item_id1:recall_id1,item_id2:recall_id2..... 或 item_id1:recall_id1:score1,item_id2:recall_id2:score2..... |
按照用戶特征和context信息(例如地域、機型等)組裝trigger_id
按照順序將特征用下劃線(_)拼接為trigger_id
特征值為空對應 "NULL"
包含 Boundaries 字段的特征需要進行離散化(左開,右閉區間),比如年齡 [20, 30, 40, 50] --> trigger對應 <=20, 20-30, 30-40,40-50, >50
用戶年齡23,對應"20-30"
用戶年齡空,對應"NULL"
用戶年齡60,對應">50"
用戶年齡19,對應"<=20"
hologres表示例:
此處使用性別、年齡、機型三個特征
trigger_id | item_ids |
Male_<=20_IOS | item_id1::score1,item_id2::score2....... |
Famale_20-30_Android | item_id4::score4,item_id5::score5....... |
...... | ....... |
配置示例:
"RecallConfs" :[
{
"Name":"user_group_hot_recall",
"RecallType": "UserGroupHotRecall",
"RecallCount" :500,
"Triggers": [
{
"TriggerKey": "gender"
},
{
"TriggerKey": "age",
"Boundaries": [20,30,40,50]
},
{
"TriggerKey": "os"
}
],
"DaoConf":{
"AdapterType": "hologres",
"HologresName": "holo_info",
"HologresTableName": "group_hotness_table"
}
}
]
字段 | 類型 | 是否必填 | 描述 |
Name | string | 是 | 自定義召回名稱 |
RecallType | string | 是 | 召回類型,固定值UserGroupHotRecall |
RecallCount | int | 是 | 召回數量 |
Triggers | json array | 是 | 構造trigger_id的具體信息 |
| string | 是 | 從user的特征里獲取tigger值 |
| json int array | 否 | 字段的邊界值范圍 |
DaoConf | json object | 是 | Dao定義 |
| string | 是 | 數據源類型,取值hologres |
| string | 在數據源配置(HologresConfs)中配置好的holo 的自定義名稱,如數據源配置中的holo_info | |
| string | 是 | 數據表名稱 |
全局熱門召回(UserGlobalHotRecall)
全局熱門召回的表schema和分組召回的表schema是相同的,只是全局熱門召回表中只有一條數據,而且 trigger_id = -1
hologres
配置示例:
"RecallConfs" :[
{
"Name":"UserGlobalHotRecall",
"RecallType": "UserGlobalHotRecall",
"RecallCount" :500,
"DaoConf":{
"AdapterType": "hologres",
"HologresName": "holo_info",
"HologresTableName": "global_hotness_table"
}
}
]
OTS(Tablestore)
配置示例:
"RecallConfs" :[
{
"Name":"UserGlobalHotRecall",
"RecallType": "UserGlobalHotRecall",
"RecallCount" :500,
"DaoConf":{
"AdapterType": "tablestore",
"TableStoreName": "ots_info",
"TableStoreTableName": "global_hotness_recall"
}
}
]
字段 | 類型 | 是否必填 | 描述 |
Name | string | 是 | 自定義召回名稱 |
RecallType | string | 是 | 召回類型,固定值UserGlobalHotRecall |
RecallCount | int | 是 | 召回數量 |
DaoConf | json object | 是 | Dao定義 |
AdapterType | string | 是 | 數據源類型,取值tablestore |
TableStoreName | string | 在數據源配置(TableStoreConfs)中配置好的 tablestore的自定義名稱,如數據源配置中的tablestore_info | |
TableStoreTableName | string | 是 | 數據表名稱 |
冷啟動召回(ColdStartRecall)
查詢item表,根據條件或者時間進行過濾,查詢出符合規則的候選集
hologres
"RecallConfs" :[
{
"Name": "AllLiveItemRecall",
"RecallType": "ColdStartRecall",
"RecallCount": 3000,
"ColdStartDaoConf": {
"AdapterType": "hologres",
"HologresName": "holo_info",
"HologresTableName": "item_status_table",
"WhereClause": "islist_status=1",
"PrimaryKey": "\"item_id\"",
"TimeInterval": 0
}
}
]
ColdStartDaoConf:
字段 | 類型 | 是否必填 | 描述 |
Name | string | 是 | 自定義召回名稱 |
RecallType | string | 是 | 召回類型,固定值ColdStartRecall |
RecallCount | int | 是 | 召回數量 |
ColdStartDaoConf | json object | 是 | 冷啟動數據定義 |
AdapterType | string | 是 | 數據源的類型,取值hologres等 |
HologresName | string | 是 | 在數據源配置(HologresConfs)中配置好的holo的自定義名稱,如數據源配置中的holo_info |
HologresTableName | string | 是 | holo中的冷啟動召回表的表名 |
WhereClause | string | 否 | 過濾條件, 如果需要時間過濾,使用${time}。 比如根據創建時間, create_time > ${time} |
PrimaryKey | string | 是 | 表的主鍵 |
TimeInterval | int | 否 | 根據時間差,計算${time}時間值。 ${time} = 當前時間- TimeInterval |
如何使用
召回的使用位置對應配置總覽中的SceneConfs,SceneConfs是一個Map[string]object結構,可以分場景的使用召回,配置如下
"SceneConfs": {
"scene_name": {
"default": {
"RecallNames": [
"collaborative_filter"
]
}
}
}
scene_name需要替換為自己的場景名。
default為目錄,這里保持默認即可。
RecallNames是一個[]string,值為召回配置中的自定義名稱。