如何用PAI-Rec建设一个详情页相关推荐场景

在使用PAI-Rec的推荐算法定制的过程中,我们可以应用召回模型产出的数据用来作为详情页相关推荐的数据。利用用户分组热门召回(UserGroupHotRecall)全局热门召回(UserGlobalHotRecall),作为全局推荐数据的补全数据。也可以使用Spark、Flink等系统中产出i2i和热门数据作为召回数据,只要数据符合PAI-Rec引擎的召回格式即可。

PAI-Rec引擎配置单怎么填写?

召回和过滤逻辑如下:

  • ProductDetailPageEtrecRecall:eTrec协同过滤算法计算得到的i2i相关物品作为第一优先级的推荐结果。

  • GroupHotRecall:分组热门的结果,这里是用物品的类目(category)统计得到的热门排行榜。

  • GlobalHotRecall:全局热门排行榜,当i2i和类目热门的结果都不足的时候,使用全局热门排行榜补全。

  • UserExposureFilter:对该用户过滤已经曝光过的物品。

{

  "RecallConfs": [
    {
      "Name": "ProductDetailPageEtrecRecall",
      "RecallType": "ItemCollaborativeFilterRecall",
      "RecallCount": 50,
      "ItemCollaborativeDaoConf": {
        "AdapterType": "hologres",
        "HologresName": "pairec-holo",
        "Item2ItemTable": "i2i_table"
      }
    },
    {
      "Name":"GroupHotRecall",
      "RecallType": "UserGroupHotRecall",
      "RecallCount" :500,
      "Triggers": [
        {
          "TriggerKey": "category"
        }
      ],
      "DaoConf":{
        "AdapterType": "hologres",
        "HologresName": "holo_info",
        "HologresTableName": "group_hotness_table"
      }
		},
    {
      "Name":"GlobalHotRecall",
      "RecallType": "UserGlobalHotRecall",
      "RecallCount" :500,
      "DaoConf":{
        "AdapterType": "hologres",
        "HologresName": "holo_info",
        "HologresTableName": "global_hotness_table"
    	}
    }
  ],
  "FilterConfs": [
    {
      "Name": "UserExposureFilter",
      "FilterType": "User2ItemExposureFilter",
      "MaxItems": 100,
      "TimeInterval": 7200,
      "WriteLog": true,
      "DaoConf": {
        "AdapterType": "hologres",
        "HologresName": "pairec-holo",
        "HologresTableName": "exposure_history"
      }
    }
  ],
  "SortNames": {
    "default": [
      "ItemRankScore"
    ]
  },
  "FilterNames": {
    "default": [
      "UniqueFilter",
      "UserExposureFilter"
    ]
  },
  "AlgoConfs": [],
  "HologresConfs": {
    "pairec-holo": {
      "DSN": "postgres://{AK}:{SK}@{Host}:{Port}/{DB}?sslmode=disable&connect_timeout=1"
    }
  },
  "KafkaConfs": {},
  "RedisConfs": {},
  "SceneConfs": {
    "product_detail_page": {
      "default": {
        "RecallNames": [
          "ProductDetailPageEtrecRecall"
        ]
      }
    }
  },
  "LogConf": {
    "RetensionDays": 3,
    "DiskSize": 20,
    "LogLevel": "INFO"
  },
  "RankConf": {},
  "FeatureConfs": {}
}

引擎接口如何配置

接口名称

/api/rec/feed

请求参数

参数名称

参数说明

类型

是否必须

用例

uid

用户id

string

“1000079”

item_id

商品id

string

"9237438"

size

获取item数量

integer

10

scene_id

场景id

String

home_feed

features

上下文特征

json map

{“current_detail_item_id”:20, “sex”:”male”}

debug

debug 用,打印更多的日志

bool

true

请求样例

curl -v http://host/api/rec/feed -d '
  {"uid":"76295990", 
  "item_id":"9237438"
  "size":1, 
  "scene_id":"home_feed"}' 

返回数据

{
    "code":200,
    "msg":"success",
    "request_id":"e332fe9c-7d99-45a8-a047-bc7ec33d07f6",
    "size":1,
    "items":[
        {
            "item_id":"3v5RE7417j7R",
            "score":0.0045,
            "retrieve_id":"ProductDetailPageEtrecRecall"
        }
    ]
}