全部產品
Search
文件中心

Artificial Intelligence Recommendation:如何用PAI-Rec建設一個詳情頁相關推薦情境

更新時間:Jul 13, 2024

在使用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"
        }
    ]
}