Augment and Reduce: Stochastic Inference for Large Categorical Distributions

Francisco J. R. Ruiz, Michalis K. Titsias, Adji B. Dieng, David M. Blei

Introduction

Categorical distributions are the backbone of modern machine learning, powering everything from image classifiers to large language models (LLMs) and recommendation systems. However, they suffer from a major scaling bottleneck: the softmax normalizer.

To calculate the probability of a single class, one must sum over all $K$ possible outcomes. When $K$ is in the tens of thousands or millions, evaluating this sum and its gradient becomes prohibitively expensive. Existing workarounds often rely on crude approximations or are limited strictly to softmax models.

Augment and Reduce (A&R) is a novel inference framework designed to scale categorical distributions to thousands of classes by reducing computational complexity from linear ($O(K)$) to constant ($O(1)$) per iteration. By introducing an auxiliary latent variable, A&R transforms the expensive log-probability calculation into a sum that can be efficiently estimated via stochastic subsampling, outperforming existing methods like "one-vs-each" (OVE) in both speed and accuracy.

Methodology: The A&R Framework

The authors propose a mathematically rigorous two-step strategy that provides a lower bound on the likelihood while generalizing to models beyond softmax, such as multinomial probit.

  1. Augment: The categorical distribution is reframed using a "utility perspective," where each class has a utility score composed of a deterministic component and random noise. The class with the highest utility is selected. By "augmenting" the model—keeping one of these noise terms as a latent variable rather than integrating it out immediately—the joint probability of the outcome and the noise becomes a product of terms.
  2. Reduce: Because the joint probability is a product, the log-joint becomes a sum over all classes. This transformation is critical: sums are easy to approximate using Stochastic Variational Inference (SVI). Instead of summing over all $K$ classes, A&R subsamples a small set of classes to compute an unbiased estimate of the gradient.
Graphical models illustrating the A&R augmentation strategy compared to standard marginalized models.

Unlike previous bounds that only work for softmax, A&R is a general recipe. By changing the distribution of the noise term, practitioners can recover softmax (Gumbel noise), multinomial probit (Gaussian noise), or multinomial logistic (Logistic noise).

Experiments and Key Insights

The researchers evaluated A&R on several diverse classification tasks, ranging from standard baselines like MNIST (10 classes) to large-scale datasets like AmazonCat-13K (2,919 classes) and a synthetic dataset with 10,000 classes to test scaling limits.

Superior Accuracy and Tighter Bounds

The paper demonstrates that adding complexity via a latent variable can actually simplify the optimization problem. By moving from a marginal likelihood to an augmented joint likelihood, A&R unlocks the use of stochastic optimization.

Crucially, A&R provides a variational lower bound (ELBO) on the marginal likelihood that is significantly tighter than the popular "one-vs-each" (OVE) bound. A tighter bound generally leads to better parameter estimates and higher predictive accuracy. On almost all datasets, Softmax A&R achieved higher test log-likelihood and better classification accuracy than the OVE baseline.

Evolution of the ELBO over time on the Bibtex dataset. A&R consistently provides a tighter bound than OVE and closely tracks the exact softmax.

Efficiency and Scaling

A&R is roughly as fast as OVE per epoch but converges to a better solution. The "local step" (updating the latent variable parameters) is computationally cheap and can be performed in parallel. In the synthetic test with 10,000 classes, A&R provided a bound on the marginal likelihood that was orders of magnitude tighter than OVE, proving its efficacy at scale. On datasets like MNIST and Bibtex, A&R's performance was nearly identical to the "exact" (but slow) softmax.

Limitations and Future Work

While highly effective, the A&R framework has a few limitations:

  • Memory Overhead: A&R requires storing "local" variational parameters for every data point in the training set, leading to an $O(N)$ memory requirement. This could be a hurdle for massive datasets, though it can be mitigated by using a global recognition network (similar to a VAE).
  • Subsampling Variance: Although the gradient estimates are unbiased, the variance introduced by subsampling classes could slow down convergence in some settings. Exploring importance sampling for class selection is a promising future direction.
  • Point Estimates: The current work focuses on maximum likelihood estimation. Extending A&R to full Bayesian posterior inference for the weights remains an open area for future research.

Summary updated

BibTeX
@inproceedings{ruiz2018augment,
  author = {Francisco J. R. Ruiz and Michalis K. Titsias and Adji B. Dieng and David M. Blei},
  title = {{Augment and Reduce: Stochastic Inference for Large Categorical Distributions}},
  booktitle = {International Conference on Machine Learning},
  year = {2018},
  url = {https://openreview.net/forum?id=B14ANibubH},
}
Figure