為了幫助用戶全面了解一個推薦場景如何配置引擎配置單,本文以猜你喜歡場景為例介紹召回、過濾、特征加載、精排和重排的基礎配置,以及如何配置在線數據源Hologres和FeatureStore。
{
"HologresConfs": {
"holo_info": {
"DSN": "postgres://${AccessKey}:${AccessSecret}@hgpostcn-cn-xxxx-cn-shanghai-vpc-st.hologres.aliyuncs.com:80/test_db?sslmode=disable&connect_timeout=1"
}
},
"FeatureStoreConfs": {
"fs_info": {
"RegionId": "cn-shanghai",
"AccessId": "${AccessKey}",
"AccessKey": "${AccessSecret}",
"ProjectName": "projectName"
}
},
"RecallConfs": [
{
"Name": "etrec_u2i2i_recall_v1",
"RecallType": "UserCustomRecall",
"RecallCount": 300,
"DaoConf": {
"AdapterType": "hologres",
"HologresName": "holo_info",
"HologresTableName": "home_feed_etrec_u2i2i_score_holo_v1"
}
},
{
"Name": "user_global_hot_recall_v1",
"RecallType": "UserGlobalHotRecall",
"RecallCount": 200,
"DaoConf": {
"AdapterType": "hologres",
"HologresName": "holo_info",
"HologresTableName": "home_feed_global_hot_holo_v1"
}
}
],
"FilterConfs": [
{
"Name": "UserExposureFilter",
"FilterType": "User2ItemExposureFilter",
"MaxItems": 50,
"TimeInterval": 604800,
"WriteLog": true,
"DaoConf": {
"AdapterType": "hologres",
"HologresName": "holo_info",
"HologresTableName": "exposure_history"
}
},
{
"Name": "ItemStateFilter",
"FilterType": "ItemStateFilter",
"ItemStateDaoConf": {
"AdapterType": "hologres",
"HologresName": "holo_info",
"HologresTableName": "item_status_table_v1",
"ItemFieldName": "item_id",
"SelectFields": "is_online"
},
"FilterParams": [
{
"Name": "is_online",
"Type": "int",
"Operator": "equal",
"Value": 1
}
]
}
],
"AlgoConfs": [
{
"Name": "home_feed_dbmtl_v1",
"Type": "EAS",
"EasConf": {
"Processor": "EasyRec",
"ResponseFuncName": "easyrecMutValResponseFunc",
"Url": "http://xxx.vpc.cn-shanghai.pai-eas.aliyuncs.com/api/predict/home_feed_dbmtl_v1",
"EndpointType": "DIRECT",
"Auth": "xxxxx"
}
}
],
"SortConfs": [
{
"Name": "BoostScoreSortByAuthor",
"SortType": "BoostScoreSort",
"Debug": false,
"BoostScoreConditions": [
{
"Conditions": [
{
"Name": "author_status",
"Domain": "item",
"Type": "string",
"Value": "teacher",
"Operator": "equal"
}
],
"Expression": "score * 10"
}
]
}
],
"SortNames": {
"home_feed": [
"BoostScoreSortByAuthor"
]
},
"FilterNames": {
"default": [
"UniqueFilter",
"UserExposureFilter"
]
},
"RankConf": {
"home_feed": {
"RankAlgoList": [
"home_feed_dbmtl_v1"
],
"RankScore": "${home_feed_dbmtl_v1_probs_is_click}+${home_feed_dbmtl_v1_probs_is_collect_like_comment}",
"BatchCount": 100,
"Processor": "EasyRec"
}
},
"FeatureConfs": {
"home_feed": {
"AsynLoadFeature": true,
"FeatureLoadConfs": [
{
"FeatureDaoConf": {
"AdapterType": "hologres",
"HologresName": "holo_info",
"FeatureKey": "user:uid",
"UserFeatureKeyName": "user_id",
"HologresTableName": "user_table_v1_all_feature_v1_online",
"UserSelectFields": "*",
"FeatureStore": "user"
},
"Features": []
},
{
"FeatureDaoConf": {
"AdapterType": "hologres",
"HologresName": "holo_info",
"ItemFeatureKeyName": "item_id",
"FeatureKey": "item:id",
"HologresTableName": "item_table_v1_all_feature_v1_online",
"ItemSelectFields": "item_id,author",
"FeatureStore": "item"
},
"Features": []
}
]
}
},
"SceneConfs": {
"home_feed": {
"default": {
"RecallNames": [
"etrec_u2i2i_recall_v1",
"user_global_hot_recall_v1"
]
}
}
}
}
引擎配置的定義邏輯:先定義召回(RecallConfs)、過濾(FilterConfs)、排序(AlgoConfs)、重排(SortConfs)的配置,然后再在場景中進行引用。如先在FilterConfs中定義過濾配置,配置的名稱為唯一標識符,配置好之后可以在FilterNames中進行引用。召回配置在SceneConfs中引用,排序配置在RankConfs中引用,重排配置在SortNames中引用。home_feed為場景名稱。但是FilterNames中的場景名稱為default,代表如果找不到要走的場景配置,則會走default(默認)。
示例詳細說明如下:
項目 | 說明 |
數據源 | 本案例配置了Hologres和FeatureStore兩種數據源,主要存儲供線上服務使用的數據,如用戶特征和物品特征、熱門召回和i2i召回數據、某個用戶已經看過的物品ID作為曝光過濾的依據等。 如果FeatureStore使用FeatureDB作為線上數據源,需要配置FeatureDB的用戶名(FeatureDBUsername)和密碼(FeatureDBPassword);如果FeatureStore使用其他數據源,則不需配置這兩個參數。兩個數據源中的 |
召回 | 本案例在RecallConfs中配置了兩路召回,分別是U2I召回和全局熱門召回,兩種召回的數據來源于Hologres。不同召回參數說明如下:
|
過濾 | 本案例在FilterConfs中配置了以下兩種過濾方式:
一些參數的解釋:
|
特征加載 | 將user特征和item特征加載到引擎中。其中,user特征參與模型的打分,item特征則多用來進行重排。
|
排序 | 排序服務先在AlgoConfs中進行配置,可以定義多個精排服務。在RankConf中設置某個推薦場景引用AlgoConfs中定義的精排服務,以及打分公式和權重調整,可以設置多個目標預測分加權之后再相加或者相乘的方式。 AlgoConfs:
RankConf:
|
重排 | 本案例在SortConfs中配置了如下兩個重排策略:
配置參數的一些解釋:
|