All models

afm

A factorization machine that weights each pairwise feature interaction with a learned attention score.

Tabular and recommender · 175 operations Checked

100%

Showing the top corner; full diagram not loaded yetShowing a small copy; full diagram not loaded yetLarge diagram, not loaded yet

Open SVG

Loading diagram (9 KB)

Open in a new tab

Click or tap a spot to read it up close. Scroll or drag inside the diagram to move through it. Zoom with + and − or Ctrl and scroll. Press 0 for the whole graph. Swipe inside the diagram to move through it. Use + and − to zoom.

At a glance

Parameters
11.4K
Operations
175
Framework
PyTorch
Recurrent
No
Published
IJCAI 2017
Cited by
943 (as of 22 October 2026)
Authors
Jun Xiao, Hao Ye, Xiangnan He and others
License
Apache-2.0
Checked
Passed: the trace was replayed operation by operation and matched the model's own output for this input.

Files

The diagram is a drawing of a TorchLens trace of the source code. It contains no code or weights.

Details
Stable ID
m3480
Graph hash
ae54ec3b05e804d162c17b0b42335a9263ba5a579b659adb97f26b8ffbfd19b9
Skeleton hash
31abd64f953372077dab1589a0c993dfdb3ddd8a47a3e3f476a56c6367a959db
Architecture hash
ee8f92a97c8af3ee035724a4341262856c3bb1062d0753f9b4348063c5b4cbcc
Diagram SHA-256
2efee3032f62effe80fcd3c12170610372b079faed374b3213c07779320611ac
TorchLens version
2.36.0
Renderer
graphviz 2.43.0+pyvips 3.2.0+libvips 8.18.7+render-opts@06c1f0d3
Check
Forward pass replayed in PyTorch

What it is

The Attentional Factorization Machine (AFM) is a variant of the Factorization Machine (FM), a supervised learning approach that extends linear regression with second-order feature interactions. The paper's criticism of FM is that it gives all feature interactions the same weight, although not all of them are equally useful and predictive. AFM instead learns the importance of each feature interaction from data through a neural attention network.

On two real-world datasets, the paper reports that on a regression task AFM improves on FM by 8.6% in relative terms. It also reports that AFM outperforms the deep learning methods Wide&Deep and DeepCross with a much simpler structure and fewer model parameters.

In the DeepCTR-Torch implementation, the attentional interaction term is added to the output of a linear model, and with attention switched off the model is the same as a standard Factorization Machine. The authors' own code uses the same input format as the LibFM toolkit, and its instructions use MovieLens tag data converted by one-hot encoding into 90,445 binary features.

Key idea. AFM improves the Factorization Machine by learning the importance of each feature interaction from data through a neural attention network.

  • afm
  • attentional factorization machine
  • attentional factorization machines
  • factorization machine
  • feature interactions
  • attention network
  • deepctr-torch
  • ctr prediction
  • recommendation
  • sparse features

AI-written summary, based on the paper and checked automatically against it; not reviewed by a person. Corrections welcome.

Cite the paper

@misc{xiao2017attentionalfactorizationmachineslearning,
      title={Attentional Factorization Machines: Learning the Weight of Feature Interactions via Attention Networks}, 
      author={Jun Xiao and Hao Ye and Xiangnan He and Hanwang Zhang and Fei Wu and Tat-Seng Chua},
      year={2017},
      eprint={1708.04617},
      archivePrefix={arXiv},
      primaryClass={cs.LG},
      url={https://arxiv.org/abs/1708.04617}, 
}