基于RNN的序列化推薦系統(tǒng)總結(jié)
作者 | 陽(yáng)光明媚
1. Session-based Recommendations with Recurrent Neural Networks
Session-based Recommendations with Recurrent Neural Networks
本文首次將RNN引入了用戶序列行為的建模,并取得了顯著的效果提升。
解決的關(guān)鍵問(wèn)題:
為了使得推薦系統(tǒng)能夠?qū)W習(xí)用戶的序列決策數(shù)據(jù),引入一個(gè)排序損失函數(shù),并用RNN模型來(lái)建模稀疏的序列決策數(shù)據(jù)。
挑戰(zhàn):
在序列化推薦的每一步,待選的物品數(shù)目巨大,在萬(wàn)到十萬(wàn)級(jí)別 點(diǎn)擊流數(shù)據(jù)量大 關(guān)心模型對(duì)用戶可能感興趣的top物品的預(yù)測(cè)能力
模型結(jié)構(gòu)與算法細(xì)節(jié):

Session-parallel mini-batches

Sampling on the output
Ranking loss
Pointwise排序估計(jì)彼此獨(dú)立的項(xiàng)目的得分或排名,損失的定義方式應(yīng)使相關(guān)項(xiàng)目的排名較。 Pairwise排序比較一個(gè)正項(xiàng)目和一個(gè)負(fù)項(xiàng)目的得分或成對(duì)的排名,損失強(qiáng)制要求正項(xiàng)目的排名應(yīng)低于負(fù)項(xiàng)目的排名。 Listwise排序使用所有項(xiàng)目的分?jǐn)?shù)和等級(jí),并將它們與完美順序進(jìn)行比較。由于它包括排序,通常計(jì)算成本更高,因此不經(jīng)常使用。此外,如果只有一個(gè)相關(guān)的項(xiàng)目-在我們的案例中-listwise排序可以通過(guò)pairwise排序解決。

論文的模型部分到這里就結(jié)束了,下面看一下執(zhí)行細(xì)節(jié)與實(shí)驗(yàn)部分
代碼地址:
https://github.com/yhs968/pyGRU4REC
用GRU對(duì)輸入建模:
# reset the hidden states if some sessions have just terminated
hidden = reset_hidden(hidden, mask).detach()
# Go through the GRU layer
logit, hidden = self.gru(input, target, hidden)
# Output sampling
logit_sampled = logit[:, target.view(-1)]
# Calculate the mini-batch loss
loss = self.loss_fn(logit_sampled)Top1 Loss的計(jì)算:
def TOP1Loss(logit):
"""
Args:
logit (BxB): Variable that stores the logits for the items in the session-parallel mini-batch.
Negative samples for a specific item are drawn from the other items in the
session-parallel minibatch, as mentioned in the original GRU4REC paper.
The first dimension corresponds to the batches, and the second dimension
corresponds to sampled number of items to evaluate.
"""
# differences between the item scores
diff = -(logit.diag().view(-1, 1).expand_as(logit) - logit)
# final loss
loss = F.sigmoid(diff).mean() + F.sigmoid(logit ** 2).mean()
return loss
一個(gè)正確物品如果被排到了20名開(kāi)外,記為0分。
baseline選擇了基于流行度的推薦,和基于物品相似度的推薦:

實(shí)驗(yàn)效果部分,可以看到提升非常顯著:

Parallel recurrent neural network architectures for feature-rich session-based recommendations

Simultaneous:所有參數(shù)同時(shí)進(jìn)行訓(xùn)練,用作baseline。 Alternating:每個(gè)epoch只訓(xùn)練一個(gè)特征的網(wǎng)絡(luò),其他特征對(duì)應(yīng)的網(wǎng)絡(luò)參數(shù)固定,循環(huán)進(jìn)行,例如:第一次訓(xùn)練ID網(wǎng)絡(luò),第二次圖像網(wǎng)絡(luò),第三次ID網(wǎng)絡(luò)....... Residual:每個(gè)網(wǎng)絡(luò)分支依次訓(xùn)練,但是不會(huì)循環(huán),每個(gè)網(wǎng)絡(luò)分支的單次訓(xùn)練長(zhǎng)度比Alternating要長(zhǎng),比如ID網(wǎng)絡(luò)訓(xùn)練10個(gè)epoch,接著feature網(wǎng)絡(luò)基于前面ID網(wǎng)絡(luò)的參差訓(xùn)練10個(gè)epoch。每個(gè)網(wǎng)絡(luò)分支基于之前訓(xùn)練過(guò)的網(wǎng)絡(luò)分支的residual error的ensemble進(jìn)行訓(xùn)練。 Interleaving:對(duì)于每個(gè)mini-batch,在網(wǎng)絡(luò)分支間交替進(jìn)行如下訓(xùn)練:第一個(gè)子網(wǎng)絡(luò)正常訓(xùn)練,第二個(gè)子網(wǎng)絡(luò)基于當(dāng)前mini-batch在當(dāng)前網(wǎng)絡(luò)的殘差訓(xùn)練。更為頻繁的交替訓(xùn)練能使得網(wǎng)絡(luò)之間的訓(xùn)練更為平衡,且這樣做沒(méi)有了同步訓(xùn)練的缺點(diǎn)。


評(píng)論
圖片
表情
