Classic matrix factorization predicts a rating as a plain dot product pu·qi of a user embedding and an item embedding — a linear model. Neural Collaborative Filtering (He et al., 2017) replaces that dot product with a small neural network that can learn a non-linear interaction function instead:
x = [p_u ; q_i] (concat, 4-dim in this 2D build)
z1 = W1·x + b1 ; h = ReLU(z1) (hidden layer)
z2 = W2·h + b2 ; ŷ = σ(z2) (predicted score, 0-1)
loss = −Σ [y·log ŷ + (1−y)·log(1−ŷ)] (binary cross-entropy)
Every training step runs full-batch gradient descent: it backpropagates the loss through the output, the hidden layer, and all the way into the embeddings themselves — so pu and qi are learned jointly with the network weights, not fixed in advance. That is why the dots in the scatter plot visibly drift during training: the model is reshaping the 2D latent space so a viewer ends up close, in this learned geometry, to the movies their network activations predict they'll like.
- Hidden units — width of the interaction layer; more units can fit sharper non-linear boundaries between genres, at the cost of needing more data.
- Learning rate — step size of each gradient-descent update; watch the loss sparkline get noisier as you push it higher.
- Explore a viewer — draws a live line from that viewer to every movie in the scatter plot, brightness set by the model's current predicted score ŷ.
- Drag / scroll on the scatter plot — pan and zoom the embedding space; the node-link and sparkline panels stay fixed as reference.
This toy catalogue is small and dense enough to train on every pair each epoch; production recommenders (YouTube's deep ranking model, for example) face millions of items and instead train on sampled negatives, but the underlying embed-then-interact math is the same.