Attentional Factorization Machines: Learning the Weight of Feature Interactions via Attention Networks
想法:FM中的所有特征交互权重都是一致的,结合现实中的数据情况,不同的特征交互对于最终结果的贡献是不同的,有一些特征交互与最终结果无关,可以认为是噪声,对最终结果的预测起负面作用。因此考虑加上一个attention机制,并将新模型命名为AFM。
attention机制带来的两个好处:
•带来了更好的预测效果。
•提供了一种方式来了解哪些特征交互对最终预测结果的贡献更大。
Attentional Factorization Machines

上图即为AFM的模型结构(忽略了线性回归部分)。
前两层把稀疏的input映射成稠密的embedding,需要注意的是,这里和NFM那篇中一样,不是简单的查表,而是embedding乘上特征x的数值。
Pair-wise Interaction Layer
在pair-wise Interaction Layer把m个vector扩展成m*(m-1)/2个interacted vector,交互操作使用的是element-wise product(逐元素乘)。
令X表示input中的非0元素,embedding layer的output为

可以把pair-wise Interaction Layer的输出表示为一个vector的集合

○表示逐元素乘

通过定义pair-wise Interaction Layer,我们能够用神经网络结构来表达FM模型。首先对fP I(E)的结果做sum pooling操作,然后使用一个全连接层映射到最终的prediction score上

p和b分别表示全连接层的weight和bias。当p=1, b=0时,即为FM模型(线性部分被省略)。
NFM可以看作是在pair-wise Interaction Layer上使用了sum pooling操作。
Attention-based Pooling Layer
考虑到FM模型的不足之处,本文提出在特征交互上加attention机制来对interacted vector进行带权求和。

aij表示attention score,可以理解为特征交互对于最终预测的重要性。估计aij比较直接的方法是直接通过最小化预测误差来进行学习,这在技术上似乎也是可行的。然而这样做的问题在于,对于一些在训练集中从来没有共同出现的特征组合,它们的attention score没有办法被学习到。为了解决这一问题,使用一个MLP来学习attention score,这一部分作者称之为attention network。
attention network的输入为两个特征的interacted vector,具体的

W(t*k维),b(t维),h(t维)为模型参数,t表示attention network中hidden layer的size,作者称之为attention factor。之后attention score通过softmax来做归一化。
attention-based pooling layer的输出是一个k维向量,然后将其映射到最终的prediction score。
AFM模型的总体式子如下

模型参数有

Learning
AFM可以用于做分类、回归等任务。用于回归时,目标函数可以使用平方误差

对于二分类问题,可以最小化log loss。
本文重点关注回归问题,使用SGD最小化目标函数。
Overfitting Prevention
防止过拟合,本文考虑使用dropout和L2正则。
attention network部分是一个单层的MLP,对这里的权重矩阵W加上L2正则来防止过拟合。
最终的目标函数为

作者指出在attention network上不使用dropout,原因在于作者在实验中发现在interaction layer和attention network上同时使用dropout会造成稳定性问题,使模型的表现退化。
网友评论