# Natural gradient optimization for LDA

## Summary

This seminar builds the natural gradient from scratch, starting from the practical failure of LDA on the full Wikipedia corpus in 2010 (a day with zero completed iterations) and ending with how natural gradient combined with mini-batching fixes it. It walks through why plain gradients are parametrization dependent, derives the natural gradient as a Lagrangian-constrained optimization problem, shows it equals the Fisher Information Matrix inverse times the ordinary gradient when KL divergence is used as the metric, then applies all of this to the variational EM updates of LDA.


## Core ideas

- Normalizing constant bottleneck: gradient descent on distribution-based models often needs a normalizing constant computed by summing over the full dataset, which makes a single gradient step prohibitively expensive at scale.

- LDA on Wikipedia failure: in 2010 people tried running LDA on the whole Wikipedia corpus and after 24 hours the method hadn't finished a single iteration, forcing an SGD-style workaround that converged in about 30 minutes at the cost of rigor.

- Parametrization dependence: plain gradients point differently depending on how you parametrize the same function (illustrated with circular versus oval level curves), so the raw gradient doesn't reliably point toward the minimum under reparametrization.

- Gaussian shift example: moving the mean of a narrow Gaussian by one unit changes its divergence from the original far more than moving a wide Gaussian by the same amount, showing that gradient magnitude in Euclidean terms ignores the actual geometry of the distribution space.

- Constrained minimization derivation: the natural gradient comes from minimizing the loss subject to a metric-bounded step size, solved via Lagrangian and Taylor expansion in a way that mirrors Newton's method, yielding a gradient scaled by an inverse metric matrix.

- Minimal metric requirements: convergence of this generalized gradient descent only needs positivity and identity of indiscernibles, no symmetry or triangle inequality, which is why asymmetric KL divergence still qualifies as a valid metric here.

- Fisher matrix emerges from KL: plugging KL divergence into the metric slot produces exactly the Fisher Information Matrix, so the natural gradient step is Fisher-inverse times the ordinary gradient, structurally identical to Newton's method.

- Fisher matrix for exponential families: it equals the second derivative of the log normalizing constant, which is the covariance matrix of the sufficient statistics; the lecture's version had an extra erroneous minus sign.

- LDA variational inference payoff: the M-step update for the word-topic matrix phi analytically needs a pass through every document and word in the corpus per iteration, but switching to stochastic natural gradient with document mini-batches removes the need to ever touch the intractable normalizing constant and converges faster than naive SGD.


## Quotes

> люди решили запустить lda на корпусе из Википедии в 2010 году и поняли за сутки что их метод не сделал ни одной итерации и это грустно (People decided to run LDA on a Wikipedia corpus in 2010 and realized after a day that their method hadn't completed a single iteration, which was sad)

Кафедра ММП

> пройтись по всей выборке ради одного градиентного шага это типа тяжело и невозможно (Going through the whole dataset for the sake of one gradient step is kind of hard and impossible)

Кафедра ММП

> это отработало типа за 30 минут и сошлось (It worked in like 30 minutes and converged)

Кафедра ММП

> знание матрицы Фишера такое же сложное как знание нормировать через ковариации (Knowing the Fisher matrix is just as hard as knowing the normalizing constant through covariance)

Кафедра ММП

> если есть что-то трудное постарайтесь от этого избавиться от своей жизни (If something is hard, try to get it out of your life)

Кафедра ММП


## Resources

[Fisher Information Matrix](https://notes.osteele.com/math/fisher-information/?trials=24&successes=15): The Fisher information is the KL-divergence metric, the covariance of sufficient statistics, and the basis of natural gradients.

[Kullback-Leibler divergence](https://arxiv.org/html/2507.04330v2): A dedicated page explaining KL divergence and its role in natural gradient optimization.


Source: https://m.youtube.com/watch?v=kjg9a1X7dyw&list=PLVF5PzSHILHSc8q2EW9A-aQjKL7isx458

Canonical: https://drop.rizzgroup.org/ledger/natural-gradient-optimization-for-lda-2f3ygy
