Level 0: Foundation
★☆☆☆☆ Introductory⏱ 5 minGeneral audience. No mathematics required.Every feature talks to every other feature
A prediction often depends on combinations: this user likes space films, this film suits weekends, engineers like documentaries. Learning a separate number for every combination is hopeless, because most combinations never appear in the data. Factorization machines give each feature, whether a user, a film, a genre, a user group or the time of day, a short vector, and measure how well any two features go together by how much their vectors point the same way. Combinations never seen before still get a sensible estimate.
Real prediction problems mix identifiers (user, item, asset) with attributes and context. FMs handle all of them in one sparse linear-plus-interactions model that trains quickly and copes with cold start. They are a standard baseline for click-through prediction and a useful bridge between classical models and deep recommenders such as DeepFM and two-tower networks.
- 1. In an FM, the interaction weight of two features is…
- 2. An FM with only one-hot user and item features equals…
- 3. FMs can estimate interactions for feature pairs that…
Level 1: Beginner
★★☆☆☆ Basic⏱ 20 minSecondary-school mathematics: arithmetic and elementary algebra.The model and the fast formula by hand
Model (degree 2):
ŷ(x) = w₀ + Σᵢ wᵢxᵢ + Σᵢ<ⱼ ⟨vᵢ, vⱼ⟩ xᵢxⱼ,
with vᵢ ∈ ℝᵏ.
For x with features 0 and 2 active (one-hot), w₀ = 1, w = (0.1, 0.2, 0.3), v₀ = (1, 0) and v₂ = (0.5, 2): ŷ = 1 + 0.4 + ⟨v₀, v₂⟩ = 1 + 0.4 + 0.5 = 1.9.
Matrix factorisation as a special case. With x one-hot over users and items, only one pair is active: ŷ = w₀ + w_user + w_item + ⟨v_user, v_item⟩, which is μ + bᵤ + bᵢ + pᵤ·qᵢ.
The O(nk) identity:
Σᵢ<ⱼ ⟨vᵢ, vⱼ⟩xᵢxⱼ = ½ Σ_f [(Σᵢ vᵢ_f xᵢ)² − Σᵢ vᵢ_f² xᵢ²].
The right-hand side touches each non-zero feature once per factor: O(k · nnz(x)) instead of O(k · nnz²).
Parameters. 1 + n + nk: 1501 for n = 300 features and k = 4, against 44 850 separate pairwise weights for a full quadratic model.
The steps in plain English:
- Encode each example as a sparse vector: one-hot identifiers, categorical attributes, scaled numeric features, normalised multi-hot history.
- Initialise w₀ = mean target, w = 0 and small random V.
- Train by SGD (or ALS or MCMC) on squared or logistic loss, with L2 regularisation on w and V.
- Predict with the O(nk) formula; tune k and λ on validation data.
- 1. The O(nk) identity avoids…
- 2. FM parameter count is…
- 3. With one-hot user and item, how many interaction terms are non-zero?
Level 2: Intermediate
★★★☆☆ Intermediate⏱ 30 minUndergraduate students and practising engineers.Why factorised interactions generalise
Polynomial regression fails on sparse data. A separate weight w_ij is learned only from examples where both i and j are active. For user × item pairs, the test pairs are by definition unseen, so their w_ij are never estimated. FMs share parameters: vᵢ is learned from every example containing i, so ⟨vᵢ, vⱼ⟩ is defined for any pair.
Gradients. ∂ŷ/∂vᵢ_f = xᵢ(Σⱼ vⱼ_f xⱼ) − vᵢ_f xᵢ². The bracketed sum is computed once per example, so an SGD step also costs O(k · nnz).
Side features and cold start. A new user has no learned user vector, but if group, location or device features are active, their vectors interact with item features to give a personalised prediction. As ratings accumulate, the user’s own vector takes over.
Exercise 1:
- the O(nk) formula matched the explicit pairwise sum to 10⁻⁹;
- an FM on one-hot (user, item) features, which is biased MF, reached held-out RMSE 0.470, against 0.940 for predicting the mean (the noise s.d. was 0.4).
# libFM, fastFM, or a few lines of PyTorch:
xv = X @ V # (batch, k)
y_hat = w0 + X @ w + 0.5 * (xv.pow(2) - (X.pow(2) @ V.pow(2))).sum(1)- 1. Why can't polynomial regression predict an unseen user–item pair?
- 2. Side features help cold-start users because…
- 3. An SGD step for an FM costs about…
Level 3: Advanced
★★★★☆ Advanced⏱ 25 minGraduate level, with full derivations and proofs.Theory
Expressiveness. Any symmetric positive semidefinite interaction matrix W can be written VVᵀ for large enough k, so an FM with enough factors can represent any such interaction pattern. Small k imposes a low-rank structure, which is what allows generalisation from sparse data. Higher-order FMs model triples, at greater cost.
Learning. Rendle’s libFM offers SGD, ALS (each parameter has a closed-form update with the others fixed, because ŷ is linear in each single parameter) and MCMC with Gibbs sampling, which integrates over the regularisation hyperparameters automatically.
Extensions.
- Field-aware FMs (FFM, Juan et al., 2016) give each feature a separate vector per field of the other feature, and won several click-prediction competitions.
- DeepFM and xDeepFM add neural components on the shared embeddings.
- Attentional FMs weight interactions.
Interview questions.
- When would you use an FM rather than MF? Whenever there are side features (user or item attributes, context, sequence features) or cold-start entities, or when the target is click-through prediction on sparse categorical data.
- How do FMs relate to deep recommenders? The embedding-plus-dot-product interaction is the FM component inside DeepFM. Two-tower models are FMs restricted to user-side by item-side interactions, with neural encoders.
- 1. Field-aware FMs give each feature…
- 2. An FM's ALS update is closed-form because…
- 3. The FM component of DeepFM provides…
Level 4: Expert
★★★★★ Expert⏱ 25 minResearchers: original papers and open problems.Do side features help new users?
History.
- S. Rendle (2010) introduced factorisation machines, and libFM in 2012.
- Y. Juan, Y. Zhuang, W.-S. Chin and C.-J. Lin (2016) introduced field-aware FMs.
- H. Guo et al. (2017) introduced DeepFM.
- FMs remain strong baselines for click-through prediction.
Exercise 2. 400 users and 150 items. A user’s taste vector is mainly their group’s (6 groups) plus individual noise, and an item’s is mainly its genre’s (5 genres). Users have geometrically distributed numbers of ratings. One rating per user was held out. Both models use k = 4 and the same training; MF uses one-hot user and item only, and the FM adds one-hot user group and item genre.
| user’s training ratings | test users | MF (user, item only) | FM with group and genre |
|---|---|---|---|
| 0–2 | 58 | 0.877 | 0.694 |
| 3–10 | 132 | 0.664 | 0.533 |
| 11 or more | 210 | 0.580 | 0.516 |
- Side features helped most where data were scarcest: a 21% lower RMSE for users with 0–2 ratings, against 11% for users with more than 10. A cold user’s prediction came mostly from the group × genre interaction.
- Even heavy users benefited, because group and genre vectors pool information that individual vectors must otherwise learn from noisy ratings.
- The benefit depends on the side features carrying real signal. Here group and genre determined most of the taste; uninformative attributes would add parameters without help.
Factorisation machines in AI, robotics and aerospace
- Click-through and engagement prediction for internal portals and tools, with user role, document type and time context.
- Asset-condition prediction: asset ID × sensor-regime × environment interactions with sparse coverage, generalising to unseen combinations.
- Cold-start personalisation: new operators or new aircraft tails predicted from attributes until their own data accumulate.
References
- S. Rendle (2010). “Factorization machines.” Proc. IEEE ICDM.
- S. Rendle (2012). “Factorization machines with libFM.” ACM Transactions on Intelligent Systems and Technology 3(3).
- Y. Juan, Y. Zhuang, W.-S. Chin, C.-J. Lin (2016). “Field-aware factorization machines for CTR prediction.” Proc. ACM RecSys.
- H. Guo, R. Tang, Y. Ye, Z. Li, X. He (2017). “DeepFM: a factorization-machine based neural network for CTR prediction.” Proc. IJCAI.