Foundations of Generative Modeling
The fundamental question that animates the entire field of generative artificial intelligence can be traced to a deceptively simple observation: given a collection of examples—images, text passages, audio recordings, or molecular structures—can we construct a system that produces new examples indistinguishable from those we started with? This question, while intuitive in its formulation, opens onto a vast terrain of mathematical sophistication, computational challenge, and philosophical intrigue. The ability to learn from data and generate novel, realistic samples lies at the heart of some of the most remarkable achievements in contemporary machine learning, from photorealistic image synthesis to coherent language generation, from drug discovery to artistic creativity. Yet the path from this elegant conceptual starting point to functional generative systems traverses deep waters of probability theory, statistical inference, and the geometry of high-dimensional spaces. This chapter establishes the theoretical foundations essential for navigating that terrain, providing the conceptual vocabulary, mathematical framework, and critical insights that will underpin our exploration of adversarial networks, diffusion models, and the broader landscape of generative AI.
The distinction between discriminative and generative modeling represents perhaps the most fundamental conceptual division in supervised learning, and understanding this division illuminates the unique challenges and opportunities presented by generative systems. A discriminative model, at its core, learns a conditional probability distribution: given an input $\mathbf{x}$, it learns $p(y|\mathbf{x})$ where $y$ represents some label or output of interest. The training objective is to find decision boundaries that separate different classes or to predict continuous outputs with minimal error. Logistic regression, support vector machines, and modern deep neural classifiers all fall within this paradigm. The discriminative approach has dominated practical machine learning for decades, and with good reason: it directly addresses the tasks that matter most in applications, often achieves superior performance on those tasks, and can be trained with relatively straightforward optimization procedures. When a medical diagnostic system learns to classify images as containing malignant tissue or not, it does not need to understand what healthy tissue looks like in the abstract—it only needs to learn the decision boundary that separates pathological from normal cases.
Generative models, in contrast, take a fundamentally different approach. Rather than learning a conditional distribution, a generative model learns the joint distribution $p(\mathbf{x}, y)$ or, equivalently, learns to model the data distribution $p(\mathbf{x})$ directly, with labels incorporated when necessary. From this complete model of the data, one can then derive the conditional distribution $p(y|\mathbf{x})$ using Bayes' rule, but this is merely a byproduct of the more ambitious goal: understanding the structure of the data itself. A generative model of natural images does not merely learn to distinguish cats from dogs—it learns what it means for an image to be a plausible natural photograph at all. This additional modeling ambition makes the generative task substantially more challenging than the discriminative one, but it also endows generative models with capabilities that discriminative systems cannot possess. A truly capable generative model can imagine novel examples that were never seen in training, can provide likelihood estimates that enable anomaly detection and outlier identification, and can support counterfactual reasoning about what would happen if certain features of the data were altered.
The mathematical framework for understanding generative models draws heavily from probability theory and statistical inference, with probabilistic graphical models providing a particularly useful language for describing the structure of these systems. A probabilistic graphical model represents a joint distribution over variables as a graph, where nodes correspond to random variables and edges encode conditional independence relationships. In the context of generative modeling, such graphs specify how complex high-dimensional data might be decomposed into simpler components and how dependencies between those components might be structured. The directed acyclic graph of a Bayesian network specifies a factorization of the joint distribution as a product of conditional distributions, one for each node given its parents. This factorization can dramatically simplify the specification of a generative model and can reveal underlying structure in the data-generating process.
Consider the canonical example of a latent variable model: suppose we observe a dataset of images of handwritten digits. The observed images are high-dimensional vectors in $\mathbb{R}^{784}$ (for $28 \times 28$ pixel images), yet the underlying variation in the data is governed by a much smaller number of factors—the identity of the digit, its position, rotation, stroke thickness, and writing style. A latent variable model posits the existence of a low-dimensional latent space $\mathbf{z} \in \mathbb{R}^d$ with $d \ll 784$ that captures these essential factors, and specifies a conditional distribution $p(\mathbf{x}|\mathbf{z})$ over observed images given latent codes. The full generative model then factors as $p(\mathbf{x}, \mathbf{z}) = p(\mathbf{z})p(\mathbf{x}|\mathbf{z})$, and the observed data distribution is obtained by marginalizing out the latent variables: $p(\mathbf{x}) = \int p(\mathbf{x}|\mathbf{z})p(\mathbf{z})d\mathbf{z}$. This marginalization operation, integrating over all possible latent codes weighted by their prior probability, is central to understanding how generative models produce their predictions, and the computational intractability of this integration in general forms one of the fundamental challenges in the field.
The formulation of generative models in terms of latent variables connects naturally to the framework of maximum likelihood estimation, the workhorse of statistical inference. Given a dataset $\mathcal{D} = \{\mathbf{x}^{(1)}, \mathbf{x}^{(2)}, \ldots, \mathbf{x}^{(N)}\}$ of independent and identically distributed samples from some unknown data-generating distribution $p_{\text{data}}(\mathbf{x})$, a generative model with parameters $\boldsymbol{\theta}$ defines a probability distribution $p_{\boldsymbol{\theta}}(\mathbf{x})$. Maximum likelihood estimation seeks the parameters that maximize the probability of the observed data under the model: $\boldsymbol{\theta}^* = \arg\max_{\boldsymbol{\theta}} \prod_{i=1}^N p_{\boldsymbol{\theta}}(\mathbf{x}^{(i)})$, or equivalently, minimizes the Kullback-Leibler divergence $D_{\text{KL}}(p_{\text{data}} \| p_{\boldsymbol{\theta}})$ between the data distribution and the model distribution. This objective has deep theoretical justification: under mild regularity conditions, the maximum likelihood estimator is consistent, efficient, and asymptotically normal. Moreover, maximizing likelihood is equivalent to minimizing the expected negative log-likelihood $\mathbb{E}_{\mathbf{x} \sim p_{\text{data}}}[-\log p_{\boldsymbol{\theta}}(\mathbf{x})]$, which connects to information-theoretic concepts of cross-entropy and perplexity.
However, the practical application of maximum likelihood to generative models is fraught with complications. For models with latent variables, the objective involves an expectation over the latent space that is typically intractable to compute exactly. For models that directly specify a likelihood function over high-dimensional data such as images, the likelihood of any specific image is often astronomically small, and small errors in probability mass estimation can lead to large errors in the log-likelihood. Furthermore, the relationship between likelihood and perceptual