Attentional Factorization Machines: Learning the Weight of Feature Interactions via Attention Networks

Jun Xiao, Hao Ye, Xiangnan He, Hanwang Zhang, Fei Wu, Tat-Seng Chua

TL;DR

This paper introduces Attentional Factorization Machines (AFM), a novel model that enhances Factorization Machines (FMs) by learning the importance of feature interactions using a neural attention mechanism. AFM significantly improves prediction accuracy by dynamically weighting feature interactions, leading to better performance and increased interpretability compared to existing methods.

What Problem Does This Paper Address?

Traditional machine learning models often struggle with sparse data, where the number of features is large but only a few are non-zero for any given instance. Factorization Machines (FMs) were developed to address this by modeling pairwise feature interactions, going beyond simple linear models. However, FMs treat all feature interactions equally, which can be problematic because not all interactions are equally useful. Interactions involving less relevant features can introduce noise and degrade performance. This paper tackles the challenge of how to effectively learn and leverage the varying importance of different feature interactions for more accurate predictions.

Methods

The core innovation of this paper is the Attentional Factorization Machine (AFM). AFM builds upon the foundation of FMs by incorporating a neural attention mechanism. Here's how it works:

  • Input and Embedding Layer: Similar to FMs, AFM takes sparse input features and embeds each non-zero feature into a dense vector.
  • Pair-wise Interaction Layer: This layer computes the element-wise product of the embedding vectors for each pair of features, similar to how FMs model interactions. This results in a set of "interacted vectors."
  • Attention-based Pooling Layer: This is the key novelty. Instead of simply summing up all the interacted vectors (as in standard FMs), AFM uses an attention network to learn a weight for each interacted vector. This weight, called the "attention score," represents the importance of that specific feature interaction. The attention network is a small neural network that takes the interacted vector as input and outputs the attention score.
  • Prediction Score: The final prediction is a weighted sum of the interacted vectors, where the weights are the learned attention scores. This allows the model to focus on more important interactions and downplay less relevant ones.

To prevent overfitting, AFM employs dropout on the pair-wise interaction layer and L2 regularization on the attention network.

Datasets

The authors evaluated AFM on two publicly available datasets:

  • Frappe: Used for context-aware recommendation, containing app usage logs with categorical context variables.
  • MovieLens: Used for personalized tag recommendation, containing user-movie-tag applications.

For both datasets, the data was converted into sparse feature vectors using one-hot encoding. Negative sampling was used to create training instances for a binary classification-like setup.

Key Insights and Ideas

  • Not all feature interactions are created equal: The fundamental insight is that simply modeling all interactions with equal weight is suboptimal. Some interactions are much more predictive than others.
  • Attention as a weighting mechanism: The paper demonstrates that a neural attention mechanism can effectively learn these varying importances, allowing the model to dynamically focus on relevant feature interactions.
  • Improved interpretability: By learning attention scores, AFM provides insights into which feature interactions are most influential, making the model more transparent than black-box deep learning methods.
  • Simplicity and effectiveness: AFM achieves state-of-the-art results with a relatively simple architecture, outperforming more complex deep learning models.

Key Results

  • Performance Improvement: AFM consistently outperformed standard FM and LibFM by a significant margin. On the Frappe dataset, it achieved an 8.6% relative improvement over FM.
  • State-of-the-Art: AFM surpassed the performance of advanced deep learning methods like Wide&Deep and DeepCross, often with fewer model parameters.
  • Hyperparameter Sensitivity: The paper found that dropout on the interaction layer and regularization on the attention network were crucial for preventing overfitting and improving generalization.
  • Interpretability: Micro-level analysis showed that AFM correctly assigned higher attention scores to more important feature interactions (e.g., item-tag interactions in MovieLens), leading to reduced prediction errors compared to FM.

Limitations and Future Work

  • Computational Complexity: The paper acknowledges that AFM's complexity is quadratic to the number of non-zero features, which can be a limitation for very large-scale sparse datasets.
  • Future Directions: The authors suggest exploring deeper versions of AFM (stacking more layers), improving learning efficiency (e.g., using hashing or data sampling techniques), and extending AFM to semi-supervised and multi-view learning scenarios. They also propose applying AFM to other domains like text and multimedia content analysis.

Summary updated

BibTeX
@inproceedings{xiao2017attentional,
  author = {Jun Xiao and Hao Ye and Xiangnan He and Hanwang Zhang and Fei Wu and Tat-Seng Chua},
  title = {{Attentional Factorization Machines: Learning the Weight of Feature Interactions via Attention Networks}},
  booktitle = {International Joint Conference on Artificial Intelligence},
  year = {2017},
  doi = {10.24963/ijcai.2017/435},
}
Figure