论文《Self-Attentive Sequential Recommendation》

论文地址:https://arxiv.org/pdf/1808.09781.pdf

Self-Attentive Sequential Recommendation

SASRec是较早应用Self-Attention到序列推荐中的模型,目前作为序列SOTA的baseline,应用十分广泛。在工业界也是很早就大规模落地,取得的效果也是非常显著,在SASRec基础上面进行改进的工作很多,包括后面引入对比学习,加入其他side info,以及加入双向Transformer结构等等。

摘要

序列模型一般是由马尔科夫链(Markov Chain)或者循环神经网络(RNN)来处理,Markov Chain假设用户的下一个行为由最近一个或者最近几个行为产生,在稀疏数据集上面表现不错。RNN能处理较长的序列,在稠密的序列上面表现不错。基于Self-Attention的SASRec能综合两者的优点,而且性能上面比基于RNN/CNN的要好。

引言

SASRec在稀疏数据集和稠密数据集上表现都不错。基于Self-Attention机制,SASRec能关注到长距离的序列依赖,而且在稀疏数据集上面,能关注到最近的序列,另外,Self-Attention可以并行,效率较高。

方法

符号表示

Embedding Layer

取固定长度的n个序列,论文《Self-Attentive Sequential Recommendation》,如果用户序列长度不够,用padding填充,不过超过了n,就取最近的n个。item的embedding矩阵论文《Self-Attentive Sequential Recommendation》,输入的embedding矩阵论文《Self-Attentive Sequential Recommendation》,这里论文《Self-Attentive Sequential Recommendation》

Positional Embedding

self-attention对位置不感知,需要额外加入位置信息,引入一个待学习的位置矩阵论文《Self-Attentive Sequential Recommendation》,论文也尝试过固定的位置embedding,效果比较差。

Self-Attention Block

论文《Self-Attentive Sequential Recommendation》
论文《Self-Attentive Sequential Recommendation》表示queries,论文《Self-Attentive Sequential Recommendation》表示keys,论文《Self-Attentive Sequential Recommendation》表示values(item embedding表示)。整个式子就是item向量表示的加权和。

Self-Attention Layer

论文《Self-Attentive Sequential Recommendation》
即通过不同的映射投影作为Attention的输入

Causality

预测第t+1个item时仅考虑前面t个item,不能用到后面的item信息,因此需要修改论文《Self-Attentive Sequential Recommendation》论文《Self-Attentive Sequential Recommendation》的连接当论文《Self-Attentive Sequential Recommendation》

Point-Wise Feed-Forward Network

论文《Self-Attentive Sequential Recommendation》
论文《Self-Attentive Sequential Recommendation》论文《Self-Attentive Sequential Recommendation》论文《Self-Attentive Sequential Recommendation》的矩阵

Stacking Self-Attention Blocks

第一个Self block 论文《Self-Attentive Sequential Recommendation》基本聚合了所有item的embedding,堆叠更多的block能学习到更复杂的行为模式。对于第论文《Self-Attentive Sequential Recommendation》个block,定义如下
论文《Self-Attentive Sequential Recommendation》
论文《Self-Attentive Sequential Recommendation》

当网络层级较深时,容易产生几个问题
(1)模型容量增加,容易过拟合
(2)层级深梯度容易消失或者爆炸,训练过程不稳定
(3)模型参数较多,训练耗时也在增加
直接套用Transformer的解决办法,使用残差连接

Residual Connections

将低层的特征直接输入给高层,高层更容易利用低层的信息。
论文《Self-Attentive Sequential Recommendation》
g表示自注意力层或者 feedforward network,先对输入x做LayerNorm,然后对g的输出做Dropout,再和原始输入x相加作为最后的输出。

Layer Normalization

Transformer里面用的是Layer Normalization,而不是Batch Normalization,主要原因是序列任务经常长短不一,而输入是固定维度,不够长的会补0,如果使用BN,会导致数据失真的比较严重,但是LN不存在这个问题,每个样本Normalization是独立的,不受其他样本的影响。
论文《Self-Attentive Sequential Recommendation》
论文《Self-Attentive Sequential Recommendation》论文《Self-Attentive Sequential Recommendation》是待学习的参数

