Alternating Least Squares

How models actually learn, from vanilla gradient descent to Adam

Alternating Least Squares, or ALS, is an optimizer for problems that become easy when you freeze half of the unknowns. It is common in matrix factorization, especially recommender systems.

The idea is simple: hold item factors fixed and solve for user factors. Then hold user factors fixed and solve for item factors. Repeat until the reconstruction stops improving.

Two tent poles can be adjusted this way. If both are loose, the canvas shape is hard to fix at once. Hold the left pole steady and adjust the right. Then hold the right steady and adjust the left. Repeating those simpler adjustments can tighten the whole tent. The figure below shows one half-step of that loop: with one side frozen (the fixed line), the best choice for the other side is a least-squares fit. Drag the target and watch the fit chase it; ALS simply alternates which side gets to be the frozen line.

Where this lives in MLALS is a classic optimizer for collaborative filtering. If users rate movies, ALS can learn user vectors and movie vectors so their dot product predicts missing ratings.
▶ Alternating Least Squares
← Optimizer LabMixed Precision & Loss Scaling →