ATRank: An Attention-Based User Behavior Modeling Framework for Recommendation
論文地址:https://arxiv.org/pdf/1711.06632.pdf
1. Introduction
- 正如單詞可以由上下文表示一樣,一個用戶也可以由他/她的歷史行爲來表徵
- 用戶行爲通常構成一個與時間相關的序列(a sequence over the timeline)
- RNN/CNN被引入來encode behavior sequence,但是 both the basic RNN and CNN encoders suffer from the
problem that the fixed-size encoding vector may not support both short and long sequences well- 即使使用LSTM或者GRU,RNN 也難以對 long-term dependencies 建模 ,且無法並行
- CNN可以並行,但是任意兩個位置的behavior之間的interaction paths最長爲, 爲卷積核的大小, 爲用戶行爲的數量
- attention被引入,在decode時能夠給予不同的行爲不同的權重
- However, we show that the one-dimensional attention score between any two vectors may neutralize their relationships in different semantic spaces
- attention的機制如下:
- 的每個元素都使用相同的權重 ,因此對 的不同語義並不能能夠做出區分
- 此外,用戶的行爲是異質的(heterogeneous),非常靈活的,因此很難去建模
- 以電商推薦系統舉例,用戶可能會瀏覽/點擊/收藏商品(browse/click/mark items)、接收/使用優惠券(receive/use coupons)、點擊廣告(click ads)、搜索關鍵詞(search keywords ),寫評論(write down reviews)、看商鋪的視頻或者直播等,每一種行爲都反映了用戶的某一方面的特徵,對於構建全方位的用戶模型都是非常有幫助的
- RNN/CNN被引入來encode behavior sequence,但是 both the basic RNN and CNN encoders suffer from the
2. Self-Attention Based Behavior Modeling Framework
用戶行爲被表示爲一個三元組:
- 表示行爲的類型 (behavior type),比如點擊/收藏/加購、領取/使用
- 表示行爲的對象 (the object the behavior acts on),比如商品、優惠券、搜索詞等
- 表示行爲發生的時間
- 用戶的行爲序列被表示爲
模型分爲如下幾塊:
- Raw Feature Spaces
- Behavior Embedding Spaces
- Latent Semantic Spaces
2.1 Raw Feature Spaces
-
首先會根據行爲的對象 將 劃分至不同的組 ,
,例如劃分爲商品行爲,優惠券行爲,關鍵字行爲等等 -
在每個 內部,object的空間相同,之後可以使用 group-specific 的神經網絡去獲得 behavior embeddings
-
舉例:對商品的行爲組成第一組,優惠券行爲是,搜索相關行爲,注意每組裏面行爲的個數不一定相同
2.2 Behavior Embedding Spaces
- 對於在 中的某個行爲 ,會將 分別轉化爲嵌入式向量:
- 對於時間 會將其離散化:計算行爲發生時間距當前時間的間隔,然後按照如下區間將時間間隔離散化,之後再進行embedding:
- behavior embedding spaces的輸出是一組向量,其中 ,表示所有屬於第 組的 behavior embedding 的 concat:
- 具體的計算過程示例如下:
- 有以下兩點注意事項:
- 每組embedding的維度是不一樣的,因爲:
- 每個用戶在不同組別下行爲的個數不一樣
- 不同組別embedding size不一定一樣,比如商品行爲一般會比搜索行爲反映更多的信息,所以會有更長的embedding size
- 不同bg的objects如果有相同的特徵,embedding 是跨組共享的,比如 shop id, category id 可以由 item, coupon組共享;但是關於時間的embedding不共享,因爲時間對於不同組行爲的影響不同。
- 每組embedding的維度是不一樣的,因爲:
2.3 Latent Semantic Spaces
- 由於不同組的embedding size不一樣,因此首先通過 將 映射到一個相同的維度 ,若一個user行爲的個數爲 , 的維度則爲
- 之後再利用 將 映射到不同的語義空間, 的維度爲
2.4 Self-Attention Layer
self-attention layer 用於 capture 不同語義空間的內在聯繫。
第 個語義空間的 attention score matrix 爲:
attention score function 爲:
attention vectors of space are:
- 是另外一個將 映射到第 個語義空間的映射函數(本文中爲一個單層的全連接加relu激活)
然後將 concat 起來,再經過一個只有一個hidden layer的前饋神經網絡:
最後會依次經過 drop out, residual connections 和 layer normalization。
參考資料
阿里北大 ATRank 論文圖解
李宏毅Transformer筆記附代碼
github: Transformer代碼
github: ATRank代碼