Prediction Layer

堆叠了b个self-attention blocks之后,再加一个MF Layer来预测,
论文《Self-Attentive Sequential Recommendation》
论文《Self-Attentive Sequential Recommendation》表示序列论文《Self-Attentive Sequential Recommendation》的下一个行为item是item 论文《Self-Attentive Sequential Recommendation》的相关性分数
论文《Self-Attentive Sequential Recommendation》 是item embedding矩阵

Shared Item Embedding

出于减少模型大小及避免过拟合的原因,使用单个item embedding矩阵论文《Self-Attentive Sequential Recommendation》
论文《Self-Attentive Sequential Recommendation》

Network Training

将每个用户的序列(论文《Self-Attentive Sequential Recommendation》)从处理成一个固定长度的序列论文《Self-Attentive Sequential Recommendation》,定于论文《Self-Attentive Sequential Recommendation》表示t时刻希望的输出

Complexity Analysis

Space Complexity:论文《Self-Attentive Sequential Recommendation》
Time Complexity:主要是self-attention和the feed forward network的计算论文《Self-Attentive Sequential Recommendation》
但是attention是能够并行计算的,实际这里耗时可以接受

实验

实验回答4个问题:
RQ1:SASRec是不是比包括CNN/RNN的方法好?
RQ2:SASRec不同组件的影响如何?
RQ3:SASRec训练性能如何?
RQ4:attention的权重是否能学到item属性或者位置的有意义的模式?

数据集

3个应用的4个数据集,数据的平台、领域、稀疏性差异显著
Amazon:从Amazon.com.产生的数据集,分成2个数据集‘’Beauty,’ and ‘Games’
Steam:大型在线视频游戏分发平台
MovieLens:很多推荐系统的基线

对比方法

PopRec:流行度推荐,就是热门推荐
Bayesian Personalized Ranking (BPR):

基于一阶马尔科夫链的模型
Factorized Markov Chains (FMC):将item矩阵分解为2个embedding,依靠最近访问的item来推荐
Factorized Personalized Markov Chains (FPMC):结合矩阵分解和一阶马尔科夫链
Translation-based Recommendation (TransRec):每个用户转换成embedding

基于深度学习的模型
GRU4Rec:使用RNN的序列推荐模型
GRU4Rec论文《Self-Attentive Sequential Recommendation》:GRU4Rec,的增强版,使用了不同的loss函数和采用策略
Convolutional Sequence Embeddings (Caser):基于CNN的高阶马尔科夫链

为公平起见, 向量维度论文《Self-Attentive Sequential Recommendation》考虑论文《Self-Attentive Sequential Recommendation》 ,正则参数论文《Self-Attentive Sequential Recommendation》考虑论文《Self-Attentive Sequential Recommendation》在验证集中找到表现最好的参数

实现细节

使用的self-attention block数目为2(论文《Self-Attentive Sequential Recommendation》),使用可学习的位置embedding,优化器是Adam,学习率为0.001,batch_size为128,dropout比例对于MovieLens-1M是0.2,其他是0.5,序列长度MovieLens-1M设置的是200,其他的设置的是50

评估指标

Hit Rate@10和NDCG@10
Hit Rate@10 下一个item在最相似的top10的比例

推荐结果

结果如下表,回答RQ1

拆解分析

回答RQ2:,SASRec不同的组件如何影响

训练性能

从2个 维度评估,一个是训练速度(训练一个epoch需要的时间),另一个是训练收敛需要的时间,所有实验使用了单个GTX-1080 Ti GPU

Visualizing Attention Weights

回答RQ4:attention 权重是否学到了有意义的模式
Attention on Positions:

Attention Between Items:
从数据集中随机抽取2个集合,item的类目分属4种,从热力图上看到相同类目的item聚集在一起,说明模型能够根据item的属性找到相似的item。

文章出处登录后可见!

已经登录?立即刷新

共计人评分,平均

到目前为止还没有投票!成为第一位评论此文章。

(0)
社会演员多的头像社会演员多普通用户
上一篇 2022年5月11日
下一篇 2022年5月11日

相关推荐