OpenViSTAI · Agents · Blockchain · Crypto
Menu
AI Models

Attentional Factorization Machine

Attentional Factorization Machine is an open-source Python repository containing TensorFlow implementations of Attentional Factorization Machines and standard Factorization Machines. It trains models from LibFM-format feature vectors, saves trained models, and evaluates them against test data, with a MovieLens tag-recommendation example.

Independent OpenViST project profile, based on linked sources.

Attentional Factorization Machine — Reproducing the repository's MovieLens personalized tag-recommendation example
OpenViST project illustration. See the linked sources for product details.
Understand the project

Practical overview

When it fits

Use it when you can prepare data in the documented LibFM feature-vector format and want to study or adapt the included FM and AFM training and evaluation workflow.

Who it is for

  • Researchers studying attention-weighted feature interactions in recommendation models.
  • Developers seeking an example implementation of factorization-machine training and evaluation.

Documented uses

  • Train an FM model and use its weights to initialize an AFM model.
  • Compare FM and AFM on feature-vector recommendation data.
  • Evaluate saved models against held-out test data.
Before you choose

Requirements & limits

The repository is public and described by its authors as a released TensorFlow implementation.

  • The documented environment specifies TensorFlow 1.0.1, NumPy and scikit-learn.
  • The examples require train, validation and test files in the expected LibFM format and directory layout.
  • The README describes RMSE as the optimization target for its stated regression and classification support.

Check current requirements in the official documentation. Source-based guidance does not mean OpenViST has run or independently tested this project.

Source-based practical guide

Train and evaluate the MovieLens tag recommendation models

Use the documented MovieLens ml-tag files to train FM and AFM models, then evaluate the saved models.

Before you start

  • TensorFlow 1.0.1, NumPy and scikit-learn.
  • MovieLens data prepared in LibFM format as ml-tag.train.libfm, ml-tag.validation.libfm and ml-tag.test.libfm under data/ml-tag.
  • The repository's code directory containing AFM.py, FM.py and LoadData.py.

Steps

  1. From the code directory, run the README's FM training command with dataset ml-tag, 100 epochs, pretrain -1, batch size 4096, hidden factor 256, learning rate 0.01 and keep 0.7.

  2. Run the README's AFM training command with dataset ml-tag, 100 epochs, pretrain 1, batch size 4096, hidden factor [8,256], keep [1.0,0.5], attention regularization 2.0 and learning rate 0.1.

  3. After training, run FM.py and AFM.py with the documented ml-tag parameters and --process evaluate to evaluate the pretrained models on the test data.

Expected outcome

The documented workflow trains and saves FM and AFM models, then evaluates each saved model against the test dataset.

Guide limitations

  • The commands and parameter values are the README's MovieLens ml-tag example, not a general configuration for other datasets.
  • The implementation lists TensorFlow 1.0.1, NumPy and scikit-learn as its environment; compatibility with other versions is not established here.
Evidence and transparency

Sources & review

Source record details
Source availability
Active
Sources checked
15 November 2026
Original website title
hexiangnan/attentional_factorization_machine · Official homepage title · retained in its source language