Submitted in Partial Fulfillment of the Requirements for the Degree of
DOCTOR OF PHILOSOPHY
Approved by:
Mohammed J. Zaki, Chair
Alex Algernon Theodore Gittens
Malik Magdon-Ismail
Dmitry Krotov
Department of Computer Science
Rensselaer Polytechnic Institute
Troy, New York
© Copyright 2026
by
Bao Pham
All Rights Reserved
ACKNOWLEDGMENT
Foremost, I would like to express my gratitude to my advisor, Dr. Mohammed J. Zaki, for his guidance, his patience, and the freedom he gave me to pursue the questions that interested me most. I also thank the members of my committee, Dr. Alex Gittens, Dr. Malik Magdon-Ismail, and Dr. Dmitry Krotov, for their time, their feedback, and the care with which they read and reviewed this thesis.
My years at RPI have shaped me as a researcher and as a person. I thank the Department of Computer Science for its support, and the students I met as a teaching assistant, who reminded me that explaining an idea clearly is the best test of understanding it. I am especially grateful to my friends at RPI, Lawrence Hiquiana, Kushal R. Bhandari, and many others, who made Troy feel like home. I would also like to thank my lab mates, Aitazaz Khan, Mohbat Tharani, and Bolun “Namir” Xia, for the time they spent discussing ideas with me, for their guidance, and for setting a high standard of work ethic. I wish them good fortune in their future endeavors.
I owe a special debt to IBM Research, a wonderful place where I learned how scientific research is done and made great friends who showed me the ropes during my three summers there. There I learned how to ask a good question, how to test an idea honestly, and how to keep going when an experiment does not work. I thank Dmitry Krotov for his mentorship and for the many conversations about Associative Memory that shaped this thesis, and I thank my collaborators and colleagues at IBM Research, including Benjamin Hoover and Parikshit Ram, for the discussions and the encouragement that carried this work forward. I would also like to thank the RPI-IBM Future of Computing Research Collaboration (FCRC) program for funding my research.
I am also grateful to AMD Research for the opportunity to work on 3D world modeling, which has opened a new direction of research that I hope to explore in the future. I thank my mentors, Utkarsh Saxena and Ruijing Yang, and my managers, Vikram Appia and Zhenyu Gu, for their guidance and support during my time there.
Finally, I thank my family for their support. I am very proud of my little sister, Rina, who recently started her undergraduate studies at Vanderbilt University. I am grateful for her encouragement and for her support of my curiosity and my pursuit of scientific research. I hope my journey encourages her own scientific curiosity as she begins her studies at Vanderbilt.
Introduction
Recall or Creation?
Generative models now write working code, synthesize realistic images and videos, and hold long conversations [22 , 147 , 127 ] (Ho et al. 2020). Their success rests on a deceptively simple principle. Given samples from an unknown data distribution, a model is trained to assign high probability to the data it has seen, whether through maximum likelihood, denoising score matching, or a conditional likelihood over parts of the data [140 , 143 , 156 ] (Ho et al. 2020). Yet an objective that rewards the training data does not, by itself, specify what the model should do with data it has never seen. A model that perfectly reproduces its training set has, in a narrow sense, solved the problem it was given. That trained models nonetheless produce samples that are new, coherent, and useful remains one of the central puzzles of modern machine learning.
The puzzle becomes sharper once we look at what these models actually generate. Diffusion models trained on images can reproduce near-exact copies of their training samples (Somepalli et al., 2023a,b; Carlini, Hayes, et al., 2023; Webster, 2023), and large language models can be prompted to emit verbatim passages of their training text [28 , 27 ] . The same models also produce images that appear nowhere in their training data and solve tasks for which they were given few or no examples [22 , 93 ] . In practice, we want both behaviors. A useful language model should recall a fact exactly and still compose a sentence that no one has written before. This raises a question that is simple to state and difficult to answer. When a generative model produces an output, is it recalling what it has seen or creating something new?
The answer matters for several reasons. The first is practical. If generated content can be traced to memorized training data, then privacy leakage and copyright concerns may be structural consequences of how these models learn rather than occasional accidents [28 , 141 ] (Carlini, Hayes, et al. 2023). The second concerns reliability. A language model that fails to recall a fact faithfully, or that confidently produces unsupported content, generates the fluent but unfounded text often described as hallucination (Ji et al., 2023). Distinguishing recall from creation is therefore a prerequisite for knowing when to trust a model’s output. The third is scientific. Despite their empirical success, we lack an account of what these models store, where they store it, and how stored content gives rise to novel samples. A similar question sits at the heart of how the brain remembers and imagines, where recalling the past and imagining the future are thought to draw on shared memory systems [135 ] . Explaining how memorization and generalization coexist in artificial generative models may thus contribute to a broader understanding of memory as a computational principle.
Classical learning theory has long treated memorization as the opposite of generalization, the symptom of a model that fits noise rather than structure. Modern deep networks have unsettled this view. They can fit randomly labeled data perfectly and still generalize on real data [172 ] , and memorizing rare examples can even be necessary for good performance on long-tailed distributions [51 ] . Recent analytical work has also shown that the memorization of facts and the generalization of rules can be achieved simultaneously by the same network [49 ] . For generative models, however, most studies of the memorization-to-generalization transition remain generalization-centric [112 , 152 , 84 , 157 , 3 , 86 , 129 , 18 , 33 , 2 ] . Memorization is typically viewed as a side effect that fades as the training set grows [168 ] (Gu et al. 2025), and the intermediate regime between the two phases, where both behaviors are present, has received comparatively little attention. These studies also predominantly concern continuous data such as images, leaving the discrete setting of language comparatively less explored.
This thesis takes a different starting point. Rather than treating memorization as a flaw to be removed, we treat it as the foundation from which generalization emerges. If the ability of a model to create is built on its ability to remember, then understanding generalization requires understanding memory first. We therefore study generative models through a framework that was built to describe memory in the first place, Associative Memory.
Associative Memory as a Lens on Generative Models
Associative Memory (AM) is an idea that emerged from physics and its concept of energy. In the Hopfield network [75 , 8 , 76 ] , a set of patterns is stored as local minima of an energy function, and a corrupted or partial cue is restored by letting the state of the network descend this energy until it settles into a nearby minimum. Each stored pattern is therefore surrounded by a basin of attraction, the set of states that flow toward it, and retrieval succeeds whenever the cue lies within the correct basin. The number of patterns that a classical Hopfield network can reliably store grows only linearly with the number of neurons [10 , 11 , 1 ] . Dense Associative Memories (DenseAMs) remove this limitation through sharper, higher-order interactions, achieving storage capacities that grow super-linearly and even exponentially with the dimension of the data [101 , 102 , 37 ] . These modern AMs have renewed interest in the field, in part because their retrieval dynamics are closely related to the attention mechanism of Transformers [123 ] (Hoover, Liang, et al. 2023) and to models of memory in neurobiology [104 , 95 ] . We refer the reader to Krotov et al. [100 ] for a recent review.
A central question of AM theory is what happens when the network is asked to store more than its capacity allows. Beyond capacity, the energy landscape develops minima that do not correspond to any stored pattern. These spurious states were historically regarded as defects that corrupt retrieval [75 , 77 , 10 ] , and loading the network further leads to a catastrophic blackout in which no meaningful attractor survives [11 ] . Recent work has revealed a different outcome. When the stored patterns share an underlying structure, overloading an AM can instead create new attractors close to examples it has never seen, while the memories of its training data persist [85 ] . From this perspective, the formation of new attractors beyond capacity is not only a failure of memory. It is also where generalization begins.
This observation suggests a reinterpretation of generative modeling itself. Training a generative model can be viewed as writing the training data into memory, and generation as an attempt to recall it. When recall succeeds, the model retrieves a training sample, which is memorization. When recall fails, the model settles into an attractor that is not a training sample. Such attractors include spurious states and, once enough data is available, generalized samples. For diffusion models, this correspondence can be made precise in an idealized limit. The energy implied by the optimal score of a diffusion model trained on a finite dataset takes the same log-sum-exp form as the energy of a DenseAM, with the noise level playing the role of temperature [9 , 124 ] (Hoover, Strobelt, et al. 2023). The theory developed for AMs, including the theory of spurious states, can therefore be brought to bear on how diffusion models memorize and generalize.
Associative Memory Beyond Energy
The energy function has long been considered the defining ingredient of an AM. It guarantees that retrieval converges, and it makes stored memories directly visible as the minima of the energy landscape. Requiring an energy function, however, also restricts the class of admissible models, since it typically demands symmetric interactions or carefully constrained architectures [98 , 95 ] (Hoover, Liang, et al. 2023). Most modern networks, including the Transformers [156 ] that underlie today’s language models, satisfy no such constraint, and there is no reason to expect the computation of a generic feed-forward network to follow the gradient of an energy function.
What an AM needs in order to retrieve its memories is not the energy function itself, but the basins of attraction that the energy function produces. Basins can arise in other ways. In the classical theory of neural networks, the robustness of a stored pattern is tied to the margin with which each neuron reproduces its own state given the states of all the others [53 , 54 ] . Maximizing the conditional likelihood of each variable given the rest, as in the pseudo-likelihood objective [17 ] , has been shown to create such basins directly, even when the learned couplings are asymmetric and no energy function exists [34 ] . Conditional likelihood is precisely the structure on which modern language models are trained. This thesis therefore adopts a broader view, in which a system acts as an AM whenever it forms basins of attraction around data, whether or not those basins are the minima of an energy.
This view has an important consequence for the coexistence of memorization and generalization. In an AM, a basin around a training example and a basin around an unseen example are objects of the same kind. A model that holds basins around both is at once a faithful memory and a system capable of recovering data it was never shown. The question of how memorization and generalization coexist then becomes a question about how basins of attraction form, how they grow or shrink with the amount of data and the size of the model, and how they can be measured.
The Nature of This Work
This thesis is primarily explanatory. Its main goal is not to propose a new generative model or to improve performance on a benchmark, but to explain behaviors that widely used generative models already exhibit, and to provide tools for observing those behaviors inside a trained model. The AM perspective, however, is also constructive. As the Energy Transformer [73 ] illustrates, energy-based modeling and AM can guide the design of new architectures that use fewer parameters than their feed-forward counterparts, remain competitive in performance, and whose computation can be read through their energy. Three principles guide the explanatory work.
First, theory serves as a lens rather than as a description of every detail. Concepts from AM theory, such as capacity, basins of attraction, spurious states, and margins, have precise meanings in idealized settings. In the continuous case, the idealized setting is a diffusion model whose score exactly matches the empirical distribution of its training data, a limit in which the connection to DenseAMs is exact. In the discrete case, it is a network of binary variables trained with pseudo-likelihood, where the link between conditional likelihood, Hebbian learning, and margins can be derived explicitly. Practical models are neither infinitely expressive nor binary. The central empirical question is therefore whether predictions derived in these idealized limits survive in finite networks trained with standard methods.
Second, memorization and generalization are also measured from the inside. The usual way to detect memorization is to compare generated samples against the training set, which becomes costly as datasets grow and says little about why a sample was produced. We still rely on such comparisons where they are needed, for instance to label generated images as memorized, spurious, or generalized, and token recovery requires reference sequences. Beyond these labels, the quantities used in this thesis are properties of the model’s own dynamics. They include the size of the basin of attraction around a generated sample, the curvature of the energy landscape around it, the reliability with which the model restores a sequence after part of it has been corrupted, and the uncertainty of the model about each token it produces. Because each of these quantities has a geometric meaning in AM theory, they help explain as well as detect. They indicate not only whether a sample is memorized, but also what kind of attractor it occupies.
Third, the amount of training data is treated as a control parameter. In AM theory, the behavior of a network is governed by its load, the number of stored patterns relative to the size of the network. By training families of models on datasets of systematically increasing size, and at several model sizes, we trace the transition from memorization to generalization across its full range, rather than observing a single model at a single point.
Finally, the scope of these claims should be stated clearly. The models studied here are small compared with frontier systems, and the results establish correspondences and measurable signatures rather than causal mechanisms. Spurious states, for instance, mark the onset of generalization, but we do not prove that they cause it. The aim is to provide a coherent and testable account of how memorization and generalization can coexist at a larger scale.
Research Questions
The perspective above leads to a central question. How can memorization and generalization coexist within the same generative model? AM theory suggests that the answer lies in how basins of attraction form, how they change with data, and how they appear from inside the model. We address this question through three parts.
Is generation a form of memory retrieval? If training writes data into memory and generation attempts to recall it, a diffusion model should behave as an AM. Below its capacity, it should hold one attractor per training sample. Beyond its capacity, it should form new attractors that belong to no single training sample, and AM theory predicts that spurious states mark the boundary between the two regimes. We ask whether finite diffusion models trained with standard methods follow this picture, and whether spurious states signal the onset of generalization.
What makes a system an Associative Memory? AMs are classically defined by an energy function whose minima are the stored memories. What allows an AM to retrieve its memories, however, is the existence of basins of attraction around them, and most generative models, including language models, are neither trained with an energy nor constrained to have one. We ask whether basins of attraction, rather than an energy function, can serve as the defining property of an AM, whether conditional likelihood maximization, the objective behind these models, is sufficient to create such basins, and whether language diffusion models then display the signatures of an AM, including a memorization-to-generalization transition in which basins around training data and basins around unseen data coexist.
Can AM theory make memorization and generalization measurable? Detecting memorization usually relies on comparing generated samples with the training set. Such comparisons indicate whether a sample is a copy, but they become costly at scale and say little about why the sample was produced. We ask whether quantities grounded in AM theory, such as basin volume, energy curvature, token recovery, and conditional entropy, can complement these comparisons by revealing where a model lies along the transition, how this position depends on the size of the training set and of the model, and which parts of a single output are recalled and which are created.
Contributions
This thesis makes two main contributions, each corresponding to one of the core chapters.
Diffusion Models as Associative Memories. In Chapter 3, we interpret continuous diffusion models through the lens of DenseAMs and characterize their memorization-to-generalization transition as a function of the training set size. This chapter addresses the first research question and contributes to the third. In the small data regime, diffusion models form a distinct attractor for each training sample, akin to a DenseAM below its critical capacity. As the training set grows, the models transition to generalization. At the onset of this transition, we identify an intermediate phase, predicted by DenseAM theory, in which spurious states emerge. These samples possess sizable basins of attraction yet do not correspond to any training sample, and we argue that they are the first signs of generative capability rather than negative artifacts. We characterize memorized, spurious, and generalized samples through their abundance, the volume of their basins of attraction, and the curvature of the energy landscape around them, across a two-dimensional (toy) model, several natural image datasets, and multiple architectures. A small-scale case study of Stable Diffusion (Rombach et al. [127 ] ) further identifies candidate memorized, spurious, and generalized samples with a similar ordering of energy curvature, suggesting that these phenomena may persist in large-scale practical models. The sample types are identified by a nearest-neighbor search over the training set, but the energy curvature is computed from the trained model alone, which points toward diagnostic tools that could monitor the onset of memorization during training without such a search.
Coexistence of Memorization and Generalization in Language. In Chapter 4, we extend this perspective to language, and building on D’Amico, Bocchi, et al. (2026), provide evidence that an explicit energy function is not required for AM behavior. This chapter addresses the second research question and contributes to the third. We study uniform-state discrete diffusion models ([14 , 25 , 55 , 131 ] ) and show, in a simplified setting of binary variables, that maximizing conditional likelihood implicitly performs Hebbian learning (Hebb [65 ] ) on the training data while maximizing the classification margin of each variable, which produces basins of attraction around the data. Empirically, these models undergo a sharp memorization-to-generalization transition governed by the size of the training set. As the training set grows, basins around training sequences shrink while basins around unseen test sequences expand, until the model recovers corrupted test sequences as reliably as training ones. We introduce token recovery rates and conditional entropy as complementary probes of this transition. Conditional entropy vanishes in the memorization regime and remains finite in the generalization regime; separates recovered tokens, which have near-zero entropy, from unrecovered ones within the same sequence; and agrees with perplexity measured by an external critic model. Larger models delay the onset of the transition and narrow the entropy gap between training and generated sequences.
Thesis Organization
The remainder of this thesis is organized as follows. Chapter 2 introduces the background on which the later chapters build, including energy-based models, continuous and discrete diffusion models, and classical and dense AMs, with an emphasis on their memory capacity and spurious states. Chapter 3 presents our study of continuous diffusion models as DenseAMs and the emergence of spurious states at the memorization-to-generalization transition. Chapter 4 extends the AM perspective to language diffusion models, where basins of attraction arise from conditional likelihood maximization without an explicit energy function. Chapter 5 summarizes our findings and discusses open questions and future directions. Chapters 3 and 4 each end with a section of supplementary material containing experimental details and additional results.
Background
Probabilistic Generative Modeling
A generative model is an approximation of the process that produced the data, one from which new samples can be drawn, or generated. We assume that each observation x x x , such as an image or a sentence, is a sample from an unknown data distribution p d a t a ( x ) p_{\mathrm{data}}(x) p data ( x ) , and we seek a parameterized distribution p θ ( x ) p_{\theta}(x) p θ ( x ) that resembles it,
p θ ( x ) ≈ p d a t a ( x ) . (1) p_{\theta}(\mathbf{x}) \approx p_{\mathrm{data}}(\mathbf{x}). \tag*{(1)} p θ ( x ) ≈ p data ( x ) . (1)
Once such a model is available, it can be used to evaluate how plausible a new observation is, to fill in missing or corrupted parts of an observation, and, most visibly, to synthesize new samples [91 ] . The difficulty is that p d a t a p_{\mathrm{data}} p data is never available directly. What we have is a finite dataset D = { x ( 1 ) , … , x ( K ) } \mathcal{D} = \{\mathbf{x}^{(1)}, \ldots, \mathbf{x}^{(K)}\} D = { x ( 1 ) , … , x ( K ) } of K K K independent samples, which defines the empirical distribution
p ^ D ( x ) = 1 K ∑ k = 1 K δ ( x − x ( k ) ) , (2) \hat{p}_{\mathcal{D}}(\mathbf{x}) = \frac{1}{K} \sum_{k=1}^{K} \delta(\mathbf{x} - \mathbf{x}^{(k)}), \tag*{(2)} p ^ D ( x ) = K 1 k = 1 ∑ K δ ( x − x ( k ) ) , (2)
where δ \delta δ is the Dirac delta. Every learning objective in this chapter is computed from p ^ D \hat{p}_{\mathcal{D}} p ^ D , while the goal is to approximate p d a t a p_{\mathrm{data}} p data . The gap between these two distributions is where the question of memorization and generalization arises.
Maximum Likelihood Estimation
The most common way to fit p θ p_{\theta} p θ is maximum likelihood estimation (MLE). The likelihood of the parameters is the probability that the model assigns to the observed dataset,
L ( θ ; D ) = ∏ x ∈ D p θ ( x ) , (3) \mathcal{L}(\theta; \mathcal{D}) = \prod_{\mathbf{x} \in\mathcal{D}} p_{\theta}(\mathbf{x}), \tag*{(3)} L ( θ ; D ) = x ∈ D ∏ p θ ( x ) , (3)
and since products of many small probabilities are numerically unstable, one works with its logarithm,
log L ( θ ; D ) = ∑ x ∈ D log p θ ( x ) . (4) \log\mathcal{L}(\theta; \mathcal{D}) = \sum_{\mathbf{x} \in\mathcal{D}} \log p_{\theta}(\mathbf{x}). \tag*{(4)} log L ( θ ; D ) = x ∈ D ∑ log p θ ( x ) . (4)
The maximum likelihood estimate is the parameter that makes the observed data most probable,
θ ∗ = arg max θ ∑ x ∈ D log p θ ( x ) . (5) \theta^* = \underset{\theta}{\arg\max}\sum_{x\in\mathcal{D}}\log p_\theta(\mathbf{x}). \tag*{(5)} θ ∗ = θ arg max x ∈ D ∑ log p θ ( x ) . (5)
Dividing Eq. (4) by K K K shows that MLE maximizes the average log-probability under the empirical distribution, which is the same as minimizing the Kullback-Leibler (KL) divergence (Kullback & Leibler, [105 ] ) from p ^ D \hat{p}_{\mathcal{D}} p ^ D to the model,
1 K log L ( θ ; D ) = E p ^ D ( x ) [ log p θ ( x ) ] = − D K L ( p ^ D ( x ) ∥ p θ ( x ) ) + constant . (6) \frac{1}{K}\log\mathcal{L}(\theta;\mathcal{D})=\mathbb{E}_{\hat{p}_{\mathcal{D}}(\mathbf{x})}\left[\log p_\theta(\mathbf{x})\right]=-\mathit{D}_{\mathrm{KL}}\left(\hat{p}_{\mathcal{D}}(\mathbf{x})\mathbin\Vert p_\theta(\mathbf{x})\right)+\text{constant}. \tag*{(6)} K 1 log L ( θ ; D ) = E p ^ D ( x ) [ log p θ ( x ) ] = − D KL ( p ^ D ( x ) ∥ p θ ( x ) ) + constant . (6)
As the number of samples grows, p ^ D \hat{p}_{\mathcal{D}} p ^ D approaches p d a t a p_{\mathrm{data}} p data , and MLE approaches the minimization of D K L ( p d a t a ∥ p θ ) \mathit{D}_{\mathrm{KL}}(p_{\mathrm{data}}\mathbin\Vert p_\theta) D KL ( p data ∥ p θ ) (Arjovsky et al., [13 ] ). For any finite dataset, however, the objective is indifferent to everything outside the training set. If the model family were unrestricted, the maximizer of Eq. (6) would be p ^ D \hat{p}_{\mathcal{D}} p ^ D itself, a model that places all of its mass on the training samples and reproduces nothing else. MLE, taken at face value, therefore rewards memorization. A model trained by MLE generalizes only because its parameterization, its capacity, and the way it is optimized prevent it from reaching this solution. The same observation reappears in diffusion models. A diffusion model that learns the score of its finite training set exactly, rather than the score of the underlying data distribution, can only reproduce its training samples (§ 3.3.4 ).
Beyond this conceptual point, MLE poses a practical challenge. Evaluating log p θ ( x ) \log p_\theta(\mathbf{x}) log p θ ( x ) requires p θ p_\theta p θ to be a properly normalized distribution, and normalizing a flexible model over a high-dimensional space is generally intractable. Much of the design of deep generative models can be understood as a response to this constraint. Autoregressive models factorize the joint distribution into a product of one-dimensional conditionals, each of which is easy to normalize (Graves, [61 ] ; Germain et al., [58 ] ; van den Oord, Kalchbrenner, & Kavukcuoglu, 2016; Yu et al., 2022; Tian et al., [150 ] ). Normalizing flows build p θ p_\theta p θ from invertible transformations of a simple base distribution, so that the change-of-variables formula gives the density exactly (Dinh et al., [41 , 42 ] ; Rezende & Mohamed, [125 ] ; Kingma & Dhariwal, [89 ] ; Weng, [166 ] ). Variational autoencoders introduce latent variables and optimize a tractable lower bound on the likelihood (Kingma & Welling, [90 ] ; Rezende et al., [126 ] ). Each of these solutions buys tractability by fixing the form of the model, whether as a sequential ordering of variables, an invertible architecture, or a particular latent-variable structure, and each constraint may limit how well the model can capture complex data [145 ] .
Energy-Based Models
Energy-based models (EBMs) take the opposite approach. Rather than constraining the model so that it can be normalized, they give up on normalization during modeling and specify only an energy function E θ ( x ) E_\theta(\mathbf{x}) E θ ( x ) that assigns low values to plausible observations and high values to implausible ones. Because the energy is not required to integrate to one, it can be represented by essentially any neural network, provided only that the corresponding distribution could in principle be normalized. This freedom has made EBMs useful for modeling images [115 ] (Du & Mordatch 2019; Du et al. 2021), text [39 ] , and graphs [109 ] . EBMs are also the natural bridge to the rest of this thesis, since the AMs discussed in § 3.4 are themselves defined by energy functions.
Energy and Probability
An energy function defines a probability distribution through the Boltzmann distribution,
p θ ( x ) = exp ( − E θ ( x ) ) Z θ , (7) p_\theta(\mathbf{x}) = \frac{\exp(-E_\theta(\mathbf{x}))}{Z_\theta}, \tag*{(7)} p θ ( x ) = Z θ exp ( − E θ ( x )) , (7)
where the partition function
Z θ = ∫ exp ( − E θ ( x ) ) d x (8) Z_\theta= \int\exp(-E_\theta(\mathbf{x})) \, \mathrm{d}\mathbf{x} \tag*{(8)} Z θ = ∫ exp ( − E θ ( x )) d x (8)
ensures that the distribution integrates to one. The partition function (8) is the difficult term to compute, since it integrates over all states and changes whenever the parameters θ \theta θ are updated. The exponential in Eq. (7) translates the geometry of the energy into probability, as illustrated in Figure 2.1 . The minima of the energy are the most probable states, and the deeper a minimum, the more probability it carries.
Figure 2.1. The relationship between energy and probability. The energy assigned to each state (left) and the probability of the same states under Eq. (7) (right) are shown. States with low energy have high probability, as indicated by the dashed gray arrow.
The price of this flexibility is paid during training. For all but the simplest energies, Z θ Z_\theta Z θ is an intractable integral over the entire input space, and so is the log-likelihood log p θ ( x ) = − E θ ( x ) − log Z θ \log p_\theta(\mathbf{x}) = -E_\theta(\mathbf{x}) - \log Z_\theta log p θ ( x ) = − E θ ( x ) − log Z θ [145 ] . Two families of methods train EBMs without ever computing Z θ Z_\theta Z θ . The first estimates the gradient of the log-likelihood using samples from the model, which leads to contrastive divergence. The second replaces the likelihood with an objective on the gradient of the log-density with respect to the data, which leads to score matching. We review both, because each prefigures an idea used later in this thesis.
Contrastive Divergence
In the population limit, MLE maximizes the expected log-likelihood of the data,
L ( θ ) = E x ∼ p d a t a ( x ) [ log p θ ( x ) ] , (9) \mathcal{L}(\theta) = \mathbb{E}_{\mathbf{x}\sim p_{\mathrm{data}}(\mathbf{x})}\left[\log p_{\theta}(\mathbf{x})\right], \tag*{(9)} L ( θ ) = E x ∼ p data ( x ) [ log p θ ( x ) ] , (9)
or, equivalently, minimizes the negative log-likelihood
− L ( θ ) = − E x ∼ p d a t a ( x ) [ log p θ ( x ) ] , (10) -\mathcal{L}(\theta) = -\mathbb{E}_{\mathbf{x}\sim p_{\mathrm{data}}(\mathbf{x})}\left[\log p_{\theta}(\mathbf{x})\right], \tag*{(10)} − L ( θ ) = − E x ∼ p data ( x ) [ log p θ ( x ) ] , (10)
which differs from the KL divergence between the data and the model only by the entropy of the data, a quantity that does not depend on θ \theta θ ,
− E x ∼ p d a t a ( x ) [ log p θ ( x ) ] = D K L ( p d a t a ( x ) ∥ p θ ( x ) ) − E x ∼ p d a t a ( x ) [ log p d a t a ( x ) ] . (11) -\mathbb{E}_{\mathbf{x}\sim p_{\mathrm{data}}(\mathbf{x})}\left[\log p_{\theta}(\mathbf{x})\right] = D_{KL}\left(p_{\mathrm{data}}(\mathbf{x}) \mathbin{\|} p_{\theta}(\mathbf{x})\right) - \mathbb{E}_{\mathbf{x}\sim p_{\mathrm{data}}(\mathbf{x})}\left[\log p_{\mathrm{data}}(\mathbf{x})\right]. \tag*{(11)} − E x ∼ p data ( x ) [ log p θ ( x ) ] = D K L ( p data ( x ) ∥ p θ ( x ) ) − E x ∼ p data ( x ) [ log p data ( x ) ] . (11)
Although the likelihood of an EBM cannot be evaluated, its gradient can be estimated, which is enough for gradient-based optimization [57 , 164 ] . Differentiating Eq. (7) gives
∇ θ log p θ ( x ) = − ∇ θ E θ ( x ) − ∇ θ log Z θ . (12) \nabla_{\theta}\log p_{\theta}(\mathbf{x}) = -\nabla_{\theta}E_{\theta}(\mathbf{x}) - \nabla_{\theta}\log Z_{\theta}. \tag*{(12)} ∇ θ log p θ ( x ) = − ∇ θ E θ ( x ) − ∇ θ log Z θ . (12)
The first term is computed by automatic differentiation of the energy. The second term involves the partition function, but it has a simple form. Moving the gradient inside the integral in Eq. (8) shows that it is an expectation under the model itself,
∇ θ log Z θ = 1 Z θ ∇ θ ∫ exp ( − E θ ( x ) ) d x = ∫ exp ( − E θ ( x ) ) Z θ ( − ∇ θ E θ ( x ) ) d x = E x ∼ p θ ( x ) [ − ∇ θ E θ ( x ) ] . (13) \nabla_{\theta} \log Z_{\theta} = \frac{1}{Z_{\theta}} \nabla_{\theta} \int\exp\left(-E_{\theta}(\mathbf{x})\right) \, \mathrm{d}\mathbf{x}
= \int\frac{\exp\left(-E_{\theta}(\mathbf{x})\right)}{Z_{\theta}} \left(-\nabla_{\theta} E_{\theta}(\mathbf{x})\right) \, \mathrm{d}\mathbf{x}
= \mathbb{E}_{\mathbf{x}\sim p_{\theta}(\mathbf{x})}\left[-\nabla_{\theta} E_{\theta}(\mathbf{x})\right]. \tag*{(13)} ∇ θ log Z θ = Z θ 1 ∇ θ ∫ exp ( − E θ ( x ) ) d x = ∫ Z θ exp ( − E θ ( x ) ) ( − ∇ θ E θ ( x ) ) d x = E x ∼ p θ ( x ) [ − ∇ θ E θ ( x ) ] . (13)
This expectation can be approximated with samples x ′ \mathbf{x}' x ′ drawn from the model by Markov chain Monte Carlo (MCMC). A convenient sampler for continuous data is Langevin dynamics [118 , 164 ] , which iterates
x τ + 1 = x τ + η 2 ∇ x log p θ ( x τ ) + η ϵ τ , ϵ τ ∼ N ( 0 , I ) , τ = 0 , … , S − 1 , (14) \mathbf{x}_{\tau+1} = \mathbf{x}_{\tau} + \frac{\eta}{2}\nabla_{\mathbf{x}}\log p_{\theta}(\mathbf{x}_{\tau}) + \sqrt{\eta}\,\epsilon_{\tau}, \qquad\epsilon_{\tau} \sim\mathcal{N}(0, I), \qquad\tau= 0,\ldots,S-1, \tag*{(14)} x τ + 1 = x τ + 2 η ∇ x log p θ ( x τ ) + η ϵ τ , ϵ τ ∼ N ( 0 , I ) , τ = 0 , … , S − 1 , (14)
with step size η \eta η . Starting from an initial state x 0 \mathbf{x}_0 x 0 , the sampler is run for a fixed number of steps S S S , and the final state x S \mathbf{x}_S x S is taken as an approximate sample from p θ p_{\theta} p θ . As η → 0 \eta\to0 η → 0 and S → ∞ S \to\infty S → ∞ , the distribution of x S \mathbf{x}_S x S converges to p θ p_{\theta} p θ under mild regularity conditions [164 ] . The sampler requires only the score of the model, the gradient of the log-density with respect to the data, which for an EBM does not involve the partition function,
∇ x log p θ ( x ) = − ∇ x E θ ( x ) − ∇ x log Z θ ⏟ = 0 = − ∇ x E θ ( x ) . (15) \nabla_{\mathbf{x}}\log p_{\theta}(\mathbf{x}) = -\nabla_{\mathbf{x}}E_{\theta}(\mathbf{x}) - \underbrace{\nabla_{\mathbf{x}}\log Z_{\theta}}_{=0}
= -\nabla_{\mathbf{x}}E_{\theta}(\mathbf{x}). \tag*{(15)} ∇ x log p θ ( x ) = − ∇ x E θ ( x ) − = 0 ∇ x log Z θ = − ∇ x E θ ( x ) . (15)
Langevin sampling is thus a noisy descent on the energy, a picture that will reappear in the reverse process of diffusion models. Substituting a model sample x ′ ∼ q θ ( x ) \mathbf{x}' \sim q_{\theta}(\mathbf{x}) x ′ ∼ q θ ( x ) , where q θ q_{\theta} q θ denotes the distribution produced by a finite run of the sampler, into Eq. (12) gives the stochastic gradient
∇ θ log p θ ( x ) ≈ − ∇ θ E θ ( x ) + ∇ θ E θ ( x ′ ) , (16) \nabla_{\theta}\log p_{\theta}(\mathbf{x}) \approx-\nabla_{\theta}E_{\theta}(\mathbf{x}) + \nabla_{\theta}E_{\theta}(\mathbf{x}'), \tag*{(16)} ∇ θ log p θ ( x ) ≈ − ∇ θ E θ ( x ) + ∇ θ E θ ( x ′ ) , (16)
which is the gradient of the contrastive objective
− L C D ( θ ) = E θ ( x ) − E θ ( x ′ ) , (17) -\mathcal{L}_{CD}(\theta) = E_{\theta}(\mathbf{x}) - E_{\theta}(\mathbf{x}'), \tag*{(17)} − L C D ( θ ) = E θ ( x ) − E θ ( x ′ ) , (17)
when x ′ x' x ′ is treated as fixed. Minimizing it lowers the energy of the data and raises the energy of the states the model currently prefers. When the sampler is run for only a few steps starting from the data, the procedure is known as contrastive divergence Hinton [68 ] . The same two-sided principle appears much earlier in the AM literature. The Boltzmann machine is trained by contrasting statistics of the data with statistics of the model Ackley et al. [4 ] , and the unlearning procedure of Hopfield et al. [77 ] removes spurious memories of a Hopfield network by raising the energy of the states into which the network falls on its own. As LeCun et al. [106 ] emphasize, the effect of such objectives is to carve the energy landscape so that the data occupy its valleys while other states are pushed onto its slopes, as illustrated in Figure 2.2 .
Figure 2.2. The effect of training an EBM on the energy landscape around the data points (shown in black). Before training, the data may lie anywhere on the landscape, including at its highest points. After training, the data sit at the lowest points, as local minima of the learned energy.
Score Matching
Contrastive divergence depends on samples from the model, and MCMC samplers can mix slowly in high dimensions, producing samples that miss parts of the distribution [143 ] (Du et al. 2021). Score matching avoids sampling altogether Hyvärinen [79 ] . Instead of comparing probabilities, it compares scores, and fits the model by minimizing the Fisher divergence between the data and the model,
D F ( p d a t a ( x ) ∥ p θ ( x ) ) = E p d a t a ( x ) [ 1 2 ∥ ∇ x log p d a t a ( x ) − ∇ x log p θ ( x ) ∥ 2 2 ] . (18) D_F\left(p_{\mathrm{data}}(\mathbf{x}) \mathbin{\|} p_\theta(\mathbf{x})\right) = \mathbb{E}_{p_{\mathrm{data}}(\mathbf{x})}\left[\frac{1}{2}\left\|\nabla_{\mathbf{x}}\log p_{\mathrm{data}}(\mathbf{x})-\nabla_{\mathbf{x}}\log p_\theta(\mathbf{x})\right\|_2^2\right]. \tag*{(18)} D F ( p data ( x ) ∥ p θ ( x ) ) = E p data ( x ) [ 2 1 ∥ ∇ x log p data ( x ) − ∇ x log p θ ( x ) ∥ 2 2 ] . (18)
Because the scores do not involve normalization constants, Z θ Z_\theta Z θ never appears. The score of the data is unknown, but Hyvärinen [79 ] showed by integration by parts that, under mild regularity conditions, Eq. (18) equals, up to a constant, an objective that depends only on the energy and its derivatives,
L S M ( θ ) = E p d a t a ( x ) [ ∑ i = 1 N ( 1 2 ( ∂ E θ ( x ) ∂ x i ) 2 − ∂ 2 E θ ( x ) ∂ x i 2 ) ] + constant , (19) \mathcal{L}_{\mathrm{SM}}(\theta)=\mathbb{E}_{p_{\mathrm{data}}(\mathbf{x})}\left[\sum_{i=1}^{N}\left(\frac{1}{2}\left(\frac{\partial E_\theta(\mathbf{x})}{\partial x_i}\right)^2-\frac{\partial^2 E_\theta(\mathbf{x})}{\partial x_i^2}\right)\right]+\text{constant}, \tag*{(19)} L SM ( θ ) = E p data ( x ) [ i = 1 ∑ N ( 2 1 ( ∂ x i ∂ E θ ( x ) ) 2 − ∂ x i 2 ∂ 2 E θ ( x ) ) ] + constant , (19)
where N N N is the dimension of x \mathbf{x} x . Minimizing L S M \mathcal{L}_{\mathrm{SM}} L SM recovers the true parameters in the limit of infinite data Hyvärinen [79 ] . The second derivatives are its weakness. The trace of the Hessian of the energy requires N N N backward passes, which is prohibitive for images and other high-dimensional data. Stochastic trace estimators reduce this cost [78 , 144 ] , but a simpler and more widely used solution is to add noise to the data.
Denoising Score Matching
Score matching also assumes that log p d a t a \log p_{\mathrm{data}} log p data is differentiable over the whole input space. Real data often violate this assumption. Images, for example, are quantized to integer pixel values and occupy a thin subset of their ambient space, so their score may be undefined [147 ] . Both problems are addressed by perturbing the data with Gaussian noise,
x ~ = x + σ ϵ , ϵ ∼ N ( 0 , I ) , (20) \tilde{x} = x + \sigma\epsilon,\qquad\epsilon\sim\mathcal{N}(0, I), \tag*{(20)} x ~ = x + σ ϵ , ϵ ∼ N ( 0 , I ) , (20)
which replaces the data distribution with the smoothed distribution
q σ ( x ~ ) = ∫ q σ ( x ~ ∣ x ) p d a t a ( x ) d x , (21) q_{\sigma}(\tilde{x}) = \int q_{\sigma}(\tilde{x} \mid x)\,p_{\mathrm{data}}(x)\,\mathrm{d}x, \tag*{(21)} q σ ( x ~ ) = ∫ q σ ( x ~ ∣ x ) p data ( x ) d x , (21)
whose score is defined everywhere. Matching the score of this smoothed distribution turns out to be equivalent, up to a constant, to matching the score of the known noise kernel [158 ] ,
D F ( q σ ( x ~ ) ∥ p θ ( x ~ ) ) = E q σ ( x ~ ) [ 1 2 ∥ ∇ x ~ log q σ ( x ~ ) − ∇ x ~ log p θ ( x ~ ) ∥ 2 2 ] = E q σ ( x , x ~ ) [ 1 2 ∥ ∇ x ~ log q σ ( x ~ ∣ x ) − ∇ x ~ log p θ ( x ~ ) ∥ 2 2 ] + constant . (22) \begin{aligned}
D_F\left(q_{\sigma}(\tilde{x}) \mathbin{\|} p_{\theta}(\tilde{x})\right)
&= \mathbb{E}_{q_{\sigma}(\tilde{x})}\left[\frac{1}{2}\left\|\nabla_{\tilde{x}}\log q_{\sigma}(\tilde{x})-\nabla_{\tilde{x}}\log p_{\theta}(\tilde{x})\right\|_2^2\right] \\
&= \mathbb{E}_{q_{\sigma}(x,\tilde{x})}\left[\frac{1}{2}\left\|\nabla_{\tilde{x}}\log q_{\sigma}(\tilde{x}\mid x)-\nabla_{\tilde{x}}\log p_{\theta}(\tilde{x})\right\|_2^2\right] + \text{constant}. \tag*{(22)}
\end{aligned} D F ( q σ ( x ~ ) ∥ p θ ( x ~ ) ) = E q σ ( x ~ ) [ 2 1 ∥ ∇ x ~ log q σ ( x ~ ) − ∇ x ~ log p θ ( x ~ ) ∥ 2 2 ] = E q σ ( x , x ~ ) [ 2 1 ∥ ∇ x ~ log q σ ( x ~ ∣ x ) − ∇ x ~ log p θ ( x ~ ) ∥ 2 2 ] + constant . (22)
The second line contains neither the unknown data score nor second derivatives. For the Gaussian kernel, ∇ x ~ log q σ ( x ~ ∣ x ) = − ( x ~ − x ) / σ 2 = − ϵ / σ \nabla_{\tilde{x}}\log q_{\sigma}(\tilde{x}\mid x)=-(\tilde{x}-x)/\sigma^2=-\epsilon/\sigma ∇ x ~ log q σ ( x ~ ∣ x ) = − ( x ~ − x ) / σ 2 = − ϵ / σ , and the objective becomes the denoising score matching loss [158 , 143 ] ,
L D S M ( θ ) = E p d a t a ( x ) , ϵ ∼ N ( 0 , I ) [ 1 2 ∥ ∇ x log p θ ( x + σ ϵ ) + ϵ σ ∥ 2 2 ] . (23) \mathcal{L}_{\mathrm{DSM}}(\theta)=\mathbb{E}_{p_{\mathrm{data}}(x),\,\epsilon\sim\mathcal{N}(0,I)}\left[\frac{1}{2}\left\lVert\nabla_x\log p_\theta(x+\sigma\epsilon)+\frac{\epsilon}{\sigma}\right\rVert_2^2\right]. \tag*{(23)} L DSM ( θ ) = E p data ( x ) , ϵ ∼ N ( 0 , I ) [ 2 1 ∇ x log p θ ( x + σ ϵ ) + σ ϵ 2 2 ] . (23)
The model learns to point from a noisy observation back toward the clean data, which is why the objective is called denoising. The price is that the model learns the score of q σ q_\sigma q σ rather than that of p d a t a p_{\mathrm{data}} p data . A small σ \sigma σ keeps the two close, but makes the score hard to learn far from the data, where few noisy samples fall. Diffusion models resolve this trade-off by learning the score at many noise levels at once. The objective in Eq. (23) is already the training objective of a variance-exploding diffusion model restricted to a single noise level [140 , 147 ] (Ho et al. 2020), and we develop this connection in § 3.3 .
Diffusion Models
The denoising score matching objective (23) learns the score of the data at a single, small noise level. Diffusion models extend this idea in two ways. They learn the score across a whole range of noise levels, from nearly clean data to pure noise, and they use these scores to transform noise back into data [140 , 143 , 147 ] (Ho et al. 2020). This simple recipe now underlies state-of-the-art generators of images [127 ] , audio [31 , 94 ] , and video [20 ] (Ho et al. 2022). A diffusion model consists of two processes. The forward process gradually corrupts data with noise until no trace of the original sample remains. The reverse process, learned by a neural network, gradually removes the noise to produce a sample. Figure 2.3 illustrates the forward process.
Figure 2.3. The forward process of a diffusion model. A clean image x 0 x_0 x 0 is progressively corrupted by Gaussian noise over T T T steps, until x T x_T x T is indistinguishable from pure noise (top row). The corresponding marginal distribution (bottom row) evolves from the complex and multimodal data distribution p d a t a p_{\mathrm{data}} p data toward a simple Gaussian. Generation reverses this process. It starts from a sample of the Gaussian and removes the noise step by step until a sample resembling the data is obtained. Reproduced from: Krotov, D., Hoover, B., Ram, P., & Pham, B. (2025). Modern methods in associative memory . arXiv. https://doi.org/10.48550/arXiv.2507.06211
The Forward Process
In the discrete-time formulation of Ho et al. (2020), the forward process is a Markov chain that adds a small amount of Gaussian noise at each step,
q ( x t ∣ x t − 1 ) = N ( x t ; 1 − β t x t − 1 , β t I ) , t = 1 , … , T , (24) q(x_t\mid x_{t-1})=\mathcal{N}\left(x_t;\sqrt{1-\beta_t}\,x_{t-1},\beta_t I\right),\qquad t=1,\ldots,T, \tag*{(24)} q ( x t ∣ x t − 1 ) = N ( x t ; 1 − β t x t − 1 , β t I ) , t = 1 , … , T , (24)
where x 0 ∼ p d a t a ( x ) x_0\sim p_{\mathrm{data}}(x) x 0 ∼ p data ( x ) and β t ∈ ( 0 , 1 ) \beta_t\in(0,1) β t ∈ ( 0 , 1 ) is a prescribed variance schedule. Because a composition of Gaussian transitions is again Gaussian, the noisy sample at any step can be obtained from the clean sample in closed form,
q ( x t ∣ x 0 ) = N ( x t ; α ˉ t x 0 , ( 1 − α ˉ t ) I ) , α ˉ t = ∏ s = 1 t ( 1 − β s ) , (25) q(\mathbf{x}_t \mid\mathbf{x}_0) = \mathcal{N}\left(\mathbf{x}_t; \sqrt{\bar{\alpha}_t}\mathbf{x}_0, (1-\bar{\alpha}_t)I\right), \qquad\bar{\alpha}_t = \prod_{s=1}^{t}(1-\beta_s), \tag*{(25)} q ( x t ∣ x 0 ) = N ( x t ; α ˉ t x 0 , ( 1 − α ˉ t ) I ) , α ˉ t = s = 1 ∏ t ( 1 − β s ) , (25)
or equivalently x t = α ˉ t x 0 + 1 − α ˉ t ϵ \mathbf{x}_t = \sqrt{\bar{\alpha}_t}\mathbf{x}_0 + \sqrt{1-\bar{\alpha}_t}\,\epsilon x t = α ˉ t x 0 + 1 − α ˉ t ϵ with ϵ ∼ N ( 0 , I ) \epsilon\sim\mathcal{N}(0,I) ϵ ∼ N ( 0 , I ) . The schedule is chosen such that α ˉ T ≈ 0 \bar{\alpha}_T \approx0 α ˉ T ≈ 0 , so that x T \mathbf{x}_T x T is distributed approximately as N ( 0 , I ) \mathcal{N}(0,I) N ( 0 , I ) regardless of the initial sample. The marginal distribution at step t t t ,
q t ( x t ) = ∫ q ( x t ∣ x 0 ) p d a t a ( x 0 ) d x 0 , (26) q_t(\mathbf{x}_t) = \int q(\mathbf{x}_t \mid\mathbf{x}_0)\,p_{\mathrm{data}}(\mathbf{x}_0)\,\mathrm{d}\mathbf{x}_0, \tag*{(26)} q t ( x t ) = ∫ q ( x t ∣ x 0 ) p data ( x 0 ) d x 0 , (26)
is a smoothed version of the data distribution, and the smoothing grows with t t t . This is the progression shown in the bottom row of Figure 2.3 , in which the modes of p d a t a p_{\mathrm{data}} p data gradually merge into a single Gaussian.
The Reverse Process and Training
Generation runs the chain backward. Starting from x T ∼ N ( 0 , I ) \mathbf{x}_T \sim\mathcal{N}(0,I) x T ∼ N ( 0 , I ) , the model draws samples from learned transitions
p θ ( x t − 1 ∣ x t ) = N ( x t − 1 ; μ θ ( x t , t ) , σ t 2 I ) , (27) p_\theta(\mathbf{x}_{t-1} \mid\mathbf{x}_t) = \mathcal{N}\left(\mathbf{x}_{t-1}; \boldsymbol{\mu}_\theta(\mathbf{x}_t,t), \sigma_t^2 I\right), \tag*{(27)} p θ ( x t − 1 ∣ x t ) = N ( x t − 1 ; μ θ ( x t , t ) , σ t 2 I ) , (27)
which are approximately Gaussian when each forward step adds only a small amount of noise [140 ] . The parameters are trained by maximizing a variational lower bound on the log-likelihood log p θ ( x 0 ) \log p_\theta(\mathbf{x}_0) log p θ ( x 0 ) , so diffusion models remain likelihood-based models in the sense of § 3.1.1 . Ho et al. (2020) showed that, if the mean is parameterized through a network ϵ θ ( x t , t ) \epsilon_\theta(\mathbf{x}_t,t) ϵ θ ( x t , t ) that predicts the noise added to the sample,
μ θ ( x t , t ) = 1 1 − β t ( x t − β t 1 − α ˉ t ϵ θ ( x t , t ) ) , (28) \boldsymbol{\mu}_\theta(\mathbf{x}_t,t) = \frac{1}{\sqrt{1-\beta_t}}\left(\mathbf{x}_t - \frac{\beta_t}{\sqrt{1-\bar{\alpha}_t}}\epsilon_\theta(\mathbf{x}_t,t)\right), \tag*{(28)} μ θ ( x t , t ) = 1 − β t 1 ( x t − 1 − α ˉ t β t ϵ θ ( x t , t ) ) , (28)
then the bound reduces, up to a weighting of its terms, to a simple regression objective,
L s i m p l e ( θ ) = E t , x 0 , ϵ [ ∥ ϵ − ϵ θ ( α ˉ t x 0 + 1 − α ˉ t ϵ , t ) ∥ 2 2 ] , (29) \mathcal{L}_{\mathrm{simple}}(\theta) = \mathbb{E}_{t,\mathbf{x}_0,\epsilon}\left[\left\lVert\epsilon- \epsilon_\theta\left(\sqrt{\bar{\alpha}_t}\mathbf{x}_0 + \sqrt{1-\bar{\alpha}_t}\epsilon,t\right)\right\rVert_2^2\right], \tag*{(29)} L simple ( θ ) = E t , x 0 , ϵ [ ϵ − ϵ θ ( α ˉ t x 0 + 1 − α ˉ t ϵ , t ) 2 2 ] , (29)
where t t t is drawn uniformly from { 1 , … , T } \{1,\ldots,T\} { 1 , … , T } .
The noise-prediction objective is denoising score matching in disguise. From Eq. (25) , the score of the forward transition is ∇ x t log q ( x t ∣ x 0 ) = − ε / 1 − α ˉ t \nabla_{x_t} \log q(x_t \mid x_0) = -\varepsilon/\sqrt{1-\bar{\alpha}_t} ∇ x t log q ( x t ∣ x 0 ) = − ε / 1 − α ˉ t . Predicting the noise is therefore equivalent to estimating the score of the noisy data, with
s θ ( x t , t ) = − ε θ ( x t , t ) 1 − α ˉ t ≈ ∇ x t log q t ( x t ) , (30) s_\theta(x_t,t)=-\frac{\varepsilon_\theta(x_t,t)}{\sqrt{1-\bar{\alpha}_t}}\approx\nabla_{x_t}\log q_t(x_t), \tag*{(30)} s θ ( x t , t ) = − 1 − α ˉ t ε θ ( x t , t ) ≈ ∇ x t log q t ( x t ) , (30)
and Eq. (29) is a weighted sum of the denoising score matching objective (22) over all noise levels. A diffusion model is thus a single network that has learned the score of the data at every degree of corruption.
A Continuous-Time View
Song, Sohl-Dickstein, et al. [147 ] unified these models by taking the number of steps to infinity. The forward process then becomes a stochastic differential equation (SDE),
d x t = f ( x t , t ) d t + g ( t ) d w t , (31) \mathrm{d}x_t=f(x_t,t)\,\mathrm{d}t+g(t)\,\mathrm{d}w_t, \tag*{(31)} d x t = f ( x t , t ) d t + g ( t ) d w t , (31)
where w t w_t w t is a standard Wiener process, f f f is a drift, and g g g is a diffusion coefficient. The chain in Eq. (24) is a discretization of the variance-preserving choice f ( x , t ) = − 1 2 β ( t ) x f(x,t)=-\frac{1}{2}\beta(t)x f ( x , t ) = − 2 1 β ( t ) x and g ( t ) = β ( t ) g(t)=\sqrt{\beta(t)} g ( t ) = β ( t ) , whereas the variance-exploding choice f = 0 f=0 f = 0 recovers the multi-scale denoising score matching of Song & Ermon [143 ] . A classical result of Anderson [12 ] states that this process can be reversed in time by the SDE
d x t = [ f ( x t , t ) − g ( t ) 2 ∇ x t log p t ( x t ) ] d t + g ( t ) d w ˉ t , (32) \mathrm{d}x_t = \left[f(x_t,t) - g(t)^2 \nabla_{x_t} \log p_t(x_t)\right]\mathrm{d}t + g(t)\,\mathrm{d}\bar{w}_t, \tag*{(32)} d x t = [ f ( x t , t ) − g ( t ) 2 ∇ x t log p t ( x t ) ] d t + g ( t ) d w ˉ t , (32)
where time flows backward and w ˉ t \bar{w}_t w ˉ t is a Wiener process in reversed time. The only unknown quantity is the score ∇ x log p t ( x ) \nabla_x \log p_t(x) ∇ x log p t ( x ) , which is approximated by a network s θ ( x , t ) s_\theta(x,t) s θ ( x , t ) trained with the time-weighted denoising score matching objective
θ ∗ = arg min θ E t , x 0 , x t [ λ ( t ) ∥ s θ ( x t , t ) − ∇ x t log p ( x t ∣ x 0 ) ∥ 2 2 ] , (33) \theta^* = \underset{\theta}{\arg\min}\ \mathbb{E}_{t,x_0,x_t}\left[\lambda(t)\left\|s_\theta(x_t,t)-\nabla_{x_t}\log p(x_t\mid x_0)\right\|_2^2\right], \tag*{(33)} θ ∗ = θ arg min E t , x 0 , x t [ λ ( t ) ∥ s θ ( x t , t ) − ∇ x t log p ( x t ∣ x 0 ) ∥ 2 2 ] , (33)
with a positive weighting function λ ( t ) \lambda(t) λ ( t ) . The same marginal distributions are also produced by a deterministic probability flow ordinary differential equation,
d x t = [ f ( x t , t ) − 1 2 g ( t ) 2 ∇ x t log p t ( x t ) ] d t , (34) \mathrm{d}x_t = \left[f(x_t,t)-\frac{1}{2}g(t)^2\nabla_{x_t}\log p_t(x_t)\right]\mathrm{d}t, \tag*{(34)} d x t = [ f ( x t , t ) − 2 1 g ( t ) 2 ∇ x t log p t ( x t ) ] d t , (34)
which underlies fast deterministic samplers [146 ] (Song, Sohl-Dickstein, et al. 2021).
Diffusion Models as Energy-Based Models
Because the score is the gradient of a log density, a diffusion model can be read through the lens of § 3.2 . Writing the noisy marginal as p t ( x ) ∝ exp ( − E t ( x ) ) p_t(x) \propto\exp(-E_t(x)) p t ( x ) ∝ exp ( − E t ( x )) , the learned score approximates s θ ( x , t ) ≈ − ∇ x E t ( x ) s_\theta(x,t) \approx-\nabla_x E_t(x) s θ ( x , t ) ≈ − ∇ x E t ( x ) . A diffusion model is then a family of EBMs indexed by the noise level, and the reverse process is a noisy descent on an energy landscape that changes with time. At high noise the landscape is smooth and has a single broad basin, as in the rightmost distribution of Figure 2.3 . As the noise decreases, the landscape sharpens and its minima move toward the regions where the data concentrate. By learning only the gradient of the energy, diffusion models sidestep the intractable partition function that complicates the training of EBMs. The score network is, however, a generic neural network, and it is not guaranteed to be the exact gradient of any energy function.
This reading raises a question that is central to this thesis. If the score network were perfectly accurate on a finite training set, p t p_t p t would be the empirical distribution of the training data smoothed by Gaussian noise, and the reverse process would return only the training samples (Gu et al., 2025; [18 ] . A diffusion model that generalizes must therefore depart from this ideal in a structured way. As we discuss in Chapter 3, the energy implied by this idealized score takes the form of a DenseAM energy ([9 ] (Hoover, Strobelт, et al. 2023)), which makes the theory of AMs reviewed in § 3.4 a natural tool for understanding when diffusion models memorize and when they generalize.
Discrete Diffusion Models
Text is composed of discrete tokens, for which Gaussian noise is not defined. Discrete diffusion models replace it with a corruption process over a finite vocabulary ([14 , 25 , 55 , 131 ] ). Let each token be represented by a one-hot vector x ∈ V = { x ∈ { 0 , 1 } V : ∑ i = 1 V x i = 1 } \mathbf{x} \in\mathcal{V} = \{\mathbf{x} \in\{0,1\}^{V} : \sum_{i=1}^{V}x_i=1\} x ∈ V = { x ∈ { 0 , 1 } V : ∑ i = 1 V x i = 1 } , where V V V is the vocabulary size. The forward process interpolates between the clean token and a fixed prior distribution π \boldsymbol{\pi} π over the vocabulary,
q t ( z t ∣ x ) = Cat ( z t ; α t x + ( 1 − α t ) π ) , t ∈ [ 0 , 1 ] , (35) q_t(z_t \mid\mathbf{x}) = \operatorname{Cat}(z_t; \alpha_t\mathbf{x} + (1-\alpha_t)\boldsymbol{\pi}), \qquad t \in[0,1], \tag*{(35)} q t ( z t ∣ x ) = Cat ( z t ; α t x + ( 1 − α t ) π ) , t ∈ [ 0 , 1 ] , (35)
where Cat ( ⋅ ) \operatorname{Cat}(\cdot) Cat ( ⋅ ) is a categorical distribution and α t \alpha_t α t decreases from α 0 ≈ 1 \alpha_0 \approx1 α 0 ≈ 1 to α 1 ≈ 0 \alpha_1 \approx0 α 1 ≈ 0 . Two choices of prior are common. In masked diffusion, π \boldsymbol{\pi} π places all of its mass on a special mask token, so corruption hides tokens ([14 , 131 ] ). In uniform-state diffusion, π = 1 / V \boldsymbol{\pi}=1/V π = 1/ V , so corruption replaces tokens with random ones ([14 , 132 ] ). In the uniform case, a corrupted token looks like any other token, and the model must judge every position of the sequence, including tokens that may already be correct. Generation can therefore revise tokens repeatedly, much as the state of an AM is updated until it settles.
For a time s < t s<t s < t , the reverse transition of this forward process is available in closed form once the clean token is known ([14 , 25 ] ),
q s ∣ t ( z s ∣ z t , x ) = q t ∣ s ( z t ∣ z s ) q s ( z s ∣ x ) q t ( z t ∣ x ) , (36) q_{s\mid t}(z_s \mid z_t,\mathbf{x}) = \frac{q_{t\mid s}(z_t \mid z_s)q_s(z_s \mid\mathbf{x})}{q_t(z_t \mid\mathbf{x})}, \tag*{(36)} q s ∣ t ( z s ∣ z t , x ) = q t ( z t ∣ x ) q t ∣ s ( z t ∣ z s ) q s ( z s ∣ x ) , (36)
which is again a categorical distribution whose probabilities are fixed by z t z_t z t , x \mathbf{x} x , π \boldsymbol{\pi} π , and the schedule α t \alpha_t α t . During generation the clean token is unknown, so it is replaced by the prediction of a network x θ ( z t , t ) \mathbf{x}_{\theta}(z_t,t) x θ ( z t , t ) ,
p θ ( z s ∣ z t ) = q s ∣ t ( z s ∣ z t , x = x θ ( z t , t ) ) , x θ ( z t , t ) = p θ ( x ∣ z t ) ∈ Δ V , (37) p_{\theta}(z_s \mid z_t) = q_{s\mid t}(z_s \mid z_t,\mathbf{x}=\mathbf{x}_{\theta}(z_t,t)), \qquad\mathbf{x}_{\theta}(z_t,t)=p_{\theta}(\mathbf{x}\mid z_t)\in\Delta^{V}, \tag*{(37)} p θ ( z s ∣ z t ) = q s ∣ t ( z s ∣ z t , x = x θ ( z t , t )) , x θ ( z t , t ) = p θ ( x ∣ z t ) ∈ Δ V , (37)
where Δ V \Delta^{V} Δ V denotes the probability simplex over the vocabulary. The output of the network is therefore not a direction in which to move, but a categorical distribution over which clean token occupies each position. For a sequence of L L L tokens, the network reads the entire corrupted sequence z t 1 : L z_{t}^{1:L} z t 1 : L and returns one such distribution p θ ( x ℓ ∣ z t 1 : L ) p_{\theta}(x^{\ell} \mid z_{t}^{1:L}) p θ ( x ℓ ∣ z t 1 : L ) for every position ℓ \ell ℓ .
The parameters are trained by minimizing the negative evidence lower bound (NELBO) on the log-likelihood of the data [14 , 131 ] ,
L N E L B O ( θ ) = E q [ − log p θ ( x ∣ z t ϵ ) + ∑ s < t D K L ( q s ∣ t ( z s ∣ z t , x ) ∥ p θ ( z s ∣ z t ) ) ] + D K L ( q 1 ( z 1 ∣ x ) ∥ p ( z 1 ) ) (38) \mathcal{L}_{\mathrm{NELBO}}(\theta)=\mathbb{E}_{q}\left[-\log p_{\theta}(\mathbf{x}\mid\mathbf{z}_{t_{\epsilon}})+\sum_{s<t}D_{\mathrm{KL}}\left(q_{s\mid t}(\mathbf{z}_{s}\mid\mathbf{z}_{t},\mathbf{x})\mathbin{\|}p_{\theta}(\mathbf{z}_{s}\mid\mathbf{z}_{t})\right)\right]+D_{\mathrm{KL}}\left(q_{1}(\mathbf{z}_{1}\mid\mathbf{x})\mathbin{\|}p(\mathbf{z}_{1})\right) \tag*{(38)} L NELBO ( θ ) = E q [ − log p θ ( x ∣ z t ϵ ) + s < t ∑ D KL ( q s ∣ t ( z s ∣ z t , x ) ∥ p θ ( z s ∣ z t ) ) ] + D KL ( q 1 ( z 1 ∣ x ) ∥ p ( z 1 ) ) (38)
where the prior term does not depend on θ \theta θ . Because the true and learned reverse transitions in Eq. (37) differ only in whether the clean token is given or predicted, every term that depends on θ \theta θ is a function of the predicted distribution p θ ( x ∣ z t ) p_{\theta}(\mathbf{x}\mid\mathbf{z}_{t}) p θ ( x ∣ z t ) alone. The reconstruction term makes this explicit. For a sequence, it is the cross-entropy between the clean tokens and the predictions of the network,
L r e c o n s t r u c t i o n ( θ ) = − ∑ ℓ = 1 L log p θ ( x ℓ ∣ z t ϵ 1 : L ) = − ∑ ℓ = 1 L ⟨ x ℓ , log x θ ℓ ( z t ϵ 1 : L , t ϵ ) ⟩ (39) \mathcal{L}_{\mathrm{reconstruction}}(\theta)=-\sum_{\ell=1}^{L}\log p_{\theta}\left(x^{\ell}\mid z_{t_{\epsilon}}^{1:L}\right)=-\sum_{\ell=1}^{L}\left\langle x^{\ell},\log x_{\theta}^{\ell}\left(z_{t_{\epsilon}}^{1:L},t_{\epsilon}\right)\right\rangle \tag*{(39)} L reconstruction ( θ ) = − ℓ = 1 ∑ L log p θ ( x ℓ ∣ z t ϵ 1 : L ) = − ℓ = 1 ∑ L ⟨ x ℓ , log x θ ℓ ( z t ϵ 1 : L , t ϵ ) ⟩ (39)
where t ϵ t_{\epsilon} t ϵ is a small time close to zero. Note that z t ϵ z_{t_{\epsilon}} z t ϵ is not necessarily a clean sequence itself. Since α t ϵ ≈ 1 \alpha_{t_{\epsilon}}\approx1 α t ϵ ≈ 1 rather than exactly one, z t ϵ z_{t_{\epsilon}} z t ϵ is a slightly perturbed version of x \mathbf{x} x produced by the forward process at this small time, and the reconstruction term asks the network to recover the clean tokens from an input that is nearly, but not exactly, clean. The diffusion term compares, position by position, the posterior obtained from the true token with the posterior obtained from the predicted one. In the masked case, the continuous-time limit of Eq. (38) reduces exactly to a time-weighted cross-entropy over the masked positions [131 ] ,
L N E L B O ∞ ( θ ) = E q ∫ 0 1 α t ′ 1 − α t ∑ ℓ = 1 L log x θ ℓ ( z t 1 : L , t ) , x ℓ d t (40) \mathcal{L}_{\mathrm{NELBO}}^{\infty}(\theta)=\mathbb{E}_{q}\int_{0}^{1}\frac{\alpha_{t}^{\prime}}{1-\alpha_{t}}\sum_{\ell=1}^{L}\log x_{\theta}^{\ell}\left(z_{t}^{1:L},t\right),x^{\ell}\,dt \tag*{(40)} L NELBO ∞ ( θ ) = E q ∫ 0 1 1 − α t α t ′ ℓ = 1 ∑ L log x θ ℓ ( z t 1 : L , t ) , x ℓ d t (40)
where α t ′ < 0 \alpha_{t}^{\prime}<0 α t ′ < 0 is the time derivative of the schedule, so that each term is a positively weighted negative log-probability of the correct token.
These objectives differ from their continuous counterparts in an important way. A continuous diffusion model learns a score s θ ( x t , t ) s_\theta(\mathbf{x}_t,t) s θ ( x t , t ) , or equivalently the noise ϵ θ ( x t , t ) \epsilon_\theta(\mathbf{x}_t,t) ϵ θ ( x t , t ) to be removed, which tells the sampler in which direction and by how much to move the current state. Nothing of this kind is learned here. The network never estimates a gradient of a log density or the amount of corruption to undo. How far each reverse step travels is fixed entirely by the schedule α t \alpha_t α t and the closed-form posterior in Eq. (36) . What the network learns is a classifier, the conditional likelihood of each clean token given a corrupted version of the others. As we discuss in Chapter 4, this is the same structure as the pseudo-likelihood objective for AMs [17 , 34 ] , and it is the reason basins of attraction can form in these models without an explicit energy function.
Associative Memory Networks
The previous sections described generative models whose goal is to approximate a data distribution, and showed that their training objectives, taken literally, reward memorization of the training set. We now turn to a class of models for which memorization is not a side effect but the very object of study. Associative Memory (AM) networks, also known as Hopfield networks, offer a complementary and historically rich perspective on energy-based dynamical neural systems.
These networks are designed to store and retrieve patterns by leveraging attractor dynamics on an energy landscape. Unlike generative models that aim to model the full data distribution, AM networks encode a finite set of patterns and recover them from noisy or incomplete cues. Originally inspired by physical systems such as magnets and spin glasses, and by biological principles such as Hebbian learning [65 ] , AM networks provide a clean and interpretable view of how information can be embedded in and recovered from a neural system.
From the beginning, the central question of AM theory has been one of capacity. How many patterns can a network of a given size store and reliably retrieve? How large is the basin of attraction around each memory, and how does it shrink as more patterns are stored? What happens to the energy landscape once the capacity is exceeded? These questions have been studied for four decades with the tools of statistical mechanics [10 , 11 , 53 ] , and they have produced a precise vocabulary for memorization. A memory is a fixed point of the dynamics, its robustness is the size of its basin, and the limit of what a network can memorize is its capacity. More recently, the same theory has begun to describe generalization. When an AM is loaded beyond its capacity with patterns that share an underlying structure, it can form new attractors near examples it has never stored [85 ] (D’Amico, Bocchi, et al. 2026).
This combination is what makes AM essential to the questions of this thesis. Generative models are judged by whether they memorize or generalize, yet they rarely offer a direct way to see what they have stored. AM networks offer exactly this. Their memories are explicit, their retrieval dynamics are guaranteed to converge, and the transition from storing patterns to creating new ones can be located and measured. If modern generative models can be described as AMs, then this vocabulary of fixed points, basins, capacity, and spurious states becomes a language for explaining their behavior.
In this section, we provide an overview of classical and modern AM networks. We examine the core mechanisms behind their storage and retrieval, discuss their capacity and the spurious states that appear beyond it, and review Dense Associative Memories and their connection to attention. The connections between these ideas and diffusion models are developed in the later chapters.
Classical Associative Memories
In the midst of the second Artificial Intelligence (AI) winter, Hopfield networks were introduced as models of how biological brains might store and recall information. Developed by Hopfield [75 ] , while unknowingly building on the earlier work of Amari [8 ] and on the Lenz-Ising model introduced in 1920 [23 ] , these models became one of the first concrete examples of a dynamical neural network capable of storing binary patterns as local minima of an energy landscape and retrieving them. As a result, Hopfield networks helped revitalize interest in artificial neural networks at the time.
The inspiration behind AM networks came from two key sources, magnetism and Hebbian learning. From physics, Hopfield [75 ] borrowed the idea that a system can settle into a low-energy configuration, similar to how magnetic spins align with one another. Each stable pattern, or memory, corresponds to a local minimum of the energy landscape of the system. From neuroscience, the Hebbian learning rule [65 , 47 , 128 ] , often summarized as “neurons that fire together wire together,” served as the foundation for storing patterns in the network. In classical networks, this rule strengthens the connections between co-activated neurons, allowing the system to encode patterns through their correlations and later retrieve them.
Specifically, using the Hebbian learning rule, these networks form a symmetric weight matrix W ∈ R N × N W \in\mathbb{R}^{N \times N} W ∈ R N × N ,
W = ∑ μ = 1 K ξ μ ( ξ μ ) ⊤ , (41) \mathbf{W} = \sum_{\mu=1}^{K} \boldsymbol{\xi}^{\mu} \left(\boldsymbol{\xi}^{\mu}\right)^{\top}, \tag*{(41)} W = μ = 1 ∑ K ξ μ ( ξ μ ) ⊤ , (41)
to store a set of K K K patterns ξ μ ∈ { ± 1 } N \boldsymbol{\xi}^{\mu} \in\{\pm1\}^{N} ξ μ ∈ { ± 1 } N . The diagonal entries of W \mathbf{W} W are set to zero to prevent self-connections. Once the matrix W \mathbf{W} W is formed, retrieval is governed by an energy function. Given a binary query x ∈ { ± 1 } N \mathbf{x} \in\{\pm1\}^{N} x ∈ { ± 1 } N , the energy introduced by Hopfield [75 ] is
E ( x ) = − 1 2 x T W x . (42) E(\mathbf{x}) = -\frac{1}{2}\mathbf{x}^{\mathsf{T}}\mathbf{W}\mathbf{x}. \tag*{(42)} E ( x ) = − 2 1 x T Wx . (42)
This energy determines the dynamics of the network, which iteratively updates the query x \mathbf{x} x so as to reduce its energy. The most common scheme is the asynchronous update, in which one neuron at a time aligns with the sign of its local field, x i ← sgn ( ∑ j W i j x j ) x_i \leftarrow\operatorname{sgn}\left(\sum_j W_{ij}x_j\right) x i ← sgn ( ∑ j W ij x j ) (Hopfield, [75 , 76 ] ). Because each such update can only decrease the energy, the dynamics are guaranteed to converge to a fixed point. Synchronous updates, in which all neurons are updated simultaneously, have also been studied, but they can lead to oscillations because the energy is no longer guaranteed to decrease monotonically ([32 , 66 ] ). If the number of stored patterns K K K is below the capacity of the network, a noisy or incomplete version of a stored pattern is guided by the dynamics to the nearest attractor, which is the stored memory itself. This attractor-based behavior is the core mechanism behind pattern completion and retrieval in AM networks, as illustrated in Figure 2.4 .
Figure 2.4. An illustration of the retrieval process in a high-capacity AM network. Given a query x \mathbf{x} x , the network performs gradient descent on its energy function with respect to the query. Because the energy is a Lyapunov function [110 ] , the dynamics are guaranteed to settle at a fixed point, here the memory x ∗ \mathbf{x}^{*} x ∗ closest to the query. The animal images are retrieved from the ImageNet-1K dataset [40 ] .
A crucial property of Hopfield networks is that their energy function is a Lyapunov function, a function that decreases monotonically along the trajectories of the system and is bounded from below ([110 ] ). This property ensures that the dynamics are stable and converge to a local minimum of the energy landscape. The set of initial states that flow to a given minimum is its basin of attraction, and its size measures how much corruption a memory can tolerate before it is lost. Thus, unlike standard recurrent neural networks ([48 , 71 , 83 ] ), which process sequences of inputs and learn temporal dependencies, AM networks perform fixed-point retrieval by evolving an input state toward a local energy minimum through gradient descent-like dynamics.
Memory Capacity and Spurious States
The capacity of the classical AM network was the first question asked of it, and its answer exposed the most important limitation of the model. Hopfield [75 ] observed experimentally that a network of N N N neurons can store roughly 0.15 N 0.15N 0.15 N random, uncorrelated patterns. Using the replica method from the statistical mechanics of spin glasses, Amit et al. [10 ] later derived the critical capacity analytically, K max ≈ 0.14 N K^{\max} \approx0.14N K m a x ≈ 0.14 N . The analysis revealed a sharp transition governed by the load α = K / N \alpha= K/N α = K / N . Below the critical load, the stored patterns are stable attractors with finite basins. Above it, interference between the patterns destroys them all at once, and the network enters a phase in which no stored pattern can be retrieved [11 ] . As more patterns are added, the attractor landscape thus becomes increasingly crowded, recall becomes unstable, and the dynamics converge to incorrect states [1 ] .
The capacity of the Hebbian rule is not the capacity of the network itself. Gardner [53 ] asked how many patterns could be stored by any choice of couplings, and showed that the answer reaches K max = 2 N K^{\max} = 2N K m a x = 2 N for uncorrelated patterns. Her analysis tied the stability of each memory to a margin, the amount by which each neuron agrees with the local field produced by all the others, and showed that larger margins produce larger basins of attraction [53 , 54 ] . This view of memory as a set of classification problems, one per neuron, reappears in Chapter 4, where it explains how basins can form without an energy function.
The crowding of patterns as their number K K K increases leads to a second phenomenon, the appearance of spurious states. These are stable states of the network that do not correspond to any of the stored patterns, as illustrated in Figure 2.5 . They emerge from crosstalk between memories, particularly as the number of stored patterns approaches the capacity of the network, and in the classical model many of them are mixtures of a few stored patterns [10 ] . Hopfield later proposed an “unlearning” mechanism that suppresses spurious attractors by raising their energy without disrupting the true memories [77 ] . Interestingly, this unlearning process is akin to the contrastive divergence objective (17) discussed in § 3.2.2 . It is, however, computationally expensive and does not fully eliminate the issue in practice. Classical AM networks are also highly sensitive to correlations between patterns. Hebbian storage works well only when the patterns are nearly uncorrelated. When patterns overlap, interference increases and retrieval deteriorates, which makes classical Hopfield networks poorly suited to natural data, where correlations are the rule.
Figure 2.5. The energy landscape of a classical AM network (left) and of a DenseAM (right). Memories in classical AM networks interfere with one another much more strongly than in DenseAMs. This interference produces spurious patterns (shown as ξ ′ \xi' ξ ′ ), which can be combinations of stored patterns or random-like states. In the classical network (left), they are shown as an interpolation between two stored patterns, and they hamper retrieval. DenseAMs instead use higher-order interaction functions, which reduce the interference among memories. The animal images are retrieved from the ImageNet-1K dataset [40 ] .
For most of the history of the field, spurious states were therefore treated as defects to be removed. Recent work suggests a different reading. When the stored patterns are not random but are samples from a structured distribution, overloading the network need not lead to a blackout. Instead, new attractors can form near examples drawn from the same distribution that were never stored, while the stored patterns remain retrievable [85 , 34 ] . Beyond capacity, an AM can therefore begin to generalize. This observation turns the classical question of capacity into a question about the transition from memorization to generalization, which is the question this thesis asks of diffusion models.
Dense Associative Memories
Following their initial popularity, AM networks gradually fell out of favor because of their limited storage capacity. For decades, they remained largely of theoretical interest, overshadowed by deep learning architectures that prioritized end-to-end optimization and continuous representations. This changed with the introduction of Dense Associative Memories (DenseAMs), also known as modern Hopfield networks, which reformulated the AM energy function to achieve much larger storage capacities.
As demonstrated by Krotov & Hopfield [101 ] , AM models can achieve a capacity that grows super-linearly with the number of neurons N N N by applying a rapidly growing interaction function to the overlap between the query and each memory. Specifically, the energy in Eq. (42) can be generalized to
E ( x ) = − ∑ μ = 1 K F ( ( ξ μ ) T x ) , (43) E(\mathbf{x}) = - \sum_{\mu=1}^{K} F\left((\boldsymbol{\xi}^{\mu})^{\mathsf{T}}\mathbf{x}\right), \tag*{(43)} E ( x ) = − μ = 1 ∑ K F ( ( ξ μ ) T x ) , (43)
where F ( ⋅ ) F(\cdot) F ( ⋅ ) is an interaction function and ξ μ \boldsymbol{\xi}^{\mu} ξ μ is one of the K K K stored memories. When F F F is quadratic, this energy reduces to the classical one,
E ( x ) = − ∑ μ = 1 K ( ( ξ μ ) T x ) 2 = − x T ( ∑ μ = 1 K ξ μ ( ξ μ ) T ) x = − x T W x , (44) E(\mathbf{x}) = -\sum_{\mu=1}^{K} \left((\boldsymbol{\xi}^{\mu})^{\mathsf{T}}\mathbf{x}\right)^2
= -\mathbf{x}^{\mathsf{T}}\left(\sum_{\mu=1}^{K}\boldsymbol{\xi}^{\mu}(\boldsymbol{\xi}^{\mu})^{\mathsf{T}}\right)\mathbf{x}
= -\mathbf{x}^{\mathsf{T}}\mathbf{W}\mathbf{x}, \tag*{(44)} E ( x ) = − μ = 1 ∑ K ( ( ξ μ ) T x ) 2 = − x T ( μ = 1 ∑ K ξ μ ( ξ μ ) T ) x = − x T Wx , (44)
which is the energy (42) of Hopfield [75 ] up to a constant factor.
The choice of F ( ⋅ ) F(\cdot) F ( ⋅ ) can be interpreted as defining a similarity measure between the query x \mathbf{x} x and the stored memories ξ μ \boldsymbol{\xi}^{\mu} ξ μ [113 ] . By increasing the steepness of F ( ⋅ ) F(\cdot) F ( ⋅ ) , DenseAMs shape the energy landscape to have deeper and more distinct minima around each stored memory [99 ] . This reduces interference, improves the reliability of retrieval, and allows the network to store a significantly larger number of patterns, as shown in Figure 2.5 . With a polynomial interaction F ( x ) = x n F(x) = x^n F ( x ) = x n , Krotov & Hopfield [101 ] showed that a DenseAM can store K max ∝ N n − 1 K^{\max} \propto N^{n-1} K m a x ∝ N n − 1 patterns. With an exponential interaction F ( x ) = exp ( x ) F(x) = \exp(x) F ( x ) = exp ( x ) , Demircigil et al. [37 ] showed that the capacity becomes exponential in N N N . Capacity thus becomes a design choice rather than a fixed limitation, and the steepness of the interaction controls where the boundary between memorization and its failure lies. In addition to their larger capacity, DenseAMs offer more flexibility in how patterns are represented and retrieved. Unlike classical AM networks, which operate on binary states, DenseAMs naturally support continuous queries and memories. This allows for more expressive memory representations and makes the model amenable to learning its memories with stochastic gradient descent [101 ] .
One of the most striking insights from recent work on DenseAMs is their strong connection to the attention mechanism of Transformers [156 ] . Ramsauer et al. [123 ] introduced an alternative form of the DenseAM energy,
E ( x ) = − LSE ( β , ξ , x ) + 1 2 x T x + constant , (45) E(\mathbf{x}) = -\operatorname{LSE}(\beta,\boldsymbol{\xi},\mathbf{x}) + \frac{1}{2}\mathbf{x}^{\mathsf{T}}\mathbf{x} + \text{constant}, \tag*{(45)} E ( x ) = − LSE ( β , ξ , x ) + 2 1 x T x + constant , (45)
where
LSE ( β , ξ , x ) = 1 β log ∑ μ = 1 K exp ( β ( ξ μ ) T x ) , (46) \operatorname{LSE}(\beta,\boldsymbol{\xi},\mathbf{x}) = \frac{1}{\beta}\log\sum_{\mu=1}^{K}\exp\left(\beta(\boldsymbol{\xi}^{\mu})^{\mathsf{T}}\mathbf{x}\right), \tag*{(46)} LSE ( β , ξ , x ) = β 1 log μ = 1 ∑ K exp ( β ( ξ μ ) T x ) , (46)
ξ ∈ R K × N \boldsymbol{\xi} \in\mathbb{R}^{K \times N} ξ ∈ R K × N is the memory matrix, and the inverse temperature β \beta β controls the separation between memories. The constant in Eq. (45) does not depend on x x x and can be ignored. Using the concave-convex procedure (Yuille & Rangarajan, [171 ] ), Ramsauer et al. [123 ] showed that the update rule for the query x x x reduces to
x n e w = softmax ( β x ξ T ) ξ , (47) \mathbf{x}^{\mathrm{new}} = \operatorname{softmax}\left(\beta\mathbf{x}\boldsymbol{\xi}^{\mathsf{T}}\right)\boldsymbol{\xi}, \tag*{(47)} x new = softmax ( β x ξ T ) ξ , (47)
which is equivalent to the attention mechanism. Specifically, letting the key be K = ξ \mathcal{K} = \boldsymbol{\xi} K = ξ , the value be V = ξ \mathcal{V} = \boldsymbol{\xi} V = ξ , and the query be Q = x \mathcal{Q} = \mathbf{x} Q = x , Eq. (47) becomes
x n e w = softmax ( β Q K T ) V , (48) \mathbf{x}^{\mathrm{new}} = \operatorname{softmax}\left(\beta\mathcal{Q}\mathcal{K}^{\mathsf{T}}\right)\mathcal{V}, \tag*{(48)} x new = softmax ( β Q K T ) V , (48)
which is the attention formulation of Vaswani et al. [156 ] .
Unlike standard attention, however, the key and value are shared as the memory matrix ξ \boldsymbol{\xi} ξ , while the query is a dynamical variable that evolves according to the DenseAM energy, as shown in Figure 2.6 . Depending on the inverse temperature β \beta β , a minimum of Eq. (45) can be (1) a global fixed point that averages all stored patterns, (2) a metastable state that averages several similar patterns, or (3) a single stored pattern when β \beta β is large (Ramsauer et al., [123 ] ). The inverse temperature therefore moves the network between retrieving individual memories and producing averages of them, a behavior that will reappear in diffusion models, where the noise level plays the role of temperature. This formulation also offers a powerful interpretation of attention as a step of gradient descent on a principled energy function, connecting two paradigms that had been studied in isolation.
Figure 2.6. An illustration of the DenseAM update rule (47) . The query x x x is compared with the memories ξ \xi ξ , which serve as both the key matrix K \mathcal{K} K and the value matrix V \mathcal{V} V . The softmax assigns a weight to each memory according to its similarity to the query x x x , and the weighted sum of the values retrieves the closest memory x ∗ x^* x ∗ . The animal images are retrieved from the ImageNet-1K dataset [40 ] .
Conclusion
In this chapter, we introduced the concepts on which the rest of this thesis builds. Probabilistic generative models are trained on finite datasets with objectives that, taken literally, reward memorization. EBMs offer a flexible way to represent such models, and diffusion models learn their scores across all levels of noise, in both continuous and discrete settings. AM networks, in turn, have always been about memorization. Their theory explains what a network can store, how robustly it stores it, and what happens beyond its capacity, where spurious states and, with structured data, generalization emerge. The following chapters connect these paradigms. Chapter 3 views continuous diffusion models as DenseAMs whose memories are their training samples, and Chapter 4 shows that the conditional likelihood objective of discrete diffusion models forms basins of attraction without an energy function. Together, they study how memorization and generalization coexist in diffusion models for images and for language.
Emergence of Diffusion Models from Associative Memory
Introduction
Hopfield networks are energy-based Associative Memory (AM) models, which conceptualize memories as attractor states corresponding to local minima of their energy function, and the memory retrieval process as the dynamical convergence towards such attractors Hopfield, [75 , 76 ] ; Amari [8 ] . Modern variants of such networks, called Dense Associative Memories (DenseAMs) Krotov & Hopfield, [101 , 102 ] , have helped revitalize scientific interest in these ideas and paved the way for more sophisticated AM systems Demircigil et al., [37 ] ; Agliari et al. [5 ] ; Agliari & De Marzo [6 ] ; Albanese et al. [7 ] ; Millidge et al. [113 ] ; Saha et al. [130 ] ; Krotov [99 ] ; Hoover, Liang, et al. [73 ] , driven primarily by their connection to the attention mechanism in Transformers Ramsauer et al., [123 ] ; Hoover, Liang, et al. (2023) and neurobiology Krotov & Hopfield, [104 ] ; Kozachkov et al. [95 ] .
Simultaneously, diffusion models (DMs) Sohl-Dickstein et al., [140 ] have recently gained a large popularity, due to their flexibility and accuracy in modeling various high-dimensional distributions Ho et al., (2020); Song & Ermon [143 ] ; Song, Sohl-Dickstein, et al. [147 ] ; Rombach et al. [127 ] . However, despite their effectiveness, DMs pose challenges related to data privacy and security, as concerns grow about their tendency to replicate training data alongside a lack of understanding of how generalization arises in these models (Somepalli et al., 2023a,b; Carlini, Hayes, et al., 2023; Wen et al., 2024; Jeon et al., 2025; Webster, 2023). Hence, such matters emphasize the need for further understanding of memorization and generalization behaviors of DMs.
Currently, much of the recent works on the memorization-to-generalization transition of DMs tackle it in a generalization-centric fashion (Meehan et al., 2020; van den Burg & Williams, 2021; Somepalli et al., 2023a,b; Kadkhodaie et al., 2024; Ventura et al., 2025; Achilli et al., 2024; Kamb
Portions of this chapter have previously appeared as:
Pham, B., Raya, G. , Negri, M., Zaki, M. J., Ambrogioni, L., & Krotov, D. (2026). Emergence of diffusion models from associative memory through memorization and generalization. Nature Communications . https://doi.org/10.1038/s41467-026-78727-y
Pham, B., Raya, G. , Negri, M., Zaki, M. J., Ambrogioni, L., & Krotov, D. (2025). Memorization to generalization: Emergence of diffusion models from associative memory . arXiv. https://doi.org/10.48550/arXiv.2505.21777
*Equal contribution as first author. & Ganguli, 2025; Ross et al., [129 ] ; Biroli et al., [18 ] ; Cui et al., [33 ] ; Achilli et al., [2 ] ). Namely, the memorization phenomenon is typically viewed as a “small side effect,” alleviated by drastically increasing the training data size (Yoon et al., [168 ] ; Gu et al., 2025). Although these studies shed some light on memorization and generalization, they do not fully explore the intermediate transition regime between these two phases. Our work adopts a complimentary approach which further ties memorization and generalization together. From the beginning, we cast the diffusion modeling pipeline into the AM framework. The training phase of diffusion modeling is conceptualized as the operation of writing the training data into the memory . The generation phase is viewed as the attempt of memory recall . This recall can be successful, resulting in the retrieval of training samples (memorization), or unsuccessful, resulting in the generation of new previously unseen samples (generalization). Consequently, this point of view allows us to apply the theory developed for AMs to the memorization-to-generalization transition in DMs, particularly when DMs operate in the memorization regime.
Recent works (Hoover, Strobelt, et al., 2023; Ambrogioni, [9 ] ; Raya & Ambrogioni, [124 ] ) have also begun establishing theoretical connections between DenseAMs and DMs, illustrating that the score function of typical DMs can be interpreted as the gradient of a DenseAM’s energy function. The focus of our work is the peculiar phenomenon commonly observed in AMs, called spurious states. Although spurious states is a cornerstone phenomenon in AM literature, they have not been predicted or found in DMs. Thus, the demonstration of the emergence of spurious states can further bridge DenseAMs and DMs. Historically considered as detrimental to reliable memory recall (Hopfield, [75 ] ; Hopfield et al., [77 ] ; Hopfield, [76 ] ; Amit et al., [10 ] ; Abu-Mostafa & St. Jacques, [1 ] ), spurious states were viewed as negative artifacts of AM networks. In contrast, for generative modeling these same spurious states serve as the first signatures of generalization capabilities, thus becoming a desirable emergent phenomenon (Kalaj et al., [85 ] ).
In accord with previous literature, we empirically find that DMs undergo a transition from memorization to generalization as the number of training points increases on realistic datasets. Unlike previous works, at the onset of generalization we detect the emergence of spurious patterns, which have sizable basins of attraction, but do not correspond to memorized data points. No longer negative artifacts, spurious states are now observed to be positive indicators of early generalization in DMs and they may also exist even during the full generalization stage of DMs, including Stable Diffusion (Rombach et al., [127 ] ). Our work does not prove that these spurious states are the causal driver of generalization. However, the confluence of our empirical results suggests that this is a plausible interpretation of the observed phenomena. Lastly, we provide theoretical descriptions distinguishing these peculiar states from memorized and generalized patterns, in terms of energy landscapes. Our findings suggest a close parallel between two seemingly different systems, DMs and DenseAMs, studied by two disjoint communities. Specifically, the DenseAM’s perspective on DMs can illuminate some of the computational properties of DMs at the boundary of the
memorization-generalization transition and deep inside the memorization phase.
The remainder of this chapter is organized as follows. Section (50) makes the connection between diffusion models and DenseAMs precise and explains why spurious states should be expected. Section (51) introduces the detection metrics that classify each generated sample as memorized, spurious, or generalized. Section (52) presents our results on natural image datasets, on a two-dimensional toy model, and on Stable Diffusion, characterizing the three sample types through their abundance, the volume of their basins of attraction, and the curvature of the energy around them. Section (53) discusses the implications and limitations of these findings, and the experimental details and additional results are collected in Section (54) .
Diffusion Models and Dense Associative Memories
Motivated by Hoover, Strobel, et al. (2023), Ambrogioni [9 ] , and Raya & Ambrogioni [124 ] , we first provide a theoretical link between DMs and DenseAMs through the perspective of energy. We build on the continuous-time formulation of diffusion models reviewed in Section (2.3.3). Let y ∈ R N \mathbf{y} \in\mathbb{R}^{N} y ∈ R N denote a sample drawn from a target data distribution p ( y ) p(\mathbf{y}) p ( y ) , with x 0 = y \mathbf{x}_{0} = \mathbf{y} x 0 = y . The forward and reverse processes are given by Eqs. (31) and (32) , and the score ∇ x t log p t ( x t ) = − ∇ x t E ( x t , t ) \nabla_{\mathbf{x}_{t}} \log p_{t}(\mathbf{x}_{t}) = -\nabla_{\mathbf{x}_{t}} E(\mathbf{x}_{t},t) ∇ x t log p t ( x t ) = − ∇ x t E ( x t , t ) is estimated by a neural network s θ ( x t , t ) s_{\theta}(\mathbf{x}_{t},t) s θ ( x t , t ) , where θ \theta θ denotes its set of trainable parameters, trained with denoising score matching across multiple time steps ([147 , 79 , 158 ] (Ho et al. 2020)).
Consider the training data distribution in the variance-exploding setting of f ( x t , t ) = 0 f(\mathbf{x}_{t},t)=0 f ( x t , t ) = 0 and g ( t ) = σ g(t)=\sigma g ( t ) = σ . In this case, the marginal probability distribution of noisy samples at time t t t can be computed exactly as
p ( x t , t ) = E y ∼ d a t a [ 1 ( 2 π σ 2 t ) N / 2 exp ( − ∥ x t − y ∥ 2 2 2 σ 2 t ) ] . (49) p(\mathbf{x}_{t},t)=\mathbb{E}_{\mathbf{y}\sim\mathrm{data}}\left[\frac{1}{(2\pi\sigma^{2}t)^{N/2}}\exp\left(-\frac{\lVert\mathbf{x}_{t}-\mathbf{y}\rVert_{2}^{2}}{2\sigma^{2}t}\right)\right]. \tag*{(49)} p ( x t , t ) = E y ∼ data [ ( 2 π σ 2 t ) N /2 1 exp ( − 2 σ 2 t ∥ x t − y ∥ 2 2 ) ] . (49)
Assuming the empirical distribution of the data p ( y ) = 1 K ∑ μ = 1 K δ ( N ) ( y − ξ μ ) p(\mathbf{y})=\frac{1}{K}\sum_{\mu=1}^{K}\delta^{(N)}(\mathbf{y}-\boldsymbol{\xi}^{\mu}) p ( y ) = K 1 ∑ μ = 1 K δ ( N ) ( y − ξ μ ) , where ξ μ \boldsymbol{\xi}^{\mu} ξ μ represents an individual data point (belonging to a dataset with training data size K K K ), this marginal distribution can be written as
p ( x t , t ) = 1 K ∑ μ = 1 K 1 ( 2 π σ 2 t ) N / 2 exp ( − ∥ x t − ξ μ ∥ 2 2 2 σ 2 t ) ≔ exp ( − E D M ( x t , t ) 2 σ 2 t ) . (50) p(\mathbf{x}_{t},t)=\frac{1}{K}\sum_{\mu=1}^{K}\frac{1}{(2\pi\sigma^{2}t)^{N/2}}\exp\left(-\frac{\lVert\mathbf{x}_{t}-\boldsymbol{\xi}^{\mu}\rVert_{2}^{2}}{2\sigma^{2}t}\right)\mathrel{\coloneqq}\exp\left(-\frac{E^{\mathrm{DM}}(\mathbf{x}_{t},t)}{2\sigma^{2}t}\right). \tag*{(50)} p ( x t , t ) = K 1 μ = 1 ∑ K ( 2 π σ 2 t ) N /2 1 exp ( − 2 σ 2 t ∥ x t − ξ μ ∥ 2 2 ) : = exp ( − 2 σ 2 t E DM ( x t , t ) ) . (50)
where we also defined the energy E D M E^{\mathrm{DM}} E DM of the DM, up to x-independent terms, to be
E D M ( x t , t ) = − 2 σ t 2 log [ ∑ μ = 1 K exp ( − ∥ x t − ξ μ ∥ 2 2 2 σ t 2 ) ] . (51) E^{\mathrm{DM}}(x_t,t)=-2\sigma_t^2\log\left[\sum_{\mu=1}^{K}\exp\left(-\frac{\lVert x_t-\xi^\mu\rVert_2^2}{2\sigma_t^2}\right)\right]. \tag*{(51)} E DM ( x t , t ) = − 2 σ t 2 log [ μ = 1 ∑ K exp ( − 2 σ t 2 ∥ x t − ξ μ ∥ 2 2 ) ] . (51)
As already observed in Ambrogioni [9 ] , Eq. (51) is closely related to a commonly studied DenseAM’s model, see for example Saha et al. [130 ] :
E A M ( x ) = − β − 1 log [ ∑ μ = 1 K exp ( − β ∥ x − ξ μ ∥ 2 2 ) ] . (52) E^{\mathrm{AM}}(x)=-\beta^{-1}\log\left[\sum_{\mu=1}^{K}\exp\left(-\beta\lVert x-\xi^\mu\rVert_2^2\right)\right]. \tag*{(52)} E AM ( x ) = − β − 1 log [ μ = 1 ∑ K exp ( − β ∥ x − ξ μ ∥ 2 2 ) ] . (52)
A direct comparison of Eqs. (51) and (52) highlights a close connection between these two seemingly different frameworks. Specifically, the data points ξ μ \xi^\mu ξ μ in the DM framework play the role of memories in the AM formulation. The variance of the noise added during the forward process (31) plays the role of the effective temperature β − 1 \beta^{-1} β − 1 (which controls the separation of memories), while the reverse process (32) corresponds to memory retrieval dynamics [9 ] (Hoover, Strobel[t], et al. 2023).
For a single data point ξ 1 \xi^1 ξ 1 or K = 1 K=1 K = 1 , Eq. (52) has a single local minimum at that stored pattern, where the shape of this energy landscape is independent of the value of β \beta β . This is an example of a memorized state. In contrast, for K = 2 K=2 K = 2 , there are several possibilities. The energy landscape can have two local minima when β → ∞ \beta\to\infty β → ∞ is large. But, for finite values of β \beta β , there exist configurations of patterns such that Eq. (52) has only one local minimum:
η = arg min x E A M ( x ) , (53) \eta=\underset{\mathbf{x}}{\arg\min}\ E^{\mathrm{AM}}(\mathbf{x}), \tag*{(53)} η = x arg min E AM ( x ) , (53)
such that η ≠ ξ 1 \eta\ne\xi^1 η = ξ 1 and η ≠ ξ 2 \eta\ne\xi^2 η = ξ 2 . This is an example of a spurious state . Such states are ubiquitous in AM models, when the amount of training data (memories) crosses the critical memory storage capacity of the model (which depends on the correlations between the training data points). Thus, the following question can be posed: Is it possible to observe spurious states in DMs trained using score matching objective when the energy landscape is modeled by the score-predicting neural network?
Detecting Memorized, Spurious, and Generalized Samples
The main goal of our work is to establish the existence of spurious states in DMs trained on natural high-dimensional datasets. This section explains the design of detection metrics that can classify any generated sample into one of three categories – memorized, spurious, and generalized samples – to aid in our analyses. Fundamentally, these metrics defined below rely on two datasets: the training dataset S used to train the DM, and the synthetic dataset S′ ^{\prime} ′ generated from the fully trained DM. The size of S′ ^{\prime} ′ is assumed to be much bigger than S.
Our core intuition is rooted in the energy landscape, where its topography dictates the nature of the generated samples, as shown in Figure 3.1 A). Memorized samples originate from the basins of attraction the model creates around individual data points from the training set S. Because these samples are attractors, the generation process frequently converges to exact memorized samples at small data sizes, producing outputs in the synthetic set S′ ^{\prime} ′ that are perfect duplicates of training data. In contrast, spurious samples arise from new emergent basins of attraction, formed during training, which do not correspond to any sample in S. These emergent minima are also stable attractors, which explains why they appear as duplicates within S′ ^{\prime} ′ but are absent from S. Finally, generalized samples are drawn from flatter regions of the energy landscape. Since these areas support a continuum of low-energy states rather than a single sharp minimum, the probability of landing on the exact same point twice is negligible, resulting in unique novel creations.
Figure 3.1. Schematic illustration of the energy landscape and the sample type at each phase of the transition. (A) Behavior of the energy landscape around generated samples as the size of the training dataset is increased. In the small data regime, the model stores the training data as local minima of the energy. When the amount of training data exceeds the model’s memory capacity, spurious patterns are formed and training data points are no longer energy minima. Subsequent increase of the training data size leads to the generalization phase, defined by the formation of continuous manifold of the low energy states.(B) Examples of memorized, spurious, and generalized samples in their respective columns for four datasets, MNIST [38 ] , FASHION-MNIST [167 ] , CIFAR-10 [96 ] , and LSUN-CHURCH (Yu et al., 2015). See § 4.3 for our definitions of these three sample types. For each target image (shown on the left), its top-4 nearest neighbors from the training set (top row) and the synthetic set (bottom row) are shown to highlight the novelty and commonality of the target image with respect to its training and synthetic sets. To help highlight the novelty of spurious patterns, we provide rectangular markers guiding where the features differ in their corresponding nearest neighbors.
With this intuition in mind we examine two histograms, see Figure 3.2 . First, for every element of S′ ^{\prime} ′ , their distance to their closest nearest neighbor from S is shown by the olive histogram. Second, for every element of S′ ^{\prime} ′ , their distance to their closest nearest neighbor in S′ ^{\prime} ′ (excluding itself) is shown by the gray histogram. Both histograms exhibit a clear bimodal shape, indicating that at least two groups of samples are present in S′ ^{\prime} ′ . This bimodality makes it possible to select the memorized δ m \delta_m δ m and spurious δ s \delta_s δ s thresholds to separate the samples forming the two peaks in each histogram. The left peak of the olive histogram identifies memorized samples by their small distance to the training set S, leaving spurious and generalized samples in the right peak. The gray histogram distinguishes memorized and spurious samples from generalized samples: its left peak contains high-frequency duplicates (both memorized and spurious), while its right peak consists of unique generalized samples. This bimodality provides an empirical basis for defining our detection metrics below.
Figure 3.2. Different sample types identified in accordance to the bi-modality in distance histograms for CIFAR-10 [96 ] . The grey histogram shows the distances between synthetic samples and their nearest neighbors from the synthetic set S ′ S' S ′ (which is 4x the size of the training set). The threshold δ s \delta_s δ s defines a boundary between the two peaks. The olive histogram depicts the distances from the synthetic samples to their closest neighbor from the training set S S S , with threshold δ m \delta_m δ m separating the two peaks. Memorized samples are located in the left peak of the olive histogram, below δ m \delta_m δ m . In contrast, generalized and spurious samples appear to the right of δ m \delta_m δ m in the olive histogram. Examples of the generated samples forming each of the four peaks of the histograms are shown in the inset frames. For each generated sample, top-4 nearest neighbors from the training set are shown in the top row, and those from the synthetic set are shown in the bottom row. Training set size K = 7310 K = 7310 K = 7310 is used in this figure, but the discussed phenomena are general and largely independent of this specific value. The fraction of the memorized, spurious, and generalized samples in the pool of all generated samples is shown in the bottom left panel as a function of the training set size. The inset shows amplified spurious fraction (green curve).
Following Yoon et al. [168 ] , we define the memorization detection metric M \mathcal{M} M . A sample x ^ ∈ S ′ \hat{\mathbf{x}} \in S^{\prime} x ^ ∈ S ′ is considered memorized if its distance to its nearest neighbor x 1 \mathbf{x}_1 x 1 , from the training set S, falls below a threshold δ m ∈ R \delta_m \in\mathbb{R} δ m ∈ R :
M ( x ^ , S ) = I ( d ( x ^ , x 1 ) ≤ δ m ) , (54) \mathcal{M}(\hat{\mathbf{x}}, S) = \mathbb{I}\left(d(\hat{\mathbf{x}}, \mathbf{x}_1) \leq\delta_m\right), \tag*{(54)} M ( x ^ , S ) = I ( d ( x ^ , x 1 ) ≤ δ m ) , (54)
where I \mathbb{I} I represents the indicator function and δ m \delta_m δ m is a threshold derived from the olive distance histograms, see Figure 3.2 . Second, a sample x ^ ∈ S ′ \hat{\mathbf{x}} \in S' x ^ ∈ S ′ is spurious if it is not a memorized state but is a duplicate of the synthetic set S ′ S' S ′ . This is detected by the metric S \mathcal{S} S , which identifies non-memorized samples that are close to their respective nearest neighbor x 1 ′ \mathbf{x}'_1 x 1 ′ within the synthetic set S ′ S' S ′ :
S ( x ^ , S , S ′ ) = I ( d ( x ^ , x 1 ′ ) ≤ δ s ) ∧ ¬ M ( x ^ , S ) , (55) \mathcal{S}(\hat{\mathbf{x}}, S, S') = \mathbb{I}\left(d(\hat{\mathbf{x}}, \mathbf{x}'_1) \leq\delta_s\right) \land\neg\mathcal{M}(\hat{\mathbf{x}}, S), \tag*{(55)} S ( x ^ , S , S ′ ) = I ( d ( x ^ , x 1 ′ ) ≤ δ s ) ∧ ¬ M ( x ^ , S ) , (55)
where δ s ∈ R \delta_s \in\mathbb{R} δ s ∈ R is a threshold value chosen based on the gray distance histogram. Finally, a sample x ^ \hat{\mathbf{x}} x ^ is generalized if it is neither memorized nor spurious:
G ( x ^ , S , S ′ ) = ¬ M ( x ^ , S ) ∧ ¬ S ( x ^ , S , S ′ ) . (56) \mathcal{G}(\hat{\mathbf{x}}, S, S') = \neg\mathcal{M}(\hat{\mathbf{x}}, S) \land\neg\mathcal{S}(\hat{\mathbf{x}}, S, S'). \tag*{(56)} G ( x ^ , S , S ′ ) = ¬ M ( x ^ , S ) ∧ ¬ S ( x ^ , S , S ′ ) . (56)
With these metrics, we computed the fractions of memorized, spurious, and generalized samples in the synthetic sets for various training data sizes for different datasets, see Figure 3.3 . These datasets include MNIST [38 ] , FASHION-MNIST [167 ] , CIFAR-10 [96 ] , and down-sampled LSUN-CHURCH (Yu et al., 2015). For each dataset, we trained DDPM-based DMs (Ho et al., 2020) for M = 38 M = 38 M = 38 different data sizes. For each model α = 1 , … , M \alpha= 1, \ldots, M α = 1 , … , M trained on a training set S α S_\alpha S α , a synthetic set S α ′ S'_\alpha S α ′ was generated. To account for duplication, we ensured that each S α ′ S'_\alpha S α ′ is 4 times the size of its corresponding S α S_\alpha S α . We experimented with up to 8x ratio to the training set size and did not notice qualitative differences in our conclusions, see § 4.6.2 . Each sample x ^ ∈ S α ′ \hat{\mathbf{x}} \in S'_\alpha x ^ ∈ S α ′ is classified as either memorized, spurious, or generalized using Eqs. (54) –(56) . The fractions of these three sample types with respect to ∣ S α ′ ∣ \lvert S'_\alpha\rvert ∣ S α ′ ∣ are plotted in Figure 3.3 . For each dataset, our smallest model was trained on the training set of ∣ S 1 ∣ = 2 \lvert S_1 \rvert= 2 ∣ S 1 ∣ = 2 data points while the largest model was trained on the entire original training set S M = S S_M = S S M = S . For the MNIST and FASHION-MNIST datasets, we used ℓ 2 \ell_2 ℓ 2 -distance, and the FID metric [67 ] was used for the two remaining datasets. Notably, we did not observe significant differences between either using ℓ 2 \ell_2 ℓ 2 -distance or FID metric for MNIST and FASHION-MNIST, and thus, we opted for a more efficient option (ℓ 2 \ell_2 ℓ 2 -distance) for these two datasets.
Figure 3.3. Fractions of memorized, spurious, and generalized samples in synthetic sets across training set sizes and various datasets. As the training data size K K K increases, memorization decreases and the fraction of generalized samples steadily increases (top row). The fraction of spurious patterns rises and decreases at the boundary between the memorization and generalization phases (bottom row). The synthetic set size at each point is 4x its respective training set size.
Results
The Memorization-to-Generalization Transition. We argue that the answer to this question is positive, and the spurious states indeed emerge, as DMs progress from memorization to generalization as the training data size K K K increases. When K K K is small, DMs initially memorize their training data points and store them as local minima of their energy function. In the large data regime, a different phase appears where a sufficient increase of K K K fosters the creation of attractor states corresponding to the manifold of the generated samples. Spurious states appear at the boundary of this transition and correspond to emergent attractor states of the energy function, absent in the training set, but at the same time, having distinct basins of attraction around them. This sequence of transitions is illustrated in Figure 3.1 A), which provides a schematic illustration of the possible locations of memorized and spurious patterns on the energy landscape as the training set size is increased.
In order to empirically establish this sequence of transitions, we have trained a set of conventional DMs on datasets of gradually increasing sizes. Each of the trained models is characterized by its training set S S S , and a synthetic set of generated samples drawn from this model S ′ S' S ′ (the synthetic set is assumed to be very large). A sample x ^ ∈ S ′ \hat{x} \in S' x ^ ∈ S ′ is memorized if it has duplicates in both training and synthetic sets. This is clear from the three universality classes shown in Figure 3.1 A). Since memorized samples have a basin of attraction around them, the same sample should appear in the synthetic set more than once, and that generated sample should be a copy of the training data point. A sample x ^ ∈ S ′ \hat{x} \in S' x ^ ∈ S ′ is spurious if it has duplicates in the synthetic set, but not in the training set. Again, this is clear from Figure 3.1 A): spurious samples have a well-defined basin of attraction around them, but the bottom of that basin corresponds to a newly generated sample – not the training example. Finally, the generalized sample x ^ ∈ S ′ \hat{x} \in S' x ^ ∈ S ′ has no duplicates in either the training or synthetic sets. Generalized samples occupy flat manifolds in the configuration space. For this reason, every generation produces a slightly different sample resulting in absence of duplicates in S ′ S' S ′ . These criteria correspond to the detection metrics defined in § 4.3 .
Examples of generated samples belonging to these three categories are shown in Figure 3.1 B). For each sample, the top-4 nearest neighbors from the training set (top row) and synthetic set (bottom row) are shown. It is instructive to visually examine some of the samples classified as spurious. For instance, the first spurious sample in Figure 3.1 B) (generated from the model trained on CIFAR-10 dataset [96 ] ) is a plane that has a large wing (highlighted by the cyan frame), which is absent in the training set, but has an exact duplicate in the synthetic set. Another interesting example is shown in the fourth row (generated from the model trained on FASHION-MNIST dataset [167 ] ). There are many examples of shirts in the training set with either two sleeves, or no sleeves. The generated sample shows only one sleeve. This sample has exact duplicates in the synthetic set, indicating the existence of a well-defined basin of attraction around it, but does not appear in the training set. These examples illustrate the general phenomenon, which is predicted by the AM perspective and is clearly observed empirically for conventional diffusion models trained with the score matching objective.
The abundance of memorized, spurious, and generalized samples is quantified as a function of training data set size in Figure 3.3 . Here, a family of DM models has been trained for a gradually increasing size of the training set K K K . For small K K K , the generated samples are dominated by memorized data points. As the training set gets larger, the amount of memorized samples decreases, while the amount of generalized samples increases. The spurious states appear as a peak at the boundary of this transition.
Volume of the Basins of Attraction. To characterize the volume of the basins of attraction, motivated by Biroli et al. [18 ] , Raya & Ambrogioni [124 ] , and Li & Chen (2024), we measured the critical time t c t_c t c , which is the maximal time when the reverse process (32) can still recover a target pattern x ^ \hat{\mathbf{x}} x ^ from its perturbation x t c \mathbf{x}_{t_c} x t c within an error margin. The time t c t_c t c defines the radius R ( x ^ , x t c ) = ∥ x ^ − x t c ∥ R(\hat{\mathbf{x}},\mathbf{x}_{t_c}) = \lVert\hat{\mathbf{x}}-\mathbf{x}_{t_c}\rVert R ( x ^ , x t c ) = ∥ x ^ − x t c ∥ of the basin of the attraction of a sample x ^ \hat{\mathbf{x}} x ^ , which is the Euclidean norm of the difference between x ^ \hat{\mathbf{x}} x ^ and its recoverable perturbation x t c \mathbf{x}_{t_c} x t c . The volume of this basin is simply defined by the volume of the N N N -dimensional sphere of that radius:
V ( x ^ , x t c ) = π N 2 Γ ( N 2 + 1 ) R ( x ^ , x t c ) N , (57) V(\hat{\mathbf{x}},\mathbf{x}_{t_c}) = \frac{\pi^{\frac{N}{2}}}{\Gamma\left(\frac{N}{2}+1\right)}R(\hat{\mathbf{x}},\mathbf{x}_{t_c})^{N}, \tag*{(57)} V ( x ^ , x t c ) = Γ ( 2 N + 1 ) π 2 N R ( x ^ , x t c ) N , (57)
where Γ ( ⋅ ) \Gamma(\cdot) Γ ( ⋅ ) is the Gamma function. The results of the average logarithm of Eq. (57) are shown in Figure 3.4 for samples belonging to each distinct category.
Figure 3.4. Volume of the basins of attraction for three distinct sample types and various datasets as the training set size increases. The average log-volume is computed using Eq. (57) . In general, memorized samples have the largest basin volume at the beginning of the transition. However, as the training set size increases, their basin volume decreases and approaches that of the spurious samples’ volume. Statistically, memorized and spurious samples have larger basin volume than that of the generalized samples across all datasets. The shaded regions indicate the standard deviation of the log-volume.
The distinct nature of these three different states is further substantiated by the hierarchy of the log-volume of their basins of attraction in Figure 3.4 . Memorized samples consistently exhibit the largest log-volume, followed by spurious samples, while generalized samples have near-zero volume. This is in accord with the intuitive expectation for the energy profiles in Figure 3.1 A). Memorized and spurious samples should have substantial basins of attraction around them, while generalized samples should have almost vanishing basins, since they occupy an almost flat energy manifold.
Curvature of the Energy. While the changing fractions of memorized, spurious, and generalized samples constitute a good signature of the memorization-to-generalization transition, the underlying mechanism is also rooted in the geometry of the model’s learned energy landscape, as shown in Figure 3.1 A) and Figure 3.6 . To elucidate this mechanism, we quantify the energy curvature at the minima corresponding to each sample type.
Figure 3.6. Energy landscape evolution for the 2D toy model as training data size K K K increases. Models trained at K ∈ { 2 , 9 , 1000 } K \in\{2, 9, 1000\} K ∈ { 2 , 9 , 1000 } , using the VE-SDE based diffusion pipeline from Song, Sohl-Dickstein, et al. [147 ] , with training data (represented as pink triangles) sampled from the unit circle (shown in gray). Generated samples are shown alongside the learned score field or neural network, aligned with the negative gradient of the energy (51) . Hierarchical clustering identifies structure within the generations, with the generated samples’ centroids (represented as cyan crosses) are visualized by their numerical value of the energy at the location of that centroid. The energy values of the training points are also shown for memorized samples and data points located close to spurious samples. The right-most panel shows the exact solution as K → ∞ K \to\infty K → ∞ derived in Eq. (63) . As K K K grows, the model initially memorizes individual data points, forming isolated basins. Around K = 9 K = 9 K = 9 , spurious patterns, distinct low-energy attractors not present in the data, emerge and signal the onset of generalization. At large K K K , the model enters a fully generalized regime, where low-energy states lie on a flat continuous manifold. The visualization is shown at t = 10 − 5 t = 10^{-5} t = 1 0 − 5 .
To measure this curvature, we rely on the relationship ∇ x t log p t ( x t ) = − ∇ x t E t ( x t ) \nabla_{x_t}\log p_t(x_t) = -\nabla_{x_t}E_t(x_t) ∇ x t log p t ( x t ) = − ∇ x t E t ( x t ) to analyze the Hessian of the energy function or the Jacobian of the score, evaluated at the location of each generated sample x ^ ∈ R N \hat{x} \in\mathbb{R}^{N} x ^ ∈ R N . Specifically, following Stanczuk et al. [149 ] , Achilli et al. [3 ] , and Ventura et al. [157 ] , we numerically approximate the spectrum of the energy Hessian by exploiting the tangent space of the model’s learned manifold at a given pattern x ^ \hat{x} x ^ . First, we generate a set of 4 N 4N 4 N perturbations around x ^ \hat{x} x ^ using a small time t 0 t_0 t 0 in Eq. (31) . The learned score is then evaluated at each perturbed point x ^ t 0 \hat{x}_{t_0} x ^ t 0 and the resulting 4 N 4N 4 N score vectors form a matrix M ∈ R N × 4 N M \in\mathbb{R}^{N \times4N} M ∈ R N × 4 N . Singular value decomposition is then performed on M M M to extract its singular values, serving as our measure of the local curvature of the energy around x ^ \hat{x} x ^ . The curvature spectra for the three sample types for different datasets are shown in the top row of Figure 3.5 , see § 4.6.4 for additional details.
Figure 3.5. Spectral analysis of the energy curvature for different sample types and various datasets. The shaded region is the standard deviation of the singular values. The average singular values computed for the three distinct sample types are shown in the top row. Memorized and spurious samples generally exhibit higher energy curvature, characterized by fewer near-zero singular values than generalized samples. The average singular values computed for the training data points are shown in the bottom row, where the changing color scheme denotes small to large data sizes, suggesting a drop in curvature (indicated by the decrease in singular values) as K K K increases.
The distinct universality classes of the energy behavior around generated samples, illustrated in Figure 3.1 A), suggests that the three classes of generated samples should have different behaviors of the curvature of the energy around them. The curvature of the energy profile is characterized the Hessian of the energy (or equivalently the Jacobian of the score function). We have performed the singular value decomposition on the resulting estimated Jacobian matrix, see details below. The ranked singular values are shown in Figure 3.5 . This analysis reveals that the curvature of the energy is largely consistent with the intuitive expectations from Figure 3.1 A). For instance, for MNIST and LSUN-CHURCH datasets there is a clear separation of spectral curves for memorized, spurious, and generalized samples in the region of smallest singular values. These small singular values correspond to flat directions in the ambient space, which do not result in energy increase around corresponding samples. Additionally, we performed a similar analysis for training data. The results reveal that as the training set size increases, the curvature around these training samples on average decreases. All these results are consistent with intuitive expectation predicted by Figure 3.1 A): as the training data size K K K increases, the memorized and spurious samples tend to have higher curvature (indicated by their fewer near-zero singular values) compared to the generalized samples.
While a consistent separation in the curvature spectra of memorized, spurious, and generalized samples is not readily apparent for all training data sizes K K K , likely due to the geometric complexity of the energy landscapes near transitions, we were able to observe the separation of the curvature spectra between memorized, spurious, and generalized samples at many sizes of the training dataset (prominently at or after the peak of the spurious states). In addition, we repeated a similar analysis for training data points. There is a consistent decrease in the singular values measured at the locations of the training data points as their number K K K increases, see bottom row of Figure 3.5 . This provides a direct geometric evidence of the mechanism behind generalization: the model transitions from creating sharp, high-curvature minima for individual data points in the memorization regime to learning a smoother, lower-curvature manifold that encompasses the entire dataset in the generalization regime.
A Two-Dimensional Toy Model. Natural datasets considered above are high-dimensional, which makes it difficult to directly visualize the energy behavior around generated samples. To address this issue, we designed a very simple synthetic model that makes it possible to evaluate the energy landscape of DM directly.
Imagine that the training data points live in two dimensions and lie on a unit circle:
y 1 2 + y 2 2 = 1 (58) y_{1}^{2} + y_{2}^{2} = 1 \tag*{(58)} y 1 2 + y 2 2 = 1 (58)
where y 1 y_{1} y 1 and y 2 y_{2} y 2 are coordinates in this 2D space. We are interested in exploring how the shape of E D M E^{\mathrm{DM}} E DM (51) changes as the number of training data points K K K increases. To explore this aspect, we trained a set of DMs in this precise setting. Each model is trained on a dataset of size K K K . The resulting energy landscapes are shown in Figure 3.6 . For a small data size of K = 2 K = 2 K = 2 , the DM exhibits memorization behavior – the local minima of the energy correspond to the training data points. At K = 9 K = 9 K = 9 we observed the first signs of spurious states . At this stage, the model begins to learn emergent (different from the training data) local minima of the energy. Subsequent increase of the size of the training set leads to fully generalized behavior, illustrated at K = 1000 K = 1000 K = 1000 . At this stage, all of the samples from the model live in close proximity of the exact data manifold. right panel shows the analytical expression of the energy landscape defined by Eq. (63) , which can be obtained in the limit K → ∞ K \to\infty K → ∞ .
Below, we derive the exact form of the energy landscape E A M E^{\mathrm{AM}} E AM (52) in the limit when the number of training data is infinite or K → ∞ K \to\infty K → ∞ . In this case, the distribution of data points can be described by a continuous density of states:
p ( y ) = 1 π δ ( y 1 2 + y 2 2 − 1 ) , (59) p(\mathbf{y}) = \frac{1}{\pi}\delta(y_1^2+y_2^2-1), \tag*{(59)} p ( y ) = π 1 δ ( y 1 2 + y 2 2 − 1 ) , (59)
where δ ( ⋅ ) \delta(\cdot) δ ( ⋅ ) is the Dirac delta function. The probability of the generated data is proportional (up to terms independent of the state x \mathbf{x} x ) to
p ( x ) ∼ ∫ − ∞ + ∞ d y 1 d y 2 p ( y ) e − β ∥ x − y ∥ 2 2 (60) p(\mathbf{x}) \sim\int_{-\infty}^{+\infty} \mathrm{d}y_1\mathrm{d}y_2\,p(\mathbf{y})\,e^{-\beta\lVert\mathbf{x}-\mathbf{y}\rVert_2^2} \tag*{(60)} p ( x ) ∼ ∫ − ∞ + ∞ d y 1 d y 2 p ( y ) e − β ∥ x − y ∥ 2 2 (60)
In order to evaluate this integral, it is easiest to introduce polar coordinates for both the state vector x \mathbf{x} x and the training data y \mathbf{y} y :
x 1 = R cos ( ϕ ) y 1 = r cos ( φ ) x 2 = R sin ( ϕ ) y 2 = r sin ( φ ) (61) \begin{aligned}
x_1 &= R\cos(\phi) & y_1 &= r\cos(\varphi) \\
x_2 &= R\sin(\phi) & y_2 &= r\sin(\varphi) \tag*{(61)}
\end{aligned} x 1 x 2 = R cos ( ϕ ) = R sin ( ϕ ) y 1 y 2 = r cos ( φ ) = r sin ( φ ) (61)
The integral (60) can then be written as
p ( x ) ∼ ∫ 0 2 π d ϕ ∫ 0 ∞ r d r 1 π δ ( r 2 − 1 ) e − β [ R 2 + r 2 − 2 R r cos ( ϕ − φ ) ] = e − β ( R 2 + 1 ) I 0 ( 2 β R ) (62) p(\mathbf{x}) \sim\int_0^{2\pi}\mathrm{d}\phi\int_0^{\infty}r\mathrm{d}r\,\frac{1}{\pi}\delta(r^2-1)e^{-\beta[R^2+r^2-2Rr\cos(\phi-\varphi)]}=e^{-\beta(R^2+1)}I_0(2\beta R) \tag*{(62)} p ( x ) ∼ ∫ 0 2 π d ϕ ∫ 0 ∞ r d r π 1 δ ( r 2 − 1 ) e − β [ R 2 + r 2 − 2 R r c o s ( ϕ − φ )] = e − β ( R 2 + 1 ) I 0 ( 2 β R ) (62)
and explicitly computed using the definition of the modified Bessel functions [60 ] .
Using the definition of E A M E^{\mathrm{AM}} E AM , see Eq. (52) , the energy of this toy model can be written as
E A M ( R , ϕ ) = R 2 + 1 − 1 β log [ I 0 ( 2 β R ) ] ≈ β → ∞ ( R − 1 ) 2 , (63) E^{\mathrm{AM}}(R,\phi)=R^2+1-\frac{1}{\beta}\log\left[I_0(2\beta R)\right]\underset{\beta\to\infty}{\approx}(R-1)^2, \tag*{(63)} E AM ( R , ϕ ) = R 2 + 1 − β 1 log [ I 0 ( 2 β R ) ] β → ∞ ≈ ( R − 1 ) 2 , (63)
In this formula, R R R is the radius of the unit circle, ϕ \phi ϕ is the polar angle, and I 0 ( ⋅ ) I_0(\cdot) I 0 ( ⋅ ) is a modified Bessel function of the first kind. The dependence on ϕ \phi ϕ in Eq. (63) completely disappears from the final result, since the local minima of the resulting energy function form a flat manifold . In the limit of inverse temperature β → ∞ \beta\to\infty β → ∞ , the shape of the energy landscape is described by a parabola centered around R = 1 R = 1 R = 1 . The limit of K → ∞ K \to\infty K → ∞ describes the fully generalized phase of this toy model.
The results presented in Figure 3.6 perfectly align with the intuition suggested by possible energy behaviors around generated samples illustrated in Figure 3.1 A). At small K K K the model memorizes the training data. Around K = 9 K = 9 K = 9 the model begins to form spurious states, i.e., the generated samples have lower energy than the energy of the nearby training data points. As K K K continues to increase, the model learns a flat energy landscape around the manifold of the data. That learned energy landscape E D M E^{\mathrm{DM}} E DM (51) is very similar to the empirical energy E A M E^{\mathrm{AM}} E AM of DenseAM (52) in the limits of large K K K in the regions close to the data manifold (the two energies may deviate from each other outside the manifold of the data, since there are no samples presented to DM outside the data manifold). Thus, the results of this simple two-dimensional model support the claims of the empirical evaluations on the natural datasets.
Stable Diffusion. So far our studies focused on relatively small scale datasets: MNIST Deng, [38 ] , FASHION-MNIST Xiao et al., [167 ] , CIFAR-10 Krizhevsky, [96 ] , and LSUN-CHURCH Yu et al., 2015. Focusing on these settings allowed us to train a dense grid of models with varying size of the training set and carefully examine the existence of duplicates in the training and synthetic sets. Such a careful analysis would be intractable for large-scale real world scenarios such as Stable Diffusion Rombach et al., [127 ] : training these models requires substantial compute resources, the training set is large, and the synthetic set needs to be even larger in order to reliably perform the analysis similar to what was described above. At the same time, the analysis based on the curvature of the energy landscape around generated samples is more feasible (see Figure 3.7 ).
Figure 3.7. Spectral analysis of energy curvature for different candidate examples of the three distinct sample types in Stable Diffusion model trained on LAION [136 ] . Here, each candidate exhibits different spectra signatures. The candidate memorized sample has much larger singular values, while the candidate generalized sample has much smaller ones. The selected and possibly spurious candidates have larger singular values than the candidate generalized sample, but smaller than that of the candidate memorized sample. The common trait between candidate memorized and spurious samples is that both are stable attractors, as demonstrated by their repeated generations given 4 different initial points (or noise vectors) and the associated text-prompt. The y-axis is clipped at the value of 1500 to better contrast the shown examples’ spectra.
With this in mind, we have identified several candidate samples from Stable Diffusion that fall into three categories: sharp energy curvature, intermediate energy curvature, and almost flat energy. Examples of these samples together with their singular values of the score function Jacobian are shown in Figure 3.7 . For each sample a language prompt was given to the model and the generated samples produced by that model was recorded. The prompt used were taken from the training set and the generated samples are shown together with the training image corresponding to that prompt. The results of this analysis reveal that the high curvature samples (candidate memorized states) are exact duplicates of the training image. Intermediate curvature samples (candidate spurious states) are somewhat similar to the training image, but deviate from it in certain aspects (color and pattern of the rug, color of the curtains). Finally, small curvature samples (candidate generalized states) demonstrate a greater degree of variability and larger deviations from the training image.
Given the computational complexity of large models, this analysis has only been performed at small scale (small number of prompts and generated samples). Qualitatively, these results align with our primary findings on the carefully studied small dataset models.
To validate these geometric findings on a large-scale model, we performed a case study using Stable Diffusion (Rombach et al., [127 ] ), trained on the LAION dataset (Schuhmann et al., [136 ] ), shown in Figure 3.7 . The analysis of handpicked candidate examples of memorized, spurious, and generalized samples from LAION reveals a similar hierarchy of energy curvatures. As expected, heavily memorized samples occupy high-curvature minima, evidenced by large singular values. In contrast, generalized samples exhibit a significantly lower curvature signature, while spurious samples occupy an intermediate range of curvatures. Notably, the spectra for all generated samples remain relatively sharp, with few near-zero singular values, as similarly found in Jeon et al. [80 ] .
Discussion
In conclusion, we established a novel connection between DMs and DenseAMs by identifying the emergence of creativity (generalization) in DMs with the failure of successful memory recalls via an energy-based Dense Associative Memory. Using this perspective, we empirically identified a novel intermediate phase, spurious states , previously overlooked in related DM literature, which marks the onset of generalization in these models as the training data size increases. Additional analyses of the volume of the basins of attraction on samples generated from DMs, helps validate our hypothesis delineated in Figure 3.1 A). Our findings in Stable Diffusion suggest that similar phenomena persist even in large models trained on massive datasets. Thus, our framework provides a new tool for understanding the computational mechanisms of DMs, opening new avenues for characterizing their behaviors.
The main result of our work is the empirical demonstration that DMs, trained with standard methods, generate spurious samples at the onset of memorization-to-generalization transition. The existence of these samples is a cornerstone of energy-based AM models. By casting DMs’ generation step into DenseAM setting, one can theoretically expect the emergence of these states at the transition boundary. We have characterized computational properties of memorized, spurious, and generalized samples by studying their abundance, volume of the basins of attraction, and curvature of the energy landscape as a function of the DM training set size. Spurious samples in DMs have well-defined basins of attraction around them and have not been discussed in prior literature.
Our theoretical arguments pertain to the idealistic setting in which the neural network s θ ( x t , t ) s_\theta(x_t,t) s θ ( x t , t ) is capable of learning the empirical distribution obtained by adding noise to the training data. This limiting case is often adopted in theoretical studies of DMs, see Biroli et al. [18 ] , Biroli & Mézard [19 ] , Achilli et al. [2 ] , and Vastola [155 ] . From a practical perspective, this is achieved if s θ ( x t , t ) s_\theta(x_t,t) s θ ( x t , t ) is over-parametrized and trained for a long time, and the generation process is terminated at a small but non-zero time t 0 t_0 t 0 , see Eq. (51) . This simplification allows us to make a theoretical prediction that DMs must generate spurious states. In practical settings, the size of the score modeling neural network is finite. Additionally, the score function itself is modeled by a general feed-forward neural network and, for this reason, is not guaranteed to represent the gradient of a scalar energy function. It is non-trivial that the theoretical prediction obtained in the regime of an infinitely large neural network can be extrapolated to the regime in which the size of s θ ( x t , t ) s_\theta(x_t,t) s θ ( x t , t ) is finite and the amount of training data is large. A possible perspective on our contribution is the empirical demonstration that this extrapolation is valid, and spurious states indeed exist in practically used settings.
In the AM literature, specifically on Hopfield networks, the concept of spurious states is often entangled with the phenomenon of mixture states, which are linear combinations of a certain number of memory vectors. While in certain kinds of AM models these two notions can be closely related, it is important to emphasize that they are different concepts. Spurious states are defined by the existence of a basin of attraction around them. They may or may not be mixture states. The main message of our work is to establish that spurious states exist in DMs. We do not claim that these spurious states are necessarily mixture states. It is up to the model, defined by the score modeling neural network, to decide how the spurious states are constructed from the training data.
Careful characterization of the memorization-generalization transition and the computational aspects of spurious states that define the onset of this transition may offer future insights for guiding the development of methods that can mitigate DMs’ memorization. For instance, one can imagine diagnostic tools that monitor the prevalence of spurious states among generated samples (for example by leveraging spectral analysis method, see Figure 3.5 ) during training process. If the spurious states become abundant, one could stop training or inject additional data into the training set at the onset of this regime. Thus, emergence of spurious states can serve as an early warning signal of potential memorization. The benefit of using this diagnostic method is that it does not require searching for the memorized samples in the training set, which can be unpractical due to its large size. One can also imagine incorporating regularizers into the architecture of the score-predicting neural network or the loss function that could penalize high curvature of the energy landscape around generated samples. These are some of the examples of promising directions of future work that may utilize the properties of spurious states for monitoring and reducing effects of memorization in practical large scale models.
Additionally, recent works underscore training time as a central factor in balancing generalization against memorization. For instance, Bonnaire et al. [21 ] identifies two distinct training timescales: a period of high-quality generation (independent of the number of data points) and a time where memorization scales linearly with the training dataset size. Furthermore, while increased model capacity typically enhances memorization, as shown by other works Yoon et al. [168 ] and Li et al. (2023), in contrast Favero et al. [50 ] suggests that larger architectures may paradoxically shorten the optimal generalization window, making a shorten training time (early stopping) a viable strategy for alleviating memorization. Finally, Kamb & Ganguli [86 ] provides a structural basis for this emergent creativity through a ‘patch-mixing’ mechanism, where the model composes novel images by recombining localized features from the training samples.
Overall, these perspectives complement our interpretation of DMs through the lens of AM. While this work does not focus on aspects of training time and early stopping, these recent studies also suggest that the memorization-to-generalization transition is dependent on the model capacity, and most importantly, the training dataset size – both attributes explored in our work. Thus, it leaves the exploration of the training time effects on the emergence of spurious states in DMs for future works. Moreover, the ‘patch-mixing’ mechanism offers a good explanation for how the model constructs the emergent attractor states we observe, where novel patterns are formed by recombining features of stored memories into stable, non-memorized energy minima. By confirming the existence and distinct computational properties of spurious states in DMs, we help highlight the complexity of the memorization and generalization problems, positioning these emergent attractors not as detrimental artifacts of AM, but as a distinct computation state that possess a basin of attraction (unlike generalized states) akin to memorized states.
Supplementary Material
This section collects the experimental details and additional results that support the findings of this chapter.1
The Two-Dimensional Toy Model
Dataset. To construct the dataset, we uniformly sampled points on the unit circle. Concretely, we had y ∼ p ( y ) = 1 2 π δ ( r − 1 ) \mathbf{y} \sim p(\mathbf{y}) = \frac{1}{2\pi}\delta(r - 1) y ∼ p ( y ) = 2 π 1 δ ( r − 1 ) , where r = y 1 2 + y 2 2 r = \sqrt{y_1^2 + y_2^2} r = y 1 2 + y 2 2 is the radius and δ ( r − 1 ) \delta(r - 1) δ ( r − 1 ) is the delta function ensures that all probability mass lies on radius r = 1 r = 1 r = 1 . The factor 1 2 π \frac{1}{2\pi} 2 π 1 guarantees that the angles are sampled uniformly, relying on the identity:
δ ( y 1 2 + y 2 2 − 1 ) = 2 δ ( y 1 2 + y 2 2 − 1 ) , (64) \delta\left(\sqrt{y_1^2 + y_2^2} - 1\right) = 2\delta\left(y_1^2 + y_2^2 - 1\right), \tag*{(64)} δ ( y 1 2 + y 2 2 − 1 ) = 2 δ ( y 1 2 + y 2 2 − 1 ) , (64)
where p ( y ) = 1 π δ ( y 1 2 + y 2 2 − 1 ) p(\mathbf{y}) = \frac{1}{\pi}\delta(y_1^2 + y_2^2 - 1) p ( y ) = π 1 δ ( y 1 2 + y 2 2 − 1 ) . In practice, we sampled polar coordinates ( r , φ ) (r, \varphi) ( r , φ ) with r = 1 r = 1 r = 1 and uniformly sampled the angular coordinate φ ∈ [ 0 , 2 π ] \varphi\in[0, 2\pi] φ ∈ [ 0 , 2 π ] . We then converted ( r , φ ) (r, \varphi) ( r , φ ) to Cartesian coordinates ( y 1 , y 2 ) (y_1, y_2) ( y 1 , y 2 ) using y 1 = r cos φ y_1 = r \cos\varphi y 1 = r cos φ and y 2 = r sin φ y_2 = r \sin\varphi y 2 = r sin φ .
Moreover, we created a data set of 60000 points using a fixed random seed, and then built smaller subsets by progressively adding distinct samples without replacement, ensuring that each subset is a strict subset of the next. This approach allowed us to systematically examine how the model behaves as we vary the size of the training set.
Exact Score. Following Eq. (63) , the energy can be written in closed form, whose local minima form the continuous data manifold at R = 1 2 R = 1^2 R = 1 2 . Furthermore, in the case of many data points or K → ∞ K \to\infty K → ∞ , we have p ( y ) = 1 π δ ( y 1 2 + y 2 2 − 1 ) p(\mathbf{y}) = \frac{1}{\pi}\delta(y_1^2 + y_2^2 - 1) p ( y ) = π 1 δ ( y 1 2 + y 2 2 − 1 ) . Since p ( R ) ∝ exp − E A M ( R ) p(R) \propto\exp^{-E^{\mathrm{AM}}(R)} p ( R ) ∝ exp − E AM ( R ) , the score can be described as
− ∇ R log p ( R ) = ∇ R E A M ( R ) = 2 R − 2 β I 1 ( 2 β R ) β I 0 ( 2 β R ) = 2 R − 2 I 1 ( 2 β R ) I 0 ( 2 β R ) , (65) -\nabla_R \log p(R) = \nabla_R E^{\mathrm{AM}}(R)
= 2R - \frac{2\beta I_1(2\beta R)}{\beta I_0(2\beta R)}
= 2R - 2\frac{I_1(2\beta R)}{I_0(2\beta R)}, \tag*{(65)} − ∇ R log p ( R ) = ∇ R E AM ( R ) = 2 R − β I 0 ( 2 β R ) 2 β I 1 ( 2 β R ) = 2 R − 2 I 0 ( 2 β R ) I 1 ( 2 β R ) , (65)
where E A M ( R ) E^{\mathrm{AM}}(R) E AM ( R ) is Eq. (63) , and I 1 I_1 I 1 and I 0 I_0 I 0 are the first-order and zero-order modified Bessel functions of the first kind, respectively. With further expansion, the score becomes
∇ R log p ( R ) = 2 ( I 1 ( 2 β R ) I 0 ( 2 β R ) − R ) ⇒ ∇ x log p ( x ) = 2 ( I 1 ( 2 β R ) I 0 ( 2 β R ) − R ) x R . (66) \nabla_R \log p(R) = 2\left(\frac{I_1(2\beta R)}{I_0(2\beta R)} - R\right) \Rightarrow\nabla_x \log p(x) = 2\left(\frac{I_1(2\beta R)}{I_0(2\beta R)} - R\right)\frac{x}{R}. \tag*{(66)} ∇ R log p ( R ) = 2 ( I 0 ( 2 β R ) I 1 ( 2 β R ) − R ) ⇒ ∇ x log p ( x ) = 2 ( I 0 ( 2 β R ) I 1 ( 2 β R ) − R ) R x . (66)
We implemented Eq. (63) on a 20 × 20 20 \times20 20 × 20 grid to obtain the exact energy and score of the model, overlaying 1000 samples from the training set. For visualization purposes, we set β = 20 \beta= 20 β = 20 , ensuring a well-defined energy landscape. Additionally, we normalized the energy by subtracting its minimum value to ensure that the lowest energy point remains at zero.
To align with the theoretical framework, we employed the variance-exploding (VE) SDE of the form:
d x t = σ d w t (67) \mathrm{d}x_t = \sigma\,\mathrm{d}w_t \tag*{(67)} d x t = σ d w t (67)
where the diffusion coefficient g ( t ) = σ g(t) = \sigma g ( t ) = σ . Assuming t ∈ ( 0 , 1 ] t \in(0,1] t ∈ ( 0 , 1 ] , the variance of the diffusion kernel is given by ∫ 0 t g 2 ( s ) d s = σ 2 t \int_0^t g^2(s)\,\mathrm{d}s = \sigma^2t ∫ 0 t g 2 ( s ) d s = σ 2 t , enabling us to construct the corresponding Gaussian kernel:
p ( x t ∣ y ) = N ( x t ; y , σ 2 t I ) (68) p(x_t\mid y) = \mathcal{N}(x_t; y, \sigma^2tI) \tag*{(68)} p ( x t ∣ y ) = N ( x t ; y , σ 2 t I ) (68)
However, in practice we used t ∈ [ ϵ , 1 ] t \in[\epsilon,1] t ∈ [ ϵ , 1 ] with ϵ = 10 − 5 \epsilon= 10^{-5} ϵ = 1 0 − 5 for numerical stability. The generative dynamics are given by
d x t = [ − σ 2 ∇ x t log p t ( x t ) ] d t + σ 2 d w t . (69) \mathrm{d}x_t = \left[-\sigma^2\nabla_{x_t}\log p_t(x_t)\right]\mathrm{d}t + \sigma^2\mathrm{d}w_t. \tag*{(69)} d x t = [ − σ 2 ∇ x t log p t ( x t ) ] d t + σ 2 d w t . (69)
where this runs backwards in time to match the description of Song, Sohl-Dickstein, et al. (2021). The deterministic Probability Flow ODE is
d x t d t = − 1 2 σ 2 ∇ x t log p t ( x t ) (70) \frac{\mathrm{d}x_t}{\mathrm{d}t} = -\frac{1}{2}\sigma^2\nabla_{x_t}\log p_t(x_t) \tag*{(70)} d t d x t = − 2 1 σ 2 ∇ x t log p t ( x t ) (70)
which shares the same marginal distributions as the SDE (69) and is useful for likelihood estimation.
Empirical distribution. We represented the data as an empirical distribution
p ( y ) = 1 K ∑ μ = 1 K δ ( N ) ( y − ξ μ ) (71) p(\mathbf{y}) = \frac{1}{K}\sum_{\mu=1}^{K}\delta^{(N)}(\mathbf{y}-\boldsymbol{\xi}^{\mu}) \tag*{(71)} p ( y ) = K 1 μ = 1 ∑ K δ ( N ) ( y − ξ μ ) (71)
where N N N is the dimensionality of the data point y \mathbf{y} y . Since x t \mathbf{x}_t x t is drawn from the forward process distribution p ( x t ∣ y ) p(\mathbf{x}_t \mid\mathbf{y}) p ( x t ∣ y ) that is conditioned on the data point y \mathbf{y} y , which can be expressed as a Gaussian kernel N ( x t ; y , σ t 2 I ) \mathcal{N}(\mathbf{x}_t;\mathbf{y},\sigma_t^2 I) N ( x t ; y , σ t 2 I ) . We obtained the distribution p ( x t , t ) p(\mathbf{x}_t,t) p ( x t , t ) as
p ( x t , t ) = ∫ p ( x t ∣ y ) p ( y ) d y = 1 K ∑ μ = 1 K ∫ N ( x t ; y , σ t 2 I ) δ ( N ) ( y − ξ μ ) d y = 1 K ∑ μ = 1 K N ( x t ; ξ μ , σ t 2 I ) = 1 K ∑ μ = 1 K 1 ( 2 π σ t 2 ) N / 2 exp ( − ∥ x t − ξ μ ∥ 2 2 2 σ t 2 ) (72) \begin{aligned}
p(\mathbf{x}_t,t) &= \int p(\mathbf{x}_t \mid\mathbf{y})p(\mathbf{y})\,\mathrm{d}\mathbf{y} \\
&= \frac{1}{K}\sum_{\mu=1}^{K}\int\mathcal{N}(\mathbf{x}_t;\mathbf{y},\sigma_t^2 I)\,\delta^{(N)}(\mathbf{y}-\boldsymbol{\xi}^{\mu})\,\mathrm{d}\mathbf{y} \\
&= \frac{1}{K}\sum_{\mu=1}^{K}\mathcal{N}(\mathbf{x}_t;\boldsymbol{\xi}^{\mu},\sigma_t^2 I) \\
&= \frac{1}{K}\sum_{\mu=1}^{K}\frac{1}{(2\pi\sigma_t^2)^{N/2}}\exp\left(-\frac{\lVert\mathbf{x}_t-\boldsymbol{\xi}^{\mu}\rVert_2^2}{2\sigma_t^2}\right) \tag*{(72)}
\end{aligned} p ( x t , t ) = ∫ p ( x t ∣ y ) p ( y ) d y = K 1 μ = 1 ∑ K ∫ N ( x t ; y , σ t 2 I ) δ ( N ) ( y − ξ μ ) d y = K 1 μ = 1 ∑ K N ( x t ; ξ μ , σ t 2 I ) = K 1 μ = 1 ∑ K ( 2 π σ t 2 ) N /2 1 exp ( − 2 σ t 2 ∥ x t − ξ μ ∥ 2 2 ) (72)
which is the marginal distribution underlying E D M E^{\mathrm{DM}} E DM in Eq. (51) , when the variance of the Gaussian kernel is σ t 2 \sigma_t^2 σ t 2 .
Energy Computation. Following Song, Sohl-Dickstein, et al. [147 ] we computed the log-likelihood log p θ ( x 0 ) \log p_{\theta}(\mathbf{x}_0) log p θ ( x 0 ) given by a diffusion model, with the instantaneous change of variable formula (Chen et al. [30 ] ), where x 0 \mathbf{x}_0 x 0 are the generated samples from the model. Replacing Eq. (69) into the log-likelihood equation,
log p 0 ( x 0 ; θ ) = log p T ( x T ) + ∫ 0 T ∇ ⋅ f ~ ( x t , t ) d t (73) \log p_0(\mathbf{x}_0;\theta)=\log p_T(\mathbf{x}_T)+\int_0^T\nabla\cdot\widetilde{\mathbf{f}}(\mathbf{x}_t,t)\,\mathrm{d}t \tag*{(73)} log p 0 ( x 0 ; θ ) = log p T ( x T ) + ∫ 0 T ∇ ⋅ f ( x t , t ) d t (73)
with f ~ ( x t , t ) = − 1 2 σ 2 ∇ x t log p t ( x t ) \widetilde{\mathbf{f}}(\mathbf{x}_t,t)=-\frac{1}{2}\sigma^2\nabla_{\mathbf{x}_t}\log p_t(\mathbf{x}_t) f ( x t , t ) = − 2 1 σ 2 ∇ x t log p t ( x t ) . The function f ~ ( x t , t ) \widetilde{\mathbf{f}}(\mathbf{x}_t,t) f ( x t , t ) comes from the above Probability Flow ODE (70) , and ∇ ⋅ f ~ ( x t , t ) \nabla\cdot\widetilde{\mathbf{f}}(\mathbf{x}_t,t) ∇ ⋅ f ( x t , t ) denotes the divergence of the function (or the trace of its Jacobian).
To estimate the likelihood of the model, we integrated ∇ ⋅ f ~ ( x t , t ) \nabla\cdot\widetilde{\mathbf{f}}(\mathbf{x}_t,t) ∇ ⋅ f ( x t , t ) , from a small time ϵ = 10 − 5 \epsilon=10^{-5} ϵ = 1 0 − 5 to T = 1 T=1 T = 1 , using a numerical integrator and added the prior logarithmic likelihood to it following Eq. (73) . The divergence term ∇ ⋅ f ~ ( x t , t ) \nabla\cdot\widetilde{\mathbf{f}}(\mathbf{x}_t,t) ∇ ⋅ f ( x t , t ) is computed using the Laplacian, which is computationally feasible for this toy example, instead of using the Hutchinson trace estimator (Hutchinson, [78 ] ) done in Song, Sohl-Dickstein, et al. [147 ] . We use the RK45 method (Dormand & Prince, [43 ] ) implemented in the ODE solver scipy.integrate.solve_ivp from Scipy (Virtanen et al., [159 ] ) to solve the above integral.
To compute the energy, we used the equation of E D M E^{\mathrm{DM}} E DM in Eq. (51) , which can be also computed using Eq. (73) . From the Boltzmann distribution p ( x ) = 1 Z exp [ − β E ( x ) ] p(x)=\frac{1}{Z}\exp[-\beta E(x)] p ( x ) = Z 1 exp [ − β E ( x )] , we obtained log p ( x ) ∝ − β E ( x ) \log p(x) \propto-\beta E(x) log p ( x ) ∝ − β E ( x ) . In our case, the inverse temperature is β = 1 2 σ 2 t \beta= \frac{1}{2\sigma^{2}t} β = 2 σ 2 t 1 . The equation for our VE-SDE thus becomes
E D M ( x t , t ) = − 2 σ t 2 log p ( x t , t ) (74) E^{\mathrm{DM}}(x_t,t)=-2\sigma_t^2\log p(x_t,t) \tag*{(74)} E DM ( x t , t ) = − 2 σ t 2 log p ( x t , t ) (74)
To visualize the energy landscape, we observed the energy at t = 0.15 t = 0.15 t = 0.15 which corresponds to β = 3.3 \beta= 3.3 β = 3.3 .
Model and Training Details. For each training data size K K K , we used an MLP-based network to estimate the score s θ ( x t , t ) s_\theta(x_t,t) s θ ( x t , t ) . The general architecture includes (1) a Fourier random feature (FRF) timestep embedding layer and a linear layer which projects the concatenation of FRF timestep embedding and input into a latent dimension of 256; (2) an encoder which consists of four non-convolutional residual blocks (using the same latent dimension) with Swish ((Ramachandran et al., 2017)) activation in between; (3) a decoder which consists of the same number of residual blocks; and (4) a linear block which projects the latent variable back to the 2D space.
The network was trained in continuous time with σ = 1 \sigma= 1 σ = 1 using the objective function from Ho et al. (2020) and [147 ] . Optimization is performed using the Adam ([88 ] ) optimizer with a learning rate l r = 10 − 4 lr = 10^{-4} l r = 1 0 − 4 . The batch size is set to min ( K , 500 ) \min(K, 500) min ( K , 500 ) . All models were trained for 800000 iterations with the maximum batch size of 500. Meanwhile, we used Euler-Maruyama discretization method ([92 ] ), with 1000 discretized steps, to solve the reverse SDE (69) to generate samples.
Clustering of Generated Points. To cluster the generated samples (as part of visualizing their concentrations), we used the AgglomerativeClustering algorithm from scikit-learn, a part of SciPy ([159 ] ).
Log-Likelihood of Diffusion Models. For concreteness, we provide the likelihood computation of Eq. (73) within this section to highlight the formulation of Eq. (73) done by [147 ] and [30 ] .
Probability Flow ODE. Suppose we have the following forward process:
d x t = f ( x t , t ) d t + g ( x t , t ) d w t (75) \mathrm{d}x_t=f(x_t,t)\mathrm{d}t+g(x_t,t)\mathrm{d}w_t \tag*{(75)} d x t = f ( x t , t ) d t + g ( x t , t ) d w t (75)
where f ( ⋅ , t ) : R N → R N f(\cdot,t):\mathbb{R}^{N}\to\mathbb{R}^{N} f ( ⋅ , t ) : R N → R N , g ( ⋅ , t ) : R N → R N × N g(\cdot,t):\mathbb{R}^{N}\to\mathbb{R}^{N\times N} g ( ⋅ , t ) : R N → R N × N and N N N denotes the dimensionality of x t x_t x t . Using the derivations done by Song, Sohl-Dickstein, et al. [147 ] in their Appendix D, the evolution of the marginal probability density p t ( x t ) p_t(\mathbf{x}_t) p t ( x t ) is
∂ p t ( x t ) ∂ t = − ∑ i = 1 N ∂ ∂ x i [ f i ( x t , t ) p t ( x t ) ] + 1 2 ∑ i = 1 N ∑ j = 1 N ∂ 2 ∂ x i ∂ x j [ ∑ k = 1 N g i j ( x t , t ) g j k ( x t , t ) p t ( x t ) ] (76) \frac{\partial p_t(\mathbf{x}_t)}{\partial t}
= -\sum_{i=1}^{N}\frac{\partial}{\partial x_i}\left[f_i(\mathbf{x}_t,t)p_t(\mathbf{x}_t)\right]
+\frac{1}{2}\sum_{i=1}^{N}\sum_{j=1}^{N}\frac{\partial^2}{\partial x_i\partial x_j}\left[\sum_{k=1}^{N}g_{ij}(\mathbf{x}_t,t)g_{jk}(\mathbf{x}_t,t)p_t(\mathbf{x}_t)\right] \tag*{(76)} ∂ t ∂ p t ( x t ) = − i = 1 ∑ N ∂ x i ∂ [ f i ( x t , t ) p t ( x t ) ] + 2 1 i = 1 ∑ N j = 1 ∑ N ∂ x i ∂ x j ∂ 2 [ k = 1 ∑ N g ij ( x t , t ) g j k ( x t , t ) p t ( x t ) ] (76)
which corresponds to the Fokker-Planck equation (Øksendal, [117 ] ):
∂ p t ( x t ) ∂ t = − ∑ i = 1 N ∂ ∂ x i [ f i ( x t , t ) p t ( x t ) ] + 1 2 ∑ i = 1 N ∂ ∂ x i [ ∑ j = 1 N ∂ ∂ x j [ ∑ k = 1 N g i j ( x t , t ) g j k ( x t , t ) p t ( x t ) ] ] = − ∑ i = 1 N ∂ ∂ x i [ f i ( x t , t ) p t ( x t ) ] + 1 2 ∑ i = 1 N ∂ ∂ x i [ p t ( x t ) ∇ ⋅ [ g ( x t , t ) g ( x t , t ) T ] + p t ( x t ) [ g ( x t , t ) g ( x t , t ) T ] ∇ x t log p t ( x t ) ] = − ∑ i = 1 N ∂ ∂ x i { f i ( x t , t ) p t ( x t ) − 1 2 [ ∇ ⋅ [ g ( x t , t ) g ( x t , t ) T ] + [ g ( x t , t ) g ( x t , t ) T ] ∇ x t log p t ( x t ) ] p t ( x t ) } = − ∑ i = 1 N ∂ ∂ x i [ f ~ i ( x t , t ) p t ( x t ) ] (77) \begin{aligned}
\frac{\partial p_t(\mathbf{x}_t)}{\partial t}
&= -\sum_{i=1}^{N}\frac{\partial}{\partial x_i}\left[f_i(\mathbf{x}_t,t)p_t(\mathbf{x}_t)\right] \\
&\quad+\frac{1}{2}\sum_{i=1}^{N}\frac{\partial}{\partial x_i}\left[\sum_{j=1}^{N}\frac{\partial}{\partial x_j}\left[\sum_{k=1}^{N}g_{ij}(\mathbf{x}_t,t)g_{jk}(\mathbf{x}_t,t)p_t(\mathbf{x}_t)\right]\right] \\
&= -\sum_{i=1}^{N}\frac{\partial}{\partial x_i}\left[f_i(\mathbf{x}_t,t)p_t(\mathbf{x}_t)\right] \\
&\quad+\frac{1}{2}\sum_{i=1}^{N}\frac{\partial}{\partial x_i}\left[p_t(\mathbf{x}_t)\nabla\cdot\left[\mathbf{g}(\mathbf{x}_t,t)\mathbf{g}(\mathbf{x}_t,t)^{\mathsf{T}}\right]\right. \\
&\qquad\left.{}+p_t(\mathbf{x}_t)\left[\mathbf{g}(\mathbf{x}_t,t)\mathbf{g}(\mathbf{x}_t,t)^{\mathsf{T}}\right]\nabla_{\mathbf{x}_t}\log p_t(\mathbf{x}_t)\right] \\
&= -\sum_{i=1}^{N}\frac{\partial}{\partial x_i}\left\{f_i(\mathbf{x}_t,t)p_t(\mathbf{x}_t)\right. \\
&\qquad\left.{}-\frac{1}{2}\left[\nabla\cdot\left[\mathbf{g}(\mathbf{x}_t,t)\mathbf{g}(\mathbf{x}_t,t)^{\mathsf{T}}\right]
+\left[\mathbf{g}(\mathbf{x}_t,t)\mathbf{g}(\mathbf{x}_t,t)^{\mathsf{T}}\right]\nabla_{\mathbf{x}_t}\log p_t(\mathbf{x}_t)\right]p_t(\mathbf{x}_t)\right\} \\
&= -\sum_{i=1}^{N}\frac{\partial}{\partial x_i}\left[\tilde{f}_i(\mathbf{x}_t,t)p_t(\mathbf{x}_t)\right] \tag*{(77)}
\end{aligned} ∂ t ∂ p t ( x t ) = − i = 1 ∑ N ∂ x i ∂ [ f i ( x t , t ) p t ( x t ) ] + 2 1 i = 1 ∑ N ∂ x i ∂ [ j = 1 ∑ N ∂ x j ∂ [ k = 1 ∑ N g ij ( x t , t ) g j k ( x t , t ) p t ( x t ) ] ] = − i = 1 ∑ N ∂ x i ∂ [ f i ( x t , t ) p t ( x t ) ] + 2 1 i = 1 ∑ N ∂ x i ∂ [ p t ( x t ) ∇ ⋅ [ g ( x t , t ) g ( x t , t ) T ] + p t ( x t ) [ g ( x t , t ) g ( x t , t ) T ] ∇ x t log p t ( x t ) ] = − i = 1 ∑ N ∂ x i ∂ { f i ( x t , t ) p t ( x t ) − 2 1 [ ∇ ⋅ [ g ( x t , t ) g ( x t , t ) T ] + [ g ( x t , t ) g ( x t , t ) T ] ∇ x t log p t ( x t ) ] p t ( x t ) } = − i = 1 ∑ N ∂ x i ∂ [ f ~ i ( x t , t ) p t ( x t ) ] (77)
where f ~ ( x t , t ) = f ( x t , t ) − 1 2 ∇ ⋅ [ g ( x t , t ) g ( x t , t ) T ] − 1 2 [ g ( x t , t ) g ( x t , t ) T ] ∇ x t log p t ( x t ) \tilde{\mathbf{f}}(\mathbf{x}_t,t)=\mathbf{f}(\mathbf{x}_t,t)-\frac{1}{2}\nabla\cdot\left[\mathbf{g}(\mathbf{x}_t,t)\mathbf{g}(\mathbf{x}_t,t)^{\mathsf{T}}\right]-\frac{1}{2}\left[\mathbf{g}(\mathbf{x}_t,t)\mathbf{g}(\mathbf{x}_t,t)^{\mathsf{T}}\right]\nabla_{\mathbf{x}_t}\log p_t(\mathbf{x}_t) f ~ ( x t , t ) = f ( x t , t ) − 2 1 ∇ ⋅ [ g ( x t , t ) g ( x t , t ) T ] − 2 1 [ g ( x t , t ) g ( x t , t ) T ] ∇ x t log p t ( x t ) . With careful inspection of Eq. (77) , it is equal to the Liouville equation if the diffusion term g ~ ( x , t ) = 0 \tilde{\mathbf{g}}(\mathbf{x},t)=0 g ~ ( x , t ) = 0 and essentially, it is the probability flow ODE where
d x t = f ~ ( x t , t ) d t + g ~ ( x t , t ) d w t ⏟ 0 = { f ( x t , t ) − 1 2 ∇ ⋅ [ g ( x t , t ) g ( x t , t ) T ] − 1 2 [ g ( x t , t ) g ( x t , t ) T ] ∇ x t log p t ( x t ) } d t (78) \begin{aligned}
\mathrm{d}\mathbf{x}_t
&= \tilde{\mathbf{f}}(\mathbf{x}_t,t)\mathrm{d}t+\underbrace{\tilde{\mathbf{g}}(\mathbf{x}_t,t)\mathrm{d}\mathbf{w}_t}_{0} \\
&= \left\{\mathbf{f}(\mathbf{x}_t,t)-\frac{1}{2}\nabla\cdot\left[\mathbf{g}(\mathbf{x}_t,t)\mathbf{g}(\mathbf{x}_t,t)^{\mathsf{T}}\right]-\frac{1}{2}\left[\mathbf{g}(\mathbf{x}_t,t)\mathbf{g}(\mathbf{x}_t,t)^{\mathsf{T}}\right]\nabla_{\mathbf{x}_t}\log p_t(\mathbf{x}_t)\right\}\mathrm{d}t \tag*{(78)}
\end{aligned} d x t = f ~ ( x t , t ) d t + 0 g ~ ( x t , t ) d w t = { f ( x t , t ) − 2 1 ∇ ⋅ [ g ( x t , t ) g ( x t , t ) T ] − 2 1 [ g ( x t , t ) g ( x t , t ) T ] ∇ x t log p t ( x t ) } d t (78)
Using the ODE (78) , we can derive an appropriate probability flow ODE from the forward process detailed in § 4.2 . For example, we have the following equation
d x t = { f ( x t , t ) − 1 2 g ( t ) 2 ∇ x t log p t ( x t ) } ⏟ : = f ~ ( x t , t ) d t (79) \mathrm{d}\mathbf{x}_t = \underbrace{\left\{\mathbf{f}(\mathbf{x}_t,t) - \frac{1}{2}g(t)^2\nabla_{\mathbf{x}_t}\log p_t(\mathbf{x}_t)\right\}}_{:=\widetilde{\mathbf{f}}(\mathbf{x}_t,t)}\mathrm{d}t \tag*{(79)} d x t = := f ( x t , t ) { f ( x t , t ) − 2 1 g ( t ) 2 ∇ x t log p t ( x t ) } d t (79)
for the toy model where f ( x t , t ) = 0 \mathbf{f}(\mathbf{x}_t,t)=0 f ( x t , t ) = 0 .
Log-likelihood. Furthermore, if we first take the logarithm of Eq. (77) where
∂ log p t ( x t ) ∂ t = 1 p t ( x t ) ∂ p t ( x t ) ∂ t = − ∑ i = 1 N ∂ f ~ i ( x t , t ) ∂ x i = ∇ ⋅ f ~ ( x t , t ) (80) \frac{\partial\log p_t(\mathbf{x}_t)}{\partial t}
= \frac{1}{p_t(\mathbf{x}_t)}\frac{\partial p_t(\mathbf{x}_t)}{\partial t}
= -\sum_{i=1}^{N}\frac{\partial\widetilde{f}_i(\mathbf{x}_t,t)}{\partial x_i}
= \nabla\cdot\widetilde{\mathbf{f}}(\mathbf{x}_t,t) \tag*{(80)} ∂ t ∂ log p t ( x t ) = p t ( x t ) 1 ∂ t ∂ p t ( x t ) = − i = 1 ∑ N ∂ x i ∂ f i ( x t , t ) = ∇ ⋅ f ( x t , t ) (80)
we can compute the log-likelihood of p 0 ( x 0 ) p_0(\mathbf{x}_0) p 0 ( x 0 ) using the following equation
log p 0 ( x 0 ) = log p T ( x T ) + ∫ 0 T ∇ ⋅ f ~ ( x t , t ) d t (81) \log p_0(\mathbf{x}_0) = \log p_T(\mathbf{x}_T) + \int_0^T \nabla\cdot\widetilde{\mathbf{f}}(\mathbf{x}_t,t)\,\mathrm{d}t \tag*{(81)} log p 0 ( x 0 ) = log p T ( x T ) + ∫ 0 T ∇ ⋅ f ( x t , t ) d t (81)
where ∇ ⋅ f ~ ( x t , t ) \nabla\cdot\widetilde{\mathbf{f}}(\mathbf{x}_t,t) ∇ ⋅ f ( x t , t ) is parameterized as ∇ ⋅ f ~ θ ( x t , t ) \nabla\cdot\widetilde{\mathbf{f}}_\theta(\mathbf{x}_t,t) ∇ ⋅ f θ ( x t , t ) since s θ ( x t , t ) = ∇ x t log p t ( x t ; θ ) s_\theta(\mathbf{x}_t,t)=\nabla_{\mathbf{x}_t}\log p_t(\mathbf{x}_t;\theta) s θ ( x t , t ) = ∇ x t log p t ( x t ; θ ) . Moreover, in general the term ∇ ⋅ f ~ θ ( x t , t ) \nabla\cdot\widetilde{\mathbf{f}}_\theta(\mathbf{x}_t,t) ∇ ⋅ f θ ( x t , t ) is computed via the Hutchinson trace estimator [78 ] ,
∇ ⋅ f ~ θ ( x t , t ) = E p ( ϵ ) [ ϵ T ∇ x t f ~ θ ( x t , t ) ϵ ] (82) \nabla\cdot\widetilde{\mathbf{f}}_\theta(\mathbf{x}_t,t)
= \mathbb{E}_{p(\epsilon)}\left[\epsilon^{\mathsf{T}}\nabla_{\mathbf{x}_t}\widetilde{\mathbf{f}}_\theta(\mathbf{x}_t,t)\epsilon\right] \tag*{(82)} ∇ ⋅ f θ ( x t , t ) = E p ( ϵ ) [ ϵ T ∇ x t f θ ( x t , t ) ϵ ] (82)
where ∇ x t f ~ θ ( x t , t ) \nabla_{\mathbf{x}_t}\widetilde{\mathbf{f}}_\theta(\mathbf{x}_t,t) ∇ x t f θ ( x t , t ) denotes the Jacobian of f ~ θ ( x t , t ) \widetilde{\mathbf{f}}_\theta(\mathbf{x}_t,t) f θ ( x t , t ) and the random variable ϵ \epsilon ϵ satisfies E p ( ϵ ) [ ϵ ] = 0 \mathbb{E}_{p(\epsilon)}[\epsilon]=0 E p ( ϵ ) [ ϵ ] = 0 and Cov p ( ϵ ) [ ϵ ] = I \operatorname{Cov}_{p(\epsilon)}[\epsilon]=I Cov p ( ϵ ) [ ϵ ] = I .
However, for the toy example, due to its low dimensionality we found that it is possible to not utilize the Hutchinson trace estimator at all, and instead opted to compute the trace of the Jacobian without using the noise estimators.
Memorization-to-Generalization Transition
Selection of Points. For the computation of Figure 3.3 and Figure 3.4 , we followed the experiment setup of Yoon et al. [168 ] and conducted an initial sparse search of the transition, starting at data size 500 and doubling it all the way to the total data size ∣ S ∣ |S| ∣ S ∣ , i.e., K ∈ { 500 , 1000 , 2000 , … , ∣ S ∣ } K \in\{500, 1000, 2000, \ldots, |S|\} K ∈ { 500 , 1000 , 2000 , … , ∣ S ∣ } .
We then identified two transitional critical points, A A A and B B B , see Table 3.1 , to conduct a more thorough search to elucidate the memorization-to-generalization transition.
Table 3.1: A table showing the critical points A A A and B B B of the memorization-generalization transition for each dataset. We use 30 linearly spaced points between A A A and B B B to finely characterize the memorization-to-generalization transition.
Table 3.1.
Here, point A A A indicates the initial drop in memorization while B B B signals the plateauing of memorization. To capture the finer details of this transition, we performed a search of 30 inclusive linearly spaced points, from point A A A to point B B B . For regions outside of the transition, using linear spacing, we sampled 5 points from ∣ S ∣ = 2 |S| = 2 ∣ S ∣ = 2 to point A A A , and another 5 points from B B B to the total dataset size ∣ S ∣ |S| ∣ S ∣ , inclusively. In other words, we trained a separate model for each selected data size and generated the corresponding evaluation and synthetic sets while keeping the same configuration for all models, see Table 3.3 . Then, we computed the memorization, spurious, and generalization fractions using the detection metrics in § 4.3 . The selection process for the values δ m \delta_m δ m and δ s \delta_s δ s is explained below.
Table 3.3: A table displaying both model and training configurations for each dataset.
Table 3.3.
Selection of Distance Metric. For high-dimensional datasets, CIFAR-10 [96 ] and LSUN-CHURCH (Yu et al., 2015), we utilized LPIPS [173 ] with the AlexNet [97 ] backbone, as the function d ( ⋅ , ⋅ ) d(\cdot,\cdot) d ( ⋅ , ⋅ ) for both memorization and spurious detection metrics. We selected this approach since it is a commonly used perceptual metric that compares the similarity between two images based on their feature representations. Moreover, it has been shown to better align with human judgment of visual similarity, making it ideal for assessing the quality and diversity of generated samples in these high-dimensional image datasets [173 ] . For simpler datasets like MNIST [38 ] and FASHION-MNIST [167 ] , where images are single-channel and less complex, we found that L 2 L_2 L 2 -distance suffices for both memorization and spurious detection metrics.
Selection of Threshold Values. The detection thresholds, δ m \delta_m δ m and δ s \delta_s δ s , were set based on the chosen distance metric d ( ⋅ , ⋅ ) d(\cdot,\cdot) d ( ⋅ , ⋅ ) and visual inspection of the distance histograms for bimodality as described in § 4.3 . Moreover, these thresholds were chosen to reflect the varying visual complexity and feature richness of the datasets, and their values for each dataset are shown in Table 3.2 . Specifically, for each training data size K K K of each dataset, we manually inspected the bimodality of the olive and gray histograms to select δ m \delta_m δ m and δ s \delta_s δ s . Moreover, to better tune these thresholds at each K K K , we manually inspected the least 5 spurious samples, ensuring that they do not resemble memorized samples, while doing the same for memorized samples. If the resemblance of one set to another is too strong, we decreased the corresponding threshold. Please refer to Figure 3.11 –Figure 3.13 below and Figure 3.2 for examples of the histograms. Please note that the bimodality of the gray histograms in FASHION-MNIST might not be significant, but it is enough to select their respective δ s \delta_s δ s .
Table 3.2: Table displaying the range of the memorized and spurious threshold values in the computation of the transition plots in Figure 3.3 . The full set of threshold values is provided alongside the code.
Table 3.2.
Figure 3.11. Different sample types across the memorization-to-generalization transition for LSUN-CHURCH ((Yu et al., 2015)), defined by the spurious and memorized thresholds, δ s \delta_s δ s and δ m \delta_m δ m . The grey histogram shows the distances between synthetic samples and their nearest neighbors from the synthetic set S ′ S^\prime S ′ . The threshold δ s \delta_s δ s is defined as a boundary between the two peaks. The olive histogram depicts the distances from the synthetic samples to their closest neighbor from the training set S S S , with threshold δ m \delta_m δ m separating the two peaks. The threshold δ m \delta_m δ m is chosen much stricter here such that it works well for all training dataset sizes via visual inspection. Memorized samples are located in the left peak of the olive histogram, below δ m \delta_m δ m . In contrast, generalized and spurious samples appear to the right of δ m \delta_m δ m (olive histogram). Examples of the generated samples forming each of the four peaks of the histograms are shown in the inset frames. For each generated sample top-4 nearest neighbor images from the training set are shown in the top row, and top-4 nearest neighbors from the synthetic set are shown in the bottom row. Training set size K = 4896 K = 4896 K = 4896 was used in this figure (at the peak of the frequency of spurious states), but phenomena discussed are generic and largely independent of this specific value. The fraction of the memorized, spurious, and generalized samples in the pool of all generated samples is shown in the bottom left panel as a function of the training set size. The inset shows amplified spurious fraction (green curve).
Figure 3.13. Different sample types across the memorization-to-generalization transition for MNIST [38 ] , defined by the spurious and memorized thresholds, δ s \delta_s δ s and δ m \delta_m δ m . The grey histogram shows the distances between synthetic samples and their nearest neighbors from the synthetic set S ′ S' S ′ . The threshold δ s \delta_s δ s is defined as a boundary between the two peaks. The olive histogram depicts the distances from the synthetic samples to their closest neighbor from the training set S S S , with threshold δ m \delta_m δ m separating the two peaks. Memorized samples are located in the left peak of the olive histogram, below δ m \delta_m δ m . In contrast, generalized and spurious samples appear to the right of δ m \delta_m δ m (olive histogram). Examples of the generated samples forming each of the four peaks of the histograms are shown in the inset frames. For each generated sample top-4 nearest neighbor images from the training set are shown in the top row, and top-4 nearest neighbors from the synthetic set are shown in the bottom row. Training set size K = 21379 K = 21379 K = 21379 was used in this figure, which is slightly past the peak of the frequency of spurious states. The phenomena discussed are generic and largely independent of this specific value. The fraction of the memorized, spurious, and generalized samples in the pool of all generated samples is shown in the bottom left panel as a function of the training set size. The inset shows amplified spurious fraction (green curve).
Model and Training Details. For each point in Figure 3.3 and Figure 3.4 , we trained a DDPM-based diffusion model, where the score model is a PixelCNN++ based U-Net (van den Oord, Kalchbrenner, et al. 2016; Salimans et al. [133 ] ). We kept the variances, β min = 10 − 4 \beta_{\min}=10^{-4} β m i n = 1 0 − 4 and β max = \beta_{\max}= β m a x = _久久爱 2 × 10 − 2 2 \times10^{-2} 2 × 1 0 − 2 , timesteps T = 1000 T = 1000 T = 1000 , and learning rate l r = 2 × 10 − 4 lr = 2 \times10^{-4} l r = 2 × 1 0 − 4 for all models and datasets. Each model has 2 residual blocks He et al., 2016 for each down-sampling and up-sampling layer, while an attention block is placed at 16 × 16 \times 16 × resolution. We only modified the channel multipliers for each model based on the complexity of the dataset, see Table 3.3 . If the training data size K K K is smaller than the specified batch size, the batch size is set to be equal to K K K . For generation or inference, we used the exponential moving average of each trained model, as delineated in Ho et al. (2020), which is obtained with the decay value set as 0.9999 during training. Please note that we did not use random flipping in the training of our models, since we want our measurements to reflect the training data size at best as random flipping implicitly increases the number of patterns that the models see during training. However, we did use dropout (of value 0.1) for the training of CIFAR-10 Krizhevsky, [96 ] , MNIST Deng, [38 ] , and FASHION-MNIST Xiao et al., [167 ] models. For LSUN-CHURCH dataset (Yu et al., 2015), the images were center-cropped and down-sampled to 64 × 64 64 \times64 64 × 64 resolution. Lastly, for each of the training set S α S_\alpha S α , where α = 1 , … , M \alpha= 1, \ldots, M α = 1 , … , M , they are split from the original dataset given a specific size, using the same random seed value of 3407.
Additional Results. Inspired by Yoon et al. [168 ] and Gu et al. (2025), we extend our investigation on the memorization-generalization transition by studying the effects of varying the parameter size of the diffusion model for CIFAR-10 Krizhevsky, [96 ] and LSUN-CHURCH (Yu et al., 2015). The results of this experiment are recorded in Figure 3.8 -Figure 3.9 for these two datasets respectively. Specifically, we trained two additional sets of 38 diffusion models, with the initial latent dimensions of 64 and 96 respectively, and repeated the same experimental setup delineated above, see also Table 3.3 .
Figure 3.8. The fractions of memorized, spurious, and generalized samples in synthetic sets across different training sizes for CIFAR-10 [96 ] and various model’s widths. As the training data size K K K increases, memorization decreases while the emergence of spurious patterns follows and the fraction of generalized patterns steadily increase (top row). The fraction of spurious patterns rises and decreases at the boundary between the memorization and generalization phases (bottom row). Additionally, with a smaller number of parameters, the memorization-generalization transition happens at an earlier stage (or smaller K K K ), since the model has a memorization capacity. In contrast, as the model’s size increases, the transition happens at an later stage (or larger K K K ), where it is able to memorize more training data. The numbering, e.g., 64, 96, and 128, denotes the initial latent dimension of the U-Net, see Table 3.3 .
Figure 3.9. The fractions of memorized, spurious, and generalized samples in synthetic sets across different training sizes for LSUN-CHURCH ((Yu et al., 2015)) and various model’s widths. As the training data size K K K increases, memorization decreases while the emergence of spurious patterns follows and the fraction of generalized patterns steadily increase (top row). The fraction of spurious patterns rises and decreases at the boundary between the memorization and generalization phases (bottom row). Additionally, with a smaller number of parameters, the memorization-generalization transition happens at an earlier stage (or smaller K K K ), since the model has a memorization capacity. In contrast, as the model’s size increases, the transition happens at an later stage (or larger K K K ), where it is able to memorize more training data. The numbering, e.g., 64, 96, and 128, denotes the initial latent dimension of the U-Net, see Table 3.3 .
For CIFAR-10 and the U-Net (64) models, we identified the critical points, A A A and B B B , to be 500 and 8000 respectively. Meanwhile, for the U-Net (96) models, these critical points are 2000 and 16000. To select δ m \delta_m δ m and δ s \delta_s δ s , we followed the same process detailed above by observing the distance histograms to see where bimodality occurs with respect to the distance value, and manually inspecting the images to ensure there is a minimal amount of false positives in memorized and spurious samples. Similarly, for the LSUN-CHURCH models, we identified the critical points, A A A and B B B , to be 1000 and 8000 for the U-Net (64) models; and for the larger U-Net (128) models, 4000 and 16000 as the critical points. Please refer to Table 3.2 for the threshold values.
With the smaller U-Net (64) models, we observe the memorization-generalization transition happens at an earlier stage with respect to the larger U-Net (128) models, where the peak of spurious samples appears at K = 2568 K = 2568 K = 2568 instead of K = 5862 K = 5862 K = 5862 for CIFAR-10, and K = 4862 K = 4862 K = 4862 instead of K = 6086 K = 6086 K = 6086 for LSUN-CHURCH. Overall, these results indicate that as the parameter size of the diffusion model increases, the memorization capacity of the model is increased and thus, generalization is delayed since the model can memorize more of its training data denoted by the appearance of spurious patterns happening at a larger training data size K K K . In contrast, when the memorization capacity is reduced, generalization is initiated at an earlier stage (or smaller training data size) given a larger parameterized model. Most importantly, the emergence of spurious patterns remains consistent despite the variations in the parameter size of the diffusion model: these patterns quickly rise and fall at the boundaries of the memorization-to-generalization transition.
Additionally, to verify the consistency of the memorization-generalization transition, we explored the influence of larger synthetic sets and recorded our results in Figure 3.10 . Specifically, we repeated our experiment done in Figure 3.3 for CIFAR-10 using 8 × 8 \times 8 × synthetic sets, which was originally done using 4 × 4 \times 4 × synthetic sets. Based on these results, we observe a slight increase in the fraction of spurious samples when using the larger 8 × 8 \times 8 × synthetic sets. Specifically, at K = 5862 K = 5862 K = 5862 , the fraction increases from 0.04 to roughly 0.06 with respect to the synthetic set size. Nonetheless, the trend of memorization-generalization, with the emergence of spurious samples, is still maintained regardless of the multiplier for the synthetic size. This aspect highlights the consistency of the spurious phenomenon in diffusion models in relation to the varying of training data size.
Figure 3.10. Memorization-Generalization transition plots for the CIFAR-10 dataset comparing 4 × 4 \times 4 × and 8 × 8 \times 8 × synthetic set sizes. The memorization-generalization transition is computed with 4 × 4 \times 4 × synthetic sets (left) and with 8 × 8 \times 8 × synthetic sets (right) for the same training data sizes. With the larger synthetic sets, more spurious patterns are detected around the peak of the transition. However, the overall trend is maintained, as these patterns quickly rise during the co-existence of memorization and generalization and fall as generalization becomes the dominant phase. Both figures use the same memorized and spurious threshold values detailed in Table 3.2 .
Additional Visualizations of Distance Histogram. Figure 3.11 –Figure 3.13 show the distance histograms used to select the thresholds for LSUN-CHURCH, FASHION-MNIST, and MNIST, complementing Figure 3.2 for CIFAR-10.
Figure 3.12. Different sample types across the memorization-to-generalization transition for FASHION-MNIST ([167 ] ), defined by the spurious and memorized thresholds, δ s \delta_s δ s and δ m \delta_m δ m . The grey histogram shows the distances between synthetic samples and their nearest neighbors from the synthetic set S ′ S' S ′ . The threshold δ s \delta_s δ s is defined as a boundary between the two peaks. The olive histogram depicts the distances from the synthetic samples to their closest neighbor from the training set S S S , with threshold δ m \delta_m δ m separating the two peaks. Memorized samples are located in the left peak of the olive histogram, below δ m \delta_m δ m . In contrast, generalized and spurious samples appear to the right of δ m \delta_m δ m (olive histogram). Examples of the generated samples forming each of the four peaks of the histograms are shown in the inset frames. For each generated sample top-4 nearest neighbor images from the training set are shown in the top row, and top-4 nearest neighbors from the synthetic set are shown in the bottom row. Training set size K = 7724 K = 7724 K = 7724 was used in this figure (at the peak of the frequency of spurious states), but phenomena discussed are generic and largely independent of this specific value. The fraction of the memorized, spurious, and generalized samples in the pool of all generated samples is shown in the bottom left panel as a function of the training set size. The inset shows amplified spurious fraction (green curve).
The Volume of the Basin of Attraction
Algorithm Details. To obtain the average log-volume results recorded in Figure 3.4 , we first computed the critical time t c t_c t c given an image x ^ = x 0 \hat{\mathbf{x}} = \mathbf{x}_0 x ^ = x 0 . Specifically, this is done by using Alg. (1), where t c t_c t c is obtained using the deterministic DDIM (Song, Meng, & Ermon, [146 ] ) sampler to denoise the perturbed version x t \mathbf{x}_t x t of x 0 \mathbf{x}_0 x 0 for each step in t = 1 , … , T t = 1, \ldots, T t = 1 , … , T , given N ′ N' N ′ number of denoising steps starting backward from t t t to 0 0 0 . To save computational time, the algorithm utilizes a stride constant s s s to skip over some of the timesteps t = 1 , 1 + s , 1 + 2 s , … , T − s − 1 t = 1, 1 + s, 1 + 2s, \ldots, T - s - 1 t = 1 , 1 + s , 1 + 2 s , … , T − s − 1 . For each timestep t t t , the variance preserving forward process is applied onto the targeted image x 0 \mathbf{x}_0 x 0 yielding x t \mathbf{x}_t x t . To account for the variations in noise, the image x 0 \mathbf{x}_0 x 0 is perturbed for M M M number of times at each step t t t .
To check whether if the critical time t c t_c t c is reached, the algorithm utilizes a distance metric d ( ⋅ , ⋅ ) d(\cdot,\cdot) d ( ⋅ , ⋅ ) , which is LPIPS (Zhang et al., [173 ] ), equipped with the vgg-16 backbone (Simonyan & Zisserman, [138 ] ) for all of the datasets. The distance metric d ( ⋅ , ⋅ ) d(\cdot,\cdot) d ( ⋅ , ⋅ ) checks whether if a recovered image x ^ 0 \hat{\mathbf{x}}_0 x ^ 0 , obtained from the DDIM sampler (Song, Meng, & Ermon, [146 ] ) with N ′ N' N ′ denoising steps, is similar to the original pattern x 0 \mathbf{x}_0 x 0 within an error threshold δ d ∈ ( 0 , 1 ) \delta_d \in(0,1) δ d ∈ ( 0 , 1 ) . Unlike the experiment on the memorization-generalization transition detailed in § 4.6.2 , we can afford to trade computational time for better accuracy in this experiment by using a larger backbone for LPIPS. To keep track of the critical time t c t_c t c for all perturbations, we initialized it as a vector of integers t c ∈ N M \mathbf{t}_c \in\mathbb{N}^M t c ∈ N M , where M M M is the number of perturbations or trials for the image x 0 \mathbf{x}_0 x 0 . To ensure that t c t_c t c is correct, we utilized a binary stopping vector S ^ ∈ { 0 , 1 } M \hat{\mathbf{S}} \in\{0,1\}^M S ^ ∈ { 0 , 1 } M , which keeps track of whether each perturbation of x 0 \mathbf{x}_0 x 0 is no longer recoverable, such that we only update an entry of the vector t c \mathbf{t}_c t c if and only if the corresponding entry in S ^ \hat{\mathbf{S}} S ^ is zero or not stopped.
Since the entire process of finding t c t_c t c is a rough search over a set of timesteps, we require a ‘breaking condition’ for the search. In Alg. (1), this condition is determined by the value p ∈ [ 0 , 1 ] p \in[0,1] p ∈ [ 0 , 1 ] , which is a probability corresponding to the recovery probability of the image x 0 \mathbf{x}_0 x 0 with respect to its M M M perturbations. To compute p p p , we calculated the distance vector d = d ( x ^ 0 , x 0 ) \mathbf{d} = d(\hat{\mathbf{x}}_0,\mathbf{x}_0) d = d ( x ^ 0 , x 0 ) where x ^ 0 \hat{\mathbf{x}}_0 x ^ 0 is the predicted version of x 0 \mathbf{x}_0 x 0 obtained from denoising x t \mathbf{x}_t x t . Then, we computed the recovery binary vector r ∈ [ 0 , 1 ] M \mathbf{r} \in[0,1]^M r ∈ [ 0 , 1 ] M by applying the indicator function onto d \mathbf{d} d using the threshold δ d \delta_d δ d . Lastly, we calculated the probability value p = 1 M ∑ i = 1 M r i p = \frac{1}{M} \sum_{i=1}^{M} r_i p = M 1 ∑ i = 1 M r i . If this value p p p is below the probability threshold δ p \delta_p δ p , we stop the search for critical time across all trials.
Algorithm 1: Compute critical time $t_c$ for a pattern
Input: Pattern $\hat{x}$, score model $s_\theta$, DDIM sampler $\Phi$ with $N'$ denoising steps, forward process $\mathcal{F}$, total diffusion time $T$, time stride $s$, number of trials $M$, distance metric $d$, error threshold $\delta_d$, probability threshold $\delta_p$
Output: Critical time $t_c \in \mathbb{N}^M$
1. $x_0 \leftarrow \operatorname{duplicate}(\hat{x}, M)$ // Duplicate the pattern $M$ times
2. $t_c \leftarrow 0$, $\hat{S} \leftarrow 0$ // Critical times and stopped trials
3. **for** $t = 1, 1+s, 1+2s, \ldots, T-s-1$ **do**
4. $\epsilon \sim \mathcal{N}(0,I)$, $x_t \leftarrow \mathcal{F}(x_0,\epsilon,t)$ // Forward process
5. $\hat{x}_0 \leftarrow \Phi(s_\theta,x_t,t,N')$ // DDIM denoising
6. $r_i \leftarrow \mathbb{I}(d(\hat{x}_{0,i},x_{0,i}) \le \delta_d)$ for $i=1,\ldots,M$ // Recovery of each trial
7. $p \leftarrow \frac{1}{M}\sum_{i=1}^{M}r_i$ // Recovery probability
8. **if** $p < \delta_p$ **then return** $t_c$
9. $\hat{S} \leftarrow \operatorname{update}(\hat{S},r)$, $t_c \leftarrow \operatorname{update}(t,t_c,\hat{S})$
10. **return** $t_c$
Experimental Details. For each training data size K K K , we used a maximum of the top 512 samples belonging to each of the sample types: training data, memorized, spurious, and generalized samples. Note, with the exception of the training data points, we sorted samples belonging to each set, identified via our detection metrics, by their distance from least to greatest. We computed the logarithm of the N N N -ball volume in Eq. (57) using the t c t_c t c we computed from Alg. (1) where Γ ( ⋅ ) \Gamma(\cdot) Γ ( ⋅ ) is the Euler’s gamma function [137 ] and N N N is the dimensionality of the image. The radius R ( x ^ , x t c ) R(\hat{x},x_{t_c}) R ( x ^ , x t c ) is the Euclidean norm of the difference between a given image x ^ ∈ R N \hat{x} \in\mathbb{R}^N x ^ ∈ R N and its recoverable perturbation x t c x_{t_c} x t c computed from the forward process. Figure 3.4 shows the average log-volume calculated for each training data size K K K per dataset.
Meanwhile, for Alg. (1), we fixed the stopping probability δ p \delta_p δ p as 0.8, the number of perturbations M M M as 20, the DDIM steps N ′ N' N ′ as 10 and the stride constant s s s as 10 for all datasets. At some training data size K K K , in which there are very few samples in either memorized, spurious or generalized set, we opted to not include the statistics of such a set, partly due to its large variance. We remove the statistics of such a set if the number of its samples is less than 0.1% of its corresponding synthetic set for a training data size K K K .
For CIFAR-10 and LSUN-CHURCH, we utilized the threshold δ d \delta_d δ d as 0.03 and 0.12 respectively. We kept these threshold values similar to the memorized threshold values δ m \delta_m δ m detailed in Table 3.2 , since they have proven to be effective at separating the memorized samples from non-memorized ones in the previous experiment. However, since it is difficult to select an appropriate threshold value for the L 2 L_2 L 2 -distance metric (due to its range being between 0 and ∞ \infty ∞ ), we opted to use LPIPS to experiment with MNIST and FASHION-MNIST using the same threshold δ d = 0.1 \delta_d = 0.1 δ d = 0.1 for both. To find this optimal threshold value, we selected three data sizes, where each belongs to one of the three phases: memorization, spurious, or generalization. We then observed which of the several threshold values, starting from 0.01 to 0.15 with the increment of 0.01, reflects best of the performance given by LPIPS using vgg-16 ([138 ] ) as its backbone. Specifically, we evaluated these thresholds using K ∈ { 4000 , 11724 , 60000 } K \in\{4000, 11724, 60000\} K ∈ { 4000 , 11724 , 60000 } for MNIST, and K ∈ { 4000 , 8965 , 60000 } K \in\{4000, 8965, 60000\} K ∈ { 4000 , 8965 , 60000 } for FASHION-MNIST. We simply performed Alg. (1) for those three data sizes on a small batch of 32 samples for the three sample types, and manually checked whether the recovered samples (using the obtained critical time t c t_c t c to denoise from) are similar to the original images and if this observation is consistent across those three data sizes.
The Curvature of the Energy
Overview. Following Achilli et al. [3 ] and Ventura et al. [157 ] , we utilized their stable version of algorithm for computing the singular values of the Jacobian of the score function, detailed in Alg. (2). The motivations for the algorithm are first detailed in Stanczuk et al. [149 ] and later expanded by Achilli et al. [3 ] and Ventura et al. [157 ] . Here we recite the motivations laid out in Ventura et al. [157 ] .
Consider a generative diffusion model with p 0 ( x ) p_0(\mathbf{x}) p 0 ( x ) defined on a d d d -dimensional manifold M \mathcal{M} M , where M = M 0 \mathcal{M} = \mathcal{M}_0 M = M 0 denotes the manifold at t = 0 t = 0 t = 0 . We can define a time-dependent set of points:
M t = { x ∗ ∣ s ~ M ( x ∗ , t ) = 0 , with J M ( x ∗ , t ) n.s.d. } (83) \mathcal{M}_t = \{\mathbf{x}^{*} \mid\tilde{s}_{\mathcal{M}}(\mathbf{x}^{*},t) = 0,\ \text{with } J_{\mathcal{M}}(\mathbf{x}^{*},t)\ \text{n.s.d.}\} \tag*{(83)} M t = { x ∗ ∣ s ~ M ( x ∗ , t ) = 0 , with J M ( x ∗ , t ) n.s.d. } (83)
which Ventura et al. [157 ] name the stable latent set of the diffusion process. The negative semi-definiteness (n.s.d.) is a stability condition of the Jacobian matrix J M ( x ∗ , t ) J_{\mathcal{M}}(\mathbf{x}^{*},t) J M ( x ∗ , t ) of the support score s ~ M ( x ∗ , t ) \tilde{s}_{\mathcal{M}}(\mathbf{x}^{*},t) s ~ M ( x ∗ , t ) , defined as the score function obtained from the uniform data distribution p ~ 0 ( x ) = 1 ∣ M ∣ δ M ( x ) \tilde{p}_0(\mathbf{x}) = \frac{1}{|\mathcal{M}|}\delta_{\mathcal{M}}(\mathbf{x}) p ~ 0 ( x ) = ∣ M ∣ 1 δ M ( x ) .
Using the relationship s θ ( x , t ) = − ϵ θ ( x , t ) σ t s_{\theta}(\mathbf{x},t) = -\frac{\epsilon_{\theta}(\mathbf{x},t)}{\sigma_t} s θ ( x , t ) = − σ t ϵ θ ( x , t ) , the diffusing particles typically explore shells of a radius that concentrates on σ t \sigma_t σ t . Then, for a small perturbation p \mathbf{p} p around a state x ∗ \mathbf{x}^{*} x ∗ on the latent manifold M t \mathcal{M}_t M t , the score function is well approximated by linearization:
s ( p , t ) ≈ J ( x ∗ , t ) p = ∑ j ( v j ⋅ p ) λ j ( x ∗ , t ) v j (84) s(\mathbf{p},t) \approx J(\mathbf{x}^{*},t)\mathbf{p} = \sum_j (\mathbf{v}_j \cdot\mathbf{p})\lambda_j(\mathbf{x}^{*},t)\mathbf{v}_j \tag*{(84)} s ( p , t ) ≈ J ( x ∗ , t ) p = j ∑ ( v j ⋅ p ) λ j ( x ∗ , t ) v j (84)
where v j \mathbf{v}_j v j and λ j \lambda_j λ j are the respective j j j -th eigenvector and eigenvalue of the negative Jacobian − J ( x ∗ , t ) -J(\mathbf{x}^{*},t) − J ( x ∗ , t ) . Small perturbations, which aligned with the tangent space of M t \mathcal{M}_t M t , correspond to small eigenvalues; while orthogonal perturbations correspond to high eigenvalues, as the score tends to push the stochastic dynamics towards its fixed-points. Hence, based on these relationships, the spectrum of eigenvalues can provide detailed information regarding the local geometry of the stable latent set (83) . Moreover, as already indicated by Stanczuk et al. [149 ] , one can estimate the dimensionality of the manifold from the location of a drop, or a sharp change, in the sorted spectrum of eigenvalues. The full range of the spectra results is shown in Figure 3.14 -Figure 3.17 .
Figure 3.14. Average singular value spectra of the approximated score’s Jacobian for memorized, spurious, and generalized samples from diffusion models trained on the LSUN-CHURCH (Yu et al., 2015) dataset, shown across 38 increasing training data sizes K K K . The plots reveal a clear geometric hierarchy in the intermediate training regime, where memorized samples consistently exhibit the highest curvature (largest singular values), followed by spurious, and finally generalized samples. As the model enters the full generalization phase at large K K K , the average spectra for all three sample types become very distinguishable. Shaded region is the standard deviation of the singular values of different samples of each category.
Figure 3.17. Average singular value spectra of the approximated score’s Jacobian for memorized, spurious, and generalized samples from diffusion models trained on the CIFAR-10 ([96 ] ) dataset, shown across 38 increasing training data sizes K K K . In contrast to the clear separation as seen in other datasets, the spectra for all three sample types remain heavily overlapped throughout the entire transition from memorization to generalization. However, as the model enters the full generalization phase at large K K K , the average spectra for all three sample types become less indistinguishable. Shaded region is the standard deviation of the singular values of different samples of each category.
Experimental Details. Using Alg. (2), we computed the singular values of the Jacobian of the learned score function s θ s_\theta s θ given a small time t 0 t_0 t 0 for all datasets shown in Figure 3.5 . For each sample type, we utilized a maximum of 512 samples and computed the singular values at t 0 = 2 t_0 = 2 t 0 = 2 for all datasets and training data sizes. The singular values are sorted from greatest to least, and the t o p − 5 top-5 t o p − 5 values are ignored to avoid the case of very large singular values skewing the visualizations. Meanwhile, for the spectra results of the training data points shown in the bottom row of Figure 3.5 , we utilized min ( K , 2048 ) \min(K, 2048) min ( K , 2048 ) number of training samples for all datasets and training data sizes. In this visualization, we utilized the rainbow color scheme and plotted the singular values for small training data sizes, starting from the purple color, to larger ones, ending at the red color.
Finally, regarding our experiment with Stable Diffusion ([127 ] ) for Figure 3.7 , following Wen et al. [165 ] and Jeon et al. [80 ] we utilized its version 1.4 from the package Diffusers ([160 ] ). The candidate memorized and spurious prompts we utilized are originally found by Webster [162 ] and Webster et al. [163 ] . Additional examples are shown in Figure 3.18 . Meanwhile, for candidate generalized samples, their prompts are obtained from LAION2B-Aesthetic ([136 ] ). Instead of using Alg. (2), we opted for Alg. (3) and computed the singular values of the Jacobian of the score using t 0 = 5 t_0 = 5 t 0 = 5 , due to the lack of computational resources. Please note that, according to Ventura et al. [157 ] , Alg. (2) produces a much smaller number of extreme singular values than the later algorithm. For generation of the samples, we utilized DDIM ([146 ] ) sampler with different noise vectors initialized from a fixed seed. For the visualizations, we skipped the t o p − 50 top - 50 t o p − 50 singular values and set the limit for the y y y -axis as 1500.
Figure 3.18. Additional examples of candidate memorized, spurious, and generalized samples from Stable Diffusion trained on LAION dataset [136 ] , each corresponding to a distinct curvature signature. The candidate memorized sample has much larger singular values, while the candidate generalized sample has much smaller ones. The selected possible spurious samples have larger singular values than the candidate generalized sample, but much less in contrast to the candidate memorized sample. The common trait between candidate memorized and spurious samples is that both are stable attractors, as demonstrated by their repeated similar generations given different initial points (or noise vectors) and the conditioning on text-prompt. The y-axis is clipped at the value of 1500 to better contrast the shown examples’ spectra. The associated training image for each prompt can be found in Carlini, Hayes, et al. (2023), Webster [162 ] , and Wen et al. [165 ] and on our code repository. For copyright reasons, we omitted the inclusion of original training images in this figure.
Algorithm 2. Compute singular values of the Hessian of the energy using central difference for a pattern
Input: Target sample x 0 ∈ R N x_0 \in\mathbb{R}^N x 0 ∈ R N , time t 0 t_0 t 0 , score model s θ s_\theta s θ , forward process F \mathcal{F} F
Output: Singular values { s i } i = 1 N \{s_i\}_{i=1}^{N} { s i } i = 1 N
M ← Empty ( ) \mathrm{M} \leftarrow\operatorname{Empty}() M ← Empty ( ) // Create an empty matrix
for i = 1 , 2 , … , 4 N i = 1, 2, \ldots, 4N i = 1 , 2 , … , 4 N do
ϵ ∼ N ( 0 , I ) \epsilon\sim\mathcal{N}(0, I) ϵ ∼ N ( 0 , I ) // Sample noise
x + ← F ( x 0 , ϵ , t 0 ) x^{+} \leftarrow\mathcal{F}(x_0, \epsilon, t_0) x + ← F ( x 0 , ϵ , t 0 ) , x − ← F ( x 0 , − ϵ , t 0 ) x^{-} \leftarrow\mathcal{F}(x_0, -\epsilon, t_0) x − ← F ( x 0 , − ϵ , t 0 ) // Paired perturbations
M ( i ) ← 1 2 ( s θ ( x + , t 0 ) − s θ ( x − , t 0 ) ) \mathrm{M}^{(i)} \leftarrow\frac{1}{2}\left(s_\theta(x^{+}, t_0) - s_\theta(x^{-}, t_0)\right) M ( i ) ← 2 1 ( s θ ( x + , t 0 ) − s θ ( x − , t 0 ) ) // Add a column to M
{ s i } i = 1 N ← SVD ( M ) \{s_i\}_{i=1}^{N} \leftarrow\operatorname{SVD}(\mathrm{M}) { s i } i = 1 N ← SVD ( M ) // Singular values
return { s i } i = 1 N \{s_i\}_{i=1}^{N} { s i } i = 1 N
Algorithm 3. Compute singular values of the Hessian of the energy for a pattern
Input: Target sample x 0 ∈ R N x_0 \in\mathbb{R}^N x 0 ∈ R N , time t 0 t_0 t 0 , score model s θ s_\theta s θ , forward process F \mathcal{F} F
Output: Singular values { s i } i = 1 N \{s_i\}_{i=1}^{N} { s i } i = 1 N
M ← Empty ( ) \mathrm{M} \leftarrow\operatorname{Empty}() M ← Empty ( ) // Create an empty matrix
for i = 1 , 2 , … , 4 N i = 1, 2, \ldots, 4N i = 1 , 2 , … , 4 N do
ϵ ∼ N ( 0 , I ) \epsilon\sim\mathcal{N}(0, I) ϵ ∼ N ( 0 , I ) , x + ← F ( x 0 , ϵ , t 0 ) x^{+} \leftarrow\mathcal{F}(x_0, \epsilon, t_0) x + ← F ( x 0 , ϵ , t 0 ) // Perturbation
M ( i ) ← s θ ( x + , t 0 ) \mathrm{M}^{(i)} \leftarrow s_\theta(x^{+}, t_0) M ( i ) ← s θ ( x + , t 0 ) // Add a column to M
{ s i } i = 1 N ← SVD ( M ) \{s_i\}_{i=1}^{N} \leftarrow\operatorname{SVD}(\mathrm{M}) { s i } i = 1 N ← SVD ( M ) // Singular values
return { s i } i = 1 N \{s_i\}_{i=1}^{N} { s i } i = 1 N
Curvature Results. Figure 3.14 –Figure 3.17 show the full curvature spectra for every training data size K K K and dataset.
Additional Examples of Stable Diffusion. Figure 3.18 shows additional candidate memorized, spurious, and generalized samples from Stable Diffusion.
Figure 3.15. Average singular value spectra of the approximated score’s Jacobian for memorized, spurious, and generalized samples from diffusion models trained on the FASHION-MNIST ([167 ] ) dataset, shown across 38 increasing training data sizes K K K . The plots reveal a clear geometric hierarchy in the intermediate training regime, where memorized samples consistently exhibit the highest curvature (largest singular values), followed by spurious, and finally generalized samples. As the model enters the full generalization phase at large K K K , the average spectra for all three sample types become very distinguishable. Shaded region is the standard deviation of the singular values of different samples of each category.
Figure 3.16. Average singular value spectra of the approximated score’s Jacobian for memorized, spurious, and generalized samples from diffusion models trained on the MNIST ([38 ] ) dataset, shown across 38 increasing training data sizes K K K . The plots reveal a clear geometric hierarchy in the intermediate training regime, where memorized samples consistently exhibit the highest curvature (largest singular values), followed by spurious, and finally generalized samples. As the model enters the full generalization phase at large K K K , the average spectra for all three sample types become very distinguishable. Shaded region is the standard deviation of the singular values of different samples of each category.
Relative Energy Gap
Overview. In this section, we provide an additional experiment on the relative energy gap, which measures the gap between the energy depth of training data points and each of the three distinct sample types, using the method for approximating the relative potential from Raya & Ambrogioni [124 ] .
Consider the reverse SDE in Eq. (32) ,
d x t = [ f ( x t , t ) − g ( t ) 2 ∇ x t log p t ( x t ) ] d t + g ( t ) d w ˉ t . (85) \mathrm{d}x_t = \left[f(x_t,t)-g(t)^2\nabla_{x_t}\log p_t(x_t)\right]\mathrm{d}t+g(t)\mathrm{d}\bar{w}_t. \tag*{(85)} d x t = [ f ( x t , t ) − g ( t ) 2 ∇ x t log p t ( x t ) ] d t + g ( t ) d w ˉ t . (85)
We can re-express the above equation with the potential function u ( x , t ) u(x,t) u ( x , t ) :
− ∇ x t u ( x t , t ) = f ( x t , t ) − g ( t ) 2 ∇ x t log p t ( x t ) (86) -\nabla_{x_t}u(x_t,t)=f(x_t,t)-g(t)^2\nabla_{x_t}\log p_t(x_t) \tag*{(86)} − ∇ x t u ( x t , t ) = f ( x t , t ) − g ( t ) 2 ∇ x t log p t ( x t ) (86)
by using the drift term. By moving the minus sign and taking the integration of Eq. (86) with respect to x t x_t x t , we have
u ( x t , t ) = g ( t ) 2 log p t ( x t ) + ∫ x t 0 f ( z , t ) d z , (87) u(x_t,t)=g(t)^2\log p_t(x_t)+\int_{x_t}^{0}f(z,t)\mathrm{d}z, \tag*{(87)} u ( x t , t ) = g ( t ) 2 log p t ( x t ) + ∫ x t 0 f ( z , t ) d z , (87)
which is the potential function u ( x t , t ) u(x_t,t) u ( x t , t ) of the generative process. Substituting this potential function (87) into the reverse SDE, we have the following generative process:
d x t = − ∇ x t u ( x t , t ) d t + g ( t ) d w ˉ t . (88) \mathrm{d}x_t=-\nabla_{x_t}u(x_t,t)\mathrm{d}t+g(t)\mathrm{d}\bar{w}_t. \tag*{(88)} d x t = − ∇ x t u ( x t , t ) d t + g ( t ) d w ˉ t . (88)
For our experimental setting, where we used the DDPM (Ho et al. (2020)) setting, we have the following variance preserving forward SDE:
d x t = − 1 2 β ( t ) x t d t + β ( t ) d w t , (89) \mathrm{d}x_t=-\frac{1}{2}\beta(t)x_t\mathrm{d}t+\sqrt{\beta(t)}\mathrm{d}w_t, \tag*{(89)} d x t = − 2 1 β ( t ) x t d t + β ( t ) d w t , (89)
and the corresponding reverse (or generative) process SDE
d x t = [ − 1 2 β ( t ) x t − β ( t ) ∇ x t log p t ( x t ) ] d t + β ( t ) d w ˉ t . (90) \mathrm{d}x_t=\left[-\frac{1}{2}\beta(t)x_t-\beta(t)\nabla_{x_t}\log p_t(x_t)\right]\mathrm{d}t+\sqrt{\beta(t)}\mathrm{d}\bar{w}_t. \tag*{(90)} d x t = [ − 2 1 β ( t ) x t − β ( t ) ∇ x t log p t ( x t ) ] d t + β ( t ) d w ˉ t . (90)
With Eq. (88) , we have
d x t = − ∇ x t u ( x t , t ) d t + β ( t ) d w ˉ t , (91) \mathrm{d}x_t=-\nabla_{x_t}u(x_t,t)\mathrm{d}t+\sqrt{\beta(t)}\mathrm{d}\bar{w}_t, \tag*{(91)} d x t = − ∇ x t u ( x t , t ) d t + β ( t ) d w ˉ t , (91)
and by using Eq. (86) , the potential for our experimental setting equates to
u ( x t , t ) = g ( t ) 2 log p t ( x t ) + ∫ x t 0 f ( z , t ) d z = β ( t ) log p t ( x t ) + 1 2 β ( t ) ∫ x t 0 z t d z = β ( t ) log p t ( x t ) − 1 4 β ( t ) x t 2 . (92) u(\mathbf{x}_t,t)=g(t)^2\log p_t(\mathbf{x}_t)+\int_{\mathbf{x}_t}^{0}f(\mathbf{z},t)\,\mathrm{d}\mathbf{z}
=\beta(t)\log p_t(\mathbf{x}_t)+\frac{1}{2}\beta(t)\int_{\mathbf{x}_t}^{0}\mathbf{z}_t\,\mathrm{d}\mathbf{z}
=\beta(t)\log p_t(\mathbf{x}_t)-\frac{1}{4}\beta(t)\mathbf{x}_t^2. \tag*{(92)} u ( x t , t ) = g ( t ) 2 log p t ( x t ) + ∫ x t 0 f ( z , t ) d z = β ( t ) log p t ( x t ) + 2 1 β ( t ) ∫ x t 0 z t d z = β ( t ) log p t ( x t ) − 4 1 β ( t ) x t 2 . (92)
Assume we have two images, x 1 ( t ) \mathbf{x}_1(t) x 1 ( t ) and x 2 ( t ) \mathbf{x}_2(t) x 2 ( t ) , where x 1 \mathbf{x}_1 x 1 is a target image and x 2 ( t ) \mathbf{x}_2(t) x 2 ( t ) is a reference image at time t t t . Since we are interested in the energy of unperturbed images, let x 1 = x 1 ( 0 ) \mathbf{x}_1=\mathbf{x}_1(0) x 1 = x 1 ( 0 ) and x 2 = x 2 ( 0 ) \mathbf{x}_2=\mathbf{x}_2(0) x 2 = x 2 ( 0 ) . As discussed in Raya & Ambrogioni [124 ] , the N N N -dimensional potential of a diffusion model can be projected down into 1-dimension via a generative trajectory between x 1 \mathbf{x}_1 x 1 and x 2 \mathbf{x}_2 x 2 . We can obtain such a trajectory via circular interpolation between x 1 \mathbf{x}_1 x 1 and x 2 \mathbf{x}_2 x 2 following
x ~ ( α ) = cos ( α ) x 1 + sin ( α ) x 2 , (93) \widetilde{\mathbf{x}}(\alpha)=\cos(\alpha)\mathbf{x}_1+\sin(\alpha)\mathbf{x}_2, \tag*{(93)} x ( α ) = cos ( α ) x 1 + sin ( α ) x 2 , (93)
and compute the relative potential (up to a constant) as a function of α \alpha α by using
u ~ ( α ) = u ( x ~ ( α ) ) = ∫ 0 π / 2 ∇ u ( x ~ ( α ) ) ⋅ v d α , (94) \widetilde{u}(\alpha)=u(\widetilde{\mathbf{x}}(\alpha))=\int_{0}^{\pi/2}\nabla u(\widetilde{\mathbf{x}}(\alpha))\cdot\mathbf{v}\,\mathrm{d}\alpha, \tag*{(94)} u ( α ) = u ( x ( α )) = ∫ 0 π /2 ∇ u ( x ( α )) ⋅ v d α , (94)
where v = − sin ( α ) x 1 + cos ( α ) x 2 \mathbf{v}=-\sin(\alpha)\mathbf{x}_1+\cos(\alpha)\mathbf{x}_2 v = − sin ( α ) x 1 + cos ( α ) x 2 . See Figure 3.19 for a visualization of this circular interpolation between two samples. For discrete times, we instead estimate the relative energy as
Figure 3.19. Circular interpolation of a target image x 1 x_1 x 1 and a reference image x 2 x_2 x 2 over α ∈ { 0 , … , π 2 } \alpha\in\{0,\ldots,\frac{\pi}{2}\} α ∈ { 0 , … , 2 π } for different datasets.
u ~ ( α ‾ L ) ≈ ∑ i = 1 L ∇ u ( x ~ ( α ‾ i ) ) ⋅ v Δ α (95) \widetilde{u}(\overline{\alpha}_L)\approx\sum_{i=1}^{L}\nabla u(\widetilde{\mathbf{x}}(\overline{\alpha}_i))\cdot\mathbf{v}\Delta\alpha \tag*{(95)} u ( α L ) ≈ i = 1 ∑ L ∇ u ( x ( α i )) ⋅ v Δ α (95)
given that α ‾ = { 0 , … , π 2 } \overline{\alpha}=\{0,\ldots,\frac{\pi}{2}\} α = { 0 , … , 2 π } and the potential u ( ⋅ ) u(\cdot) u ( ⋅ ) is obtained from the above Eq. (92) .
Experimental Details. In our experimentation, we utilized a maximum of the top 512 samples for each of three sample types, memorized, spurious, and generalized, to compute the relative energy following Eq. (95) , at each training data size K K K . For training data points, we instead utilized min ( K , 2048 ) \min(K,2048) min ( K , 2048 ) number of samples. Note, with the exception of the training data set, the samples in the three sets are sorted from least to greatest, based on their distance corresponding to their respective detection metric (§ 4.3 ). We computed the relative energy of each set following Alg. (4), which is strictly following the formulations detailed above. Note, we randomly selected and utilized an image from the entire training set as part of the relative energy calculation.
To define the average relative energy gap, let u ~ t a r g e t ∈ R M \tilde{u}_{\mathrm{target}} \in\mathbb{R}^{M} u ~ target ∈ R M be a set of M M M relative potentials computed from using either a memorized, spurious, or generalized set and following Eq. (95) . Please note that M M M is capped at 512 for the three sample types. Meanwhile, let u ~ d a t a ∈ R M ′ \tilde{u}_{\mathrm{data}} \in\mathbb{R}^{M'} u ~ data ∈ R M ′ be the set of relative potentials computed from the training dataset at size K K K where M ′ = min ( K , 2048 ) M' = \min(K, 2048) M ′ = min ( K , 2048 ) . The average relative energy gap is defined as
Δ ( u ~ t a r g e t , u ~ d a t a ) = 1 M ∑ i = 1 M ( u ~ t a r g e t ) i − 1 M ′ ∑ j = 1 M ′ ( u ~ d a t a ) j = μ ( u ~ t a r g e t ) − μ ( u ~ d a t a ) (96) \Delta(\tilde{u}_{\mathrm{target}}, \tilde{u}_{\mathrm{data}}) = \frac{1}{M}\sum_{i=1}^{M}(\tilde{u}_{\mathrm{target}})_i - \frac{1}{M'}\sum_{j=1}^{M'}(\tilde{u}_{\mathrm{data}})_j = \mu(\tilde{u}_{\mathrm{target}}) - \mu(\tilde{u}_{\mathrm{data}}) \tag*{(96)} Δ ( u ~ target , u ~ data ) = M 1 i = 1 ∑ M ( u ~ target ) i − M ′ 1 j = 1 ∑ M ′ ( u ~ data ) j = μ ( u ~ target ) − μ ( u ~ data ) (96)
Using Eq. (96) , we computed the average relative energy gap and recorded our results in Figure 3.20 . The shaded regions reported in this figure represent the standard deviations computed from using u ~ t a r g e t \tilde{u}_{\mathrm{target}} u ~ target , and the average relative energy gap as the mean value. Since at some training data size K K K , there might be very few samples in one of the three sets, we opted not to include the relative energy gap of such sets, partly due to their large variance. Similar to the basin of attraction experiment, we determine whether a set is too small if the number of its samples is less than 0.1 % 0.1\% 0.1% of its corresponding synthetic set. Finally, for our interpolation values α ˉ = { 0 , … , π 2 } \bar{\alpha} = \left\{0, \ldots, \frac{\pi}{2}\right\} α ˉ = { 0 , … , 2 π } used for Eq. (95) , we generate 20 points starting from 0 to π 2 \frac{\pi}{2} 2 π using linear spacing.
Figure 3.20. Average energy gap of each sample type and the training samples for the four datasets as the training data size K K K grows, computed using Eq. (95) . Gaps are measured relative to training samples, whose energy is set to zero since there is no gap to itself. A maximum of 512 samples per type is used at each K K K , or the full set is used instead if there are fewer than 512 points. Shaded regions show standard deviation of the gap values. With the exception of LSUN-CHURCH, the relative energy of the memorized samples matches that of the training data samples at K = 2 K = 2 K = 2 , but quickly diverges as K K K increases. Similarly, spurious samples’ relative potential resembles that of the training data samples during the intermediate phase of the memorization-generalization phase. However, the potential quickly diverges as the later stages of generalization are initiated and consequently, the gap between generalized and training data samples’ relative energy significantly decreases.
Discussion. The results for the relative energy gap across the memorization-generalization transition for all datasets are shown in Figure 3.20 . As the training data size K K K increases, the gap for memorized samples is initially close to zero and quickly diverges. Spurious samples’ relative potential resembles that of the training data samples during the intermediate phase of the memorization-generalization phase, where their potential is the lowest among the three sample types. However, the potential of spurious states quickly diverges as the later stages of generalization are initiated, and consequently, the gap between generalized and training data samples’ relative energies became the most narrowed among the three distinct sample types – further emphasizing the changing in the energy landscape as the DM undergoes its transition from memorization to generalization as K K K increases.
Algorithm 4: Compute the discretized relative energy between a target and a reference sample
Input: Target pattern x 1 ∈ R N x_1 \in\mathbb{R}^{N} x 1 ∈ R N and reference pattern x 2 ∈ R N x_2 \in\mathbb{R}^{N} x 2 ∈ R N (both samples at t = 0 t = 0 t = 0 ), score model s θ s_\theta s θ , interpolation values α ˉ \bar{\alpha} α ˉ , initial variance β 0 \beta_0 β 0
Output: Relative energy u ~ ( α ˉ L ) \widetilde{u}(\bar{\alpha}_L) u ( α ˉ L )
α ˉ ← { 0 , … , π 2 } \bar{\alpha} \leftarrow\{0,\ldots,\frac{\pi}{2}\} α ˉ ← { 0 , … , 2 π } // Linear spacing from 0 to π \pi π
Δ α ← α ˉ 1 − α ˉ 0 \Delta\alpha\leftarrow\bar{\alpha}_1-\bar{\alpha}_0 Δ α ← α ˉ 1 − α ˉ 0 , u ~ ( α ˉ L ) ← 0 \widetilde{u}(\bar{\alpha}_L) \leftarrow0 u ( α ˉ L ) ← 0
for α ∈ α ˉ \alpha\in\bar{\alpha} α ∈ α ˉ do
x ~ ← cos ( α ) x 1 + sin ( α ) x 2 \widetilde{x} \leftarrow\cos(\alpha)x_1+\sin(\alpha)x_2 x ← cos ( α ) x 1 + sin ( α ) x 2 , v ← − sin ( α ) x 1 + cos ( α ) x 2 \mathbf{v} \leftarrow-\sin(\alpha)x_1+\cos(\alpha)x_2 v ← − sin ( α ) x 1 + cos ( α ) x 2 // Interpolate
∇ x ~ log p 0 ( x ~ ) ← − s θ ( x ~ , 0 ) / β 0 \nabla_{\widetilde{x}}\log p_0(\widetilde{x}) \leftarrow-s_\theta(\widetilde{x},0)/\sqrt{\beta_0} ∇ x log p 0 ( x ) ← − s θ ( x , 0 ) / β 0
g ← ( − 1 2 β 0 x ~ − β 0 ∇ x ~ log p 0 ( x ~ ) ) ⊙ v Δ α \mathbf{g} \leftarrow\left(-\frac{1}{2}\beta_0\widetilde{x}-\beta_0\nabla_{\widetilde{x}}\log p_0(\widetilde{x})\right)\odot\mathbf{v}\,\Delta\alpha g ← ( − 2 1 β 0 x − β 0 ∇ x log p 0 ( x ) ) ⊙ v Δ α // Eq. (90)
u ~ ( α ˉ L ) ← u ~ ( α ˉ L ) + ∑ j = 1 N g j \widetilde{u}(\bar{\alpha}_L) \leftarrow\widetilde{u}(\bar{\alpha}_L)+\sum_{j=1}^{N}g_j u ( α ˉ L ) ← u ( α ˉ L ) + ∑ j = 1 N g j // Eq. (95)
return u ~ ( α ˉ L ) \widetilde{u}(\bar{\alpha}_L) u ( α ˉ L )
Average Relative Energy Gap Results. Figure 3.20 reports the average relative energy gap of each sample type across the memorization-to-generalization transition.
Hardware Details
The training of the models detailed in Table 3.3 was done using NVIDIA Tesla V100 GPUs, where a single GPU was used to train each model. Each GPU has 32GB of memory and is linked with Power9 processors, clocking at 3.15 GHz maximum. Each CIFAR-10 model took roughly 18, 20, and 22 hours to train for different initial latent dimensions, e.g., 64, 96, 128, respectively. Meanwhile, each LSUN-CHURCH model requires roughly 48, 56, and 103 hours of training with respect to the model’s initial latent dimension. In contrast, FASHION-MNIST and MNIST models require approximately 17 hours to be fully trained (per model). Please note that these durations are with respect to the required training iterations for each model and their corresponding dataset detailed in Table 3.3 . Also, note that we utilized the same hardware for our analyses.
Coexistence of Memorization and Generalizationin Language Diffusion Models
Introduction
Generative diffusion models ([140 ] ) have set new standards for image and video generation ([143 , 147 , 127 ] (Ho et al. 2020)). Yet, alongside their remarkable generative power, these models exhibit a well-documented tendency to reproduce their training data ((Somepalli et al., 2023a,b; Carlini, Hayes, et al., 2023; Webster, 2023)). Although recent studies have addressed the interplay between memorization and generalization in diffusion models (DMs), they predominantly focus on the continuous image domain ([168 , 84 , 18 , 86 , 3 , 165 , 80 , 2 ] (Pham, Raya, et al. 2026)). Their mechanics in the discrete domain, particularly for language modeling, remain poorly investigated.3
A particularly compelling instance of these questions arises in the context of large language models. For instance, Brown et al. [22 ] and Kojima et al. [93 ] have found that these models are capable of few-shot and even zero-shot capabilities, referring to the model’s ability to perform novel tasks with minimal or even no task-specific examples, or alternatively the possibility of retrieving appropriate responses never encountered during training. The reasons behind the emergence of these capabilities remain unclear, and the push for models capable of both factual recall and creative behaviors makes it difficult to define and assess what generalization means in this regime.
Motivated by these phenomena, this chapter studies Uniform-based Discrete Diffusion Models (UDDMs) ([14 , 25 , 55 , 131 ] ) through the theoretical lens of Associative Memories (AMs) ([100 ] ). Fundamentally, a generative system functions as an AM by reliably retrieving stored data points, by producing distinct basins around them ([75 , 53 ] ). Historically, attempting to overload these systems with too many data points leads to a catastrophic memory blackout , where all meaningful
Portions of this chapter have previously appeared as: Pham, B., Zaki, M. J., Ambrogioni, L., Krotov, D., & Negri, M. (2026). Language diffusion models are associative memories capable of retrieving unseen data. In H.-Y. Lee, S. Dev, J. J. Li, & D. Elliott (Eds.), Proceedings of the 2026 conference on empirical methods in natural language processing (pp. 19377–19404). Association for Computational Linguistics. https://doi.org/10.18653/v1/2026.emnlp-main.835 attractors are destroyed (Amit et al. [11 ] ). However, Kalaj et al. [85 ] has recently revealed a counterintuitive regime: overloading an AM can instead trigger a generalization phase where new attractors spontaneously form near unseen examples from the underlying data distribution, while the memorization of the training data points persists. The desired capability of language modeling of having both factual recall and creative behaviors resembles the co-existence of memory attractors and novel attractors in AMs. For this reason, it is useful to describe the generalization phase of UDDMs from the perspective of AMs, by focusing on the retrieval of seen and unseen data points. Notably, the co-existence of these two seemingly contradicting capabilities has been studied in an analytically tractable teacher-student setting (Farné et al. [49 ] ).
Typically, AMs are characterized with an explicit and well-defined energy function, as seen in Hopfield networks [75 , 8 ] and Dense Associative Memories [101 , 104 ] . However, this reliance on an energy function is not strictly necessary to guarantee attractor dynamics. As shown by D’Amico, Bocchi, et al. [34 ] , conditional likelihood maximization alone produces basins around the data points. Importantly, dropping the energy requirement is conceptually essential for extending the AM framework to deep feed-forward architectures. There is no reason to expect that a generic feed-forward network can be written as an energy-based model, since this interpretation restricts the class of admissible architectures due to its constraints on the symmetry of the network’s weights [98 , 95 ] (Hoover, Liang, et al. 2023). On the contrary, the conditional likelihood structure already exists in many widely used architectures (such as the Transformer [156 ] ), making it a natural connection with AMs.
Contributions. Leveraging conditional likelihood dynamics, this chapter establishes a connection between UDDMs and AMs by showing that attractor basins can be formed through conditional likelihood maximization alone (via pseudo-likelihood [17 ] ) and provide a benefit for AM. Specifically, in a simplified setting detailed in § 5.3 , we establish that maximizing conditional likelihood implicitly enforces Hebbian learning [65 ] on data points while maximizing their classification margins, providing a formal bridge between AM and generative models (like UDDMs) which rely on conditional likelihood. Moreover, unlike previous works which connect continuous DMs and AMs (Hoover, Strobel, et al. (2023); Ambrogioni [9 ] ; Pham, Raya, et al. (2026)), we extend their results to the discrete setting of language modeling.
This theoretical link of conditional likelihood maximization and AM allows us to interpret UDDMs as AM systems and reveals a sharp memorization-to-generalization transition governed by the training dataset size. As the training set gets bigger, basins around training examples shrink while (partial) basins around unseen test examples expand, eventually converging to a regime where novel samples become stable attractors (see Figure 4.1 and Figure 4.2 ). During memorization, the UDDM fails to recognize tokens of unseen test sequences as stable points, frequently altering them during the reverse process. Once generalized, however, the model is likely to maintain these tokens, preserving them if unperturbed and successfully recovering them from partially corrupted sequences via the reverse process (see Figure 4.1 A) and (4.4A) for visual examples of test and training points’ token recovery).
Figure 4.1. Basins around training examples shrink and basins around test examples expand as the training dataset size increases. (A) Textual examples showing two Tiny (∼ 24 M \sim24\mathrm{M} ∼ 24 M ) UDDMs’ token recovery at noise level t = 0.2 t = 0.2 t = 0.2 , where each is trained on two different training dataset sizes. With a small training dataset, the model fails to recognize unseen test sequences and alters all tokens. With a larger training set, the tokens of unseen sequences, however, become stable and recoverable by the sampling process. (B) Average total token recovery rates (%), including both non-corrupt and corrupted tokens, for training (left) and test (right) sequences across varying corruption levels. Line colors indicate the fractions of the training dataset used (ranging from small to large). As data scales, the model’s ability to flawlessly recover training examples drops (indicating shrinking basins), while its recovery rate of unseen test examples improves (indicating expanding basins). The convergence of these rates at large training set sizes (red curves) marks the transition from memorization to generalization. Deterministic (greedy) sampling was used across these experiments to isolate from stochastic noise.
Figure 4.2. The convergence of corrupted training and test token recovery rates marks the phase transition from memorization to generalization. The plots display the average token recovery rate (%) as the fraction of the training dataset grows, comparing the model’s ability to denoise perturbed tokens (using stochastic sampling) from the training set (solid lines) against unseen test sequences (dashed lines) across various perturbation levels based on time t t t on the LM1B dataset [29 ] for the Tiny (∼ 24 M \sim24\mathrm{M} ∼ 24 M , left), Small (∼ 135 M \sim135\mathrm{M} ∼ 135 M , middle), and Medium (∼ 384 M \sim384\mathrm{M} ∼ 384 M , right) models. In the limited-data regime, the model exhibits memorization, perfectly recovering training samples while failing on test data. As the dataset expands, the recovery rates for training and test sequences converge to an identical recovery rate, demonstrating that unseen samples have become stable attractors. Notably, the model’s size dictates the timing of this shift, where the Medium model requires a significantly larger fraction of data to trigger the transition, effectively prolonging the memorization phase.
Empirically, we detect this transition using token recovery rates and conditional entropy as complementary probes for token stability and the memorization-to-generalization transition. Crucially, token-level conditional entropy distinguishes between different token recovery behaviors, with successfully recovered tokens exhibiting near-zero entropy (see Fig. (4.4)). Meanwhile, sequence-level conditional entropy serves as a practical metric for detecting generalization, as the entropy distributions of training and synthetic sequences align perfectly once the transition is reached (see Figure 4.5 ). Notably, conditional entropy has also been found to be crucial for scaling laws in autoregressive language models (Cagnetta et al. [24 ] ), suggesting the versatility and usefulness of this metric in language modeling.
Figure 4.5. Sequence conditional entropy highlights the memorization to generalization transition. The histograms compare the sequence entropy distributions of training and synthetic (or generated) sequences respectively, for three selected fractions of the training set for the Medium UDDMs. At a very low fraction of the training set, the conditional entropy of training sequences is near zero, aligning very well alongside the conditional entropy of many generated sequences, indicating the regime of memorization. However, as the fraction of the training set reaches the total, the synthetic and training distributions of the sequence conditional entropy converge, signifying generalization. See § 5.7.5 for the full range of histograms across various model sizes.
Finally, we validate our proposed metrics via the typical measurement of perplexity using an external critic model as commonly done in language modeling (Radford et al. [122 ] ). We observe a strong alignment between these metrics, not just in the detection of memorization-to-generalization transition point, but also in the estimation of sample quality (see Figure 4.3 ). The success of this validation indicates that our metrics are effective for assessing the generative capabilities of UDDMs, while also providing a principled geometric interpretation of such capabilities.
Figure 4.3. Perplexity trends during the memorization-to-generalization transition. Evaluation of the Tiny (left), Small (middle), and Medium (right) UDDMs as the fraction of the training set increases. The vertical dashed lines roughly illustrate the transition point where the model switches from memorization to generalization. Perplexity starts at a very low value during the memorization regime, increases as the training dataset size grows, and it then decreases to a lower value upon reaching generalization. The horizontal dashed lines highlight the converging perplexity value, showing that scaling up the model leads to improved perplexity at the end of this transition. The precise position of each vertical line is the last point where the recovery rate is 100% for training tokens in Figure 4.2 . Perplexity is computed using GPT-2 Large ([122 ] ) as the critic model.
The remainder of this chapter is organized as follows. Section (98) recalls the uniform-state discrete diffusion models we study. Section (99) establishes the connection between conditional likelihood maximization and AMs in a simplified setting. Section (100) describes our three experiments and the two metrics, token recovery rate and conditional entropy, used to probe the memorization-to-generalization transition. Section (101) presents our results, and Section (102) concludes with a discussion of limitations. The experimental details and additional results are collected in Section (103) .
Uniform-State Discrete Diffusion
We study the uniform-state discrete diffusion models (UDDMs) reviewed in Section (2.3.5), specifically the formulation of Sahoo et al. [132 ] . A clean token x ∈ V x \in\mathcal{V} x ∈ V is corrupted by the forward process in Eq. (35) with the uniform prior π = 1 / V \boldsymbol{\pi} = 1/V π = 1/ V over a vocabulary of size V V V , and the reverse process replaces the unknown clean token in the closed-form posterior of Eq. (36) with the prediction of a network, p θ ( x ∣ z t ) = x θ ( z t , t ) p_\theta(x \mid z_t) = x_\theta(z_t,t) p θ ( x ∣ z t ) = x θ ( z t , t ) , as in Eq. (37) . The parameters are trained with the NELBO objective in Eq. (38) .
By framing the network’s prediction as a categorical probability distribution, the cross-entropy terms within L N E L B O \mathcal{L}_{\mathrm{NELBO}} L NELBO naturally enforce a finite classification margin and therefore store training data points. As we will explore next, this reliance on cross-entropy provides a mathematical link between discrete diffusion dynamics and AM systems. Please see Section (4.7.2) for more details on this form of UDDMs, the reverse process (37) , and the NELBO (38) .
Associative Memories from Conditional Sampling
To establish a connection between AMs and UDDMs, we rely on a specific aspect that emerges from modeling sequences of discrete variables in DMs: the core assumption is that the denoising process of a sequence z 1 : L z^{1:L} z 1 : L of length L L L factorizes for each token z ℓ z^\ell z ℓ as
p s ∣ t θ ( z s 1 : L ∣ z t 1 : L ) = ∏ ℓ = 1 L ψ s ∣ t θ ( z s ℓ ∣ z t 1 : L ) , (97) p^\theta_{s|t}\left(z_s^{1:L} \mid z_t^{1:L}\right) = \prod_{\ell=1}^{L} \psi^\theta_{s|t}\left(z_s^\ell\mid z_t^{1:L}\right), \tag*{(97)} p s ∣ t θ ( z s 1 : L ∣ z t 1 : L ) = ℓ = 1 ∏ L ψ s ∣ t θ ( z s ℓ ∣ z t 1 : L ) , (97)
where ψ s ∣ t θ \psi^\theta_{s|t} ψ s ∣ t θ denotes the conditional probability:
ψ s ∣ t θ ( z s ℓ ∣ z t 1 : L ) = Cat ( z s ℓ ; f θ ℓ ( z t 1 : L ) ) . (98) \psi^\theta_{s|t}\left(z_s^\ell\mid z_t^{1:L}\right) = \operatorname{Cat}\left(z_s^\ell; f^\ell_\theta\left(z_t^{1:L}\right)\right). \tag*{(98)} ψ s ∣ t θ ( z s ℓ ∣ z t 1 : L ) = Cat ( z s ℓ ; f θ ℓ ( z t 1 : L ) ) . (98)
Here, f θ ℓ ( z t 1 : L ) = softmax V [ β ( t ) u θ ℓ ( z t 1 : L ) ] f^\ell_\theta\left(z_t^{1:L}\right) = \operatorname{softmax}_{V}\left[\beta(t)u^\ell_\theta\left(z_t^{1:L}\right)\right] f θ ℓ ( z t 1 : L ) = softmax V [ β ( t ) u θ ℓ ( z t 1 : L ) ] , where u θ ℓ ( z t 1 : L ) u^\ell_\theta\left(z_t^{1:L}\right) u θ ℓ ( z t 1 : L ) maps the sequence z t 1 : L z_t^{1:L} z t 1 : L to raw logits via a diffusion transformer (Peebles & Xie, [119 ] ), and the softmax is applied over the V V V categories per position ℓ \ell ℓ . The inverse temperature β ( t ) \beta(t) β ( t ) depends on the diffusion schedule α ( t ) \alpha(t) α ( t ) and typically increases as t → 0 t \to0 t → 0 . These conditional probabilities enter the cross-entropy terms in NELBO (38) . This reliance on cross-entropy establishes the connection to AMs, where minimizing this loss implicitly creates basins of attraction around data points during conditional sampling (D’Amico, Bocchi, et al., 2026), and translates with minimal changes to UDDMs.
Simpler Setting: Binary Variables and Linear Logits
Consider an AM of L L L binary neurons s ℓ ∈ { ± 1 } \mathbf{s}^{\ell} \in\{\pm1\} s ℓ ∈ { ± 1 } with a non-symmetric coupling matrix W ∈ R L × L \mathbf{W} \in\mathbb{R}^{L \times L} W ∈ R L × L , where its diagonal entries are zero , we have the following deterministic update rule:
s τ ℓ = sgn ( ∑ m = 1 L W ℓ m s τ + 1 m ) (99) s^\ell_\tau= \operatorname{sgn}\left(\sum_{m=1}^{L} W^{\ell m}s^m_{\tau+1}\right) \tag*{(99)} s τ ℓ = sgn ( m = 1 ∑ L W ℓ m s τ + 1 m ) (99)
where we adopted the notation of the discrete time τ \tau τ running backwards to highlight the connection with the backward dynamics of DMs. Consider also a set of P P P examples Ξ ∈ { ± 1 } P × L \mathbf{\Xi} \in\{\pm1\}^{P \times L} Ξ ∈ { ± 1 } P × L , where x 1 : L ∈ Ξ \mathbf{x}^{1:L} \in\mathbf{\Xi} x 1 : L ∈ Ξ is a binary vector of length L L L .
To build an AM, it is not sufficient to find an optimal coupling matrix W ∗ \mathbf{W}^{*} W ∗ such that ∀ x 1 : L ∈ Ξ \forall\mathbf{x}^{1:L} \in\mathbf{\Xi} ∀ x 1 : L ∈ Ξ is a fixed point of Eq. (99) , because it would not guarantee finite basins of attraction around the examples. To create such basins, a stronger condition is instead needed:
x ℓ = sgn ( ∑ m = 1 L W ℓ m x m + κ ) , ∀ ℓ = 1 , … , L (100) x^\ell= \operatorname{sgn}\left(\sum_{m=1}^{L} W^{\ell m}x^m + \kappa\right), \quad\forall\ell= 1,\ldots,L \tag*{(100)} x ℓ = sgn ( m = 1 ∑ L W ℓ m x m + κ ) , ∀ ℓ = 1 , … , L (100)
where the classification margin κ ∈ R + \kappa\in\mathbb{R}^{+} κ ∈ R + ensures that each fixed point is robust to a finite amount of variable flips from the deterministic update rule [53 , 54 , 52 , 16 ] . Larger κ \kappa κ implies larger basins. Given the load γ = P / L \gamma= P/L γ = P / L , there exists a maximum margin κ max ( γ ) \kappa_{\max}(\gamma) κ m a x ( γ ) . As shown by Soudry et al. [148 ] and Montanari et al. [114 ] , training a Perceptron with the cross-entropy loss in the separable regime implicitly solves Eq. (100) with κ = κ max ( γ ) \kappa= \kappa_{\max}(\gamma) κ = κ m a x ( γ ) , suggesting how to produce large basins of attraction around the training examples.
Conditional sampling. To connect the cross-entropy loss with conditional sampling, it is useful to interpret this deterministic update (99) as:
s τ ℓ = arg max s ℓ ψ τ ∣ τ + 1 ( s τ ℓ ∣ s τ + 1 1 : L ; W ℓ ) (101) s^\ell_\tau= \underset{s^\ell}{\arg\max}\ \psi_{\tau|\tau+1}\left(s^\ell_\tau\mid s^{1:L}_{\tau+1}; \mathbf{W}^{\ell}\right) \tag*{(101)} s τ ℓ = s ℓ arg max ψ τ ∣ τ + 1 ( s τ ℓ ∣ s τ + 1 1 : L ; W ℓ ) (101)
where we select the most probable state under the conditional distribution (between position ℓ \ell ℓ and its neighborhood or 1 … L 1\ldots L 1 … L positions in the binary vector excluding ℓ \ell ℓ .4
ψ τ ∣ τ + 1 ( s τ ℓ ∣ s τ + 1 1 : L ; W ℓ ) = exp ( s τ ℓ f W ℓ ( s τ + 1 1 : L ) ) 2 cosh ( f W ℓ ( s τ + 1 1 : L ) ) (102) \psi_{\tau|\tau+1}(s_\tau^\ell\mid s_{\tau+1}^{1:L};\mathbf{W}^\ell)=\frac{\exp\left(s_\tau^\ell f_{\mathbf{W}}^\ell(s_{\tau+1}^{1:L})\right)}{2\cosh\left(f_{\mathbf{W}}^\ell(s_{\tau+1}^{1:L})\right)} \tag*{(102)} ψ τ ∣ τ + 1 ( s τ ℓ ∣ s τ + 1 1 : L ; W ℓ ) = 2 cosh ( f W ℓ ( s τ + 1 1 : L ) ) exp ( s τ ℓ f W ℓ ( s τ + 1 1 : L ) ) (102)
where f W ℓ ( s τ + 1 1 : L ) = β ∑ m = 1 L W ℓ m s τ + 1 m f_{\mathbf{W}}^\ell(s_{\tau+1}^{1:L})=\beta\sum_{m=1}^{L}\mathbf{W}^{\ell m}s_{\tau+1}^{m} f W ℓ ( s τ + 1 1 : L ) = β ∑ m = 1 L W ℓ m s τ + 1 m with a fixed inverse temperature β \beta β .5 For binary variables, Eq. (102) yields a logistic form. However, for generic categorical variables, f ℓ ( s 1 : L ) f_\ell(s^{1:L}) f ℓ ( s 1 : L ) are logits inside softmax( ⋅ ) (\cdot) ( ⋅ ) like that of Eq. (98) .
Conditional-likelihood maximizes classification margins. Eq. (102) suggests a way to train the model: by minimizing the following loss function, the negative logarithm of the conditional-likelihood that is also called pseudo-likelihood ([17 ] ):
L ( W ) = − 1 P ∑ x ∈ Ξ log ∏ ℓ = 1 L ψ ( x ℓ ∣ x 1 : L ; W ℓ ) = − 1 P ∑ x ∈ Ξ ∑ ℓ = 1 L [ x ℓ f W ℓ ( x 1 : L ) − log 2 cosh ( f W ℓ ( x 1 : L ) ) ] (103) \begin{aligned}
\mathcal{L}(\mathbf{W})=-\frac{1}{P}\sum_{\mathbf{x}\in\Xi}\log\prod_{\ell=1}^{L}\psi(x^\ell\mid\mathbf{x}^{1:L};\mathbf{W}^\ell) \\
&=-\frac{1}{P}\sum_{\mathbf{x}\in\Xi}\sum_{\ell=1}^{L}\left[x^\ell f_{\mathbf{W}}^\ell(\mathbf{x}^{1:L})-\log2\cosh\left(f_{\mathbf{W}}^\ell(\mathbf{x}^{1:L})\right)\right] \tag*{(103)}
\end{aligned} L ( W ) = − P 1 x ∈ Ξ ∑ log ℓ = 1 ∏ L ψ ( x ℓ ∣ x 1 : L ; W ℓ ) = − P 1 x ∈ Ξ ∑ ℓ = 1 ∑ L [ x ℓ f W ℓ ( x 1 : L ) − log 2 cosh ( f W ℓ ( x 1 : L ) ) ] (103)
It has been shown by D’Amico, Bocchi, et al. [34 ] that the above objective (103) produces basins of attraction around the training data points in the dynamics of the conditional sampling. Unlike classical AM, the couplings W \mathbf{W} W induced by conditional likelihood do not need to be symmetric, and therefore no explicit global energy function is required . The existence of attractor-like behavior follows directly from the structure of the conditional probabilities.
To have an intuition on why the loss (103) promotes classification margins, we can derive it with respect to the coupling matrix W \mathbf{W} W :
d L ( W ) d W ℓ m ∝ − 1 P ∑ x ∈ Ξ x ℓ x m ⏟ Hebbian [ 1 − tanh ( M ℓ ( x 1 : L ) ) ] ⏟ Penalty (104) \frac{\mathrm{d}\mathcal{L}(\mathbf{W})}{\mathrm{d}\mathbf{W}^{\ell m}}\propto-\frac{1}{P}\sum_{\mathbf{x}\in\Xi}\underbrace{x^\ell x^m}_{\text{Hebbian}}\underbrace{\left[1-\tanh\left(M^\ell(\mathbf{x}^{1:L})\right)\right]}_{\text{Penalty}} \tag*{(104)} d W ℓ m d L ( W ) ∝ − P 1 x ∈ Ξ ∑ Hebbian x ℓ x m Penalty [ 1 − tanh ( M ℓ ( x 1 : L ) ) ] (104)
Here, we denote the local classification margin as M ℓ ( x 1 : L ) = x ℓ f W ℓ ( x 1 : L ) M^\ell(\mathbf{x}^{1:L})=x^\ell f_{\mathbf{W}}^\ell(\mathbf{x}^{1:L}) M ℓ ( x 1 : L ) = x ℓ f W ℓ ( x 1 : L ) . The Hebbian term is factored out via identity tanh ( f W ℓ ( x 1 : L ) ) = tanh ( x ℓ M ℓ ( x 1 : L ) ) = x ℓ tanh ( M ℓ ( x 1 : L ) ) \tanh(f_{\mathbf{W}}^\ell(\mathbf{x}^{1:L}))=\tanh(x^\ell M^\ell(\mathbf{x}^{1:L}))=x^\ell\tanh(M^\ell(\mathbf{x}^{1:L})) tanh ( f W ℓ ( x 1 : L )) = tanh ( x ℓ M ℓ ( x 1 : L )) = x ℓ tanh ( M ℓ ( x 1 : L )) , given x ℓ x ℓ = 1 x^\ell x^\ell=1 x ℓ x ℓ = 1 . This yields two distinct gradient terms: a classical Hebbian learning ([65 ] ) component for pattern storage and a margin-modifying component. Because the gradient penalty 1 − tanh ( M ℓ ( x 1 : L ) ) ≈ 2 e − 2 M ℓ ( x 1 : L ) 1-\tanh(M^\ell(\mathbf{x}^{1:L})) \approx2e^{-2M^\ell(\mathbf{x}^{1:L})} 1 − tanh ( M ℓ ( x 1 : L )) ≈ 2 e − 2 M ℓ ( x 1 : L ) decays exponentially for correctly classified patterns with wide margins, the objective concentrates learning on samples with the smallest margins. The loss is thus minimized when all margins are maximized, driving weight magnitudes to diverge in the separable regime (Soudry et al. [148 ] ).
Furthermore, we verify numerically that the optimization of loss (103) leads to basins around training examples in § 5.7.4 . Specifically, we confirm the results of Soudry et al. [148 ] by reporting the lower bound computed from the idealized κ max ( γ ) \kappa_{\max}(\gamma) κ m a x ( γ ) and the one computed from the empirically achieved κ a c h i e v e d ( γ ) \kappa_{\mathrm{achieved}}(\gamma) κ achieved ( γ ) in Figure 4.6 . Notably, the shrinking of basins demonstrated in Figure 4.2 for UDDMs is also exhibited within the simple model trained using pseudo-likelihood (103) , supporting that the fundamental AM properties in UDDMs do not depend on the NELBO objective but on the underlying conditional-likelihood structure.
Figure 4.6. The implicit maximization of the margin guarantees large basins of attraction. Both panels refer to an associative memory model trained with conditional likelihood on random bit sequences. Average total bit recovery rates for training sequences across varying corruption levels are shown in the left panel. Line colors indicate the sizes of the training datasets used. This panel captures the same qualitative memorization phenomenon of Figure 4.1 . The right panel shows the basin size ρ c ( γ ) \rho_c(\gamma) ρ c ( γ ) of the trained model (red curve) compared to the margin-derived lower bound, evaluated both at the idealized κ max ( γ ) \kappa_{\max}(\gamma) κ m a x ( γ ) and at the empirically achieved κ a c h i e v e d ( γ ) \kappa_{\mathrm{achieved}}(\gamma) κ achieved ( γ ) (blue and green curves, respectively). The measured basin size remains above the achieved-margin bound at every load, confirming margin maximization is sufficient to produce basins of the predicted size. The red points correspond to the critical noise level for which the token recovery rate drops below 0.99. Each point is the average of five samples, and the error bars are too small to be visible.
Main differences with UDDMs. The above objective (103) is directly related only to the term L r e c o n s t r u c t i o n \mathcal{L}_{\mathrm{reconstruction}} L reconstruction in Eq. (38) , since AMs traditionally rely on a fixed temperature rather than annealing the temperature during its dynamics. By following this analogy, the reverse diffusion process can be interpreted as a stochastic AM retrieval dynamics for categorical variables where we also anneal the temperature, similarly to the continuous setting ([9 ] (Pham, Raya, et al. 2026)). From this perspective, we suspect that the additional terms in Eq. (38) are useful to enlarge basins of attraction when conditional probabilities are parametrized with deep architectures (like a transformer), but we leave this study for future work.
Methods
As shown in D’Amico, Bocchi, et al. [34 ] and Kalaj et al. [85 ] , the AM produced by conditional-likelihood (103) is capable of generalization: when trained on a sufficiently large dataset, the system creates new attractors that are strongly correlated with both training and test examples. In this section, taking inspirations from these results, we can ask whether similar regimes of memorization and generalization, found in AMs, can appear in UDDMs. Consequently, we design three experiments of increasing realism from the UDDM perspective, progressively bridging the gap between the AM retrieval setting and the standard generative process of a UDDM. Across these experiments, we explore the memorization-to-generalization transition as a function of the training dataset size and model scale.
Experiment 1: Deterministic retrieval from reference examples. To emulate the zerotemperature retrieval dynamics of an AM without the confounding effects of stochastic generation noise, we establish a specialized baseline setting. As reported in Figure 4.1 , we initialize the reverse process from corrupted training and test examples, and replace the standard stochastic sampling with deterministic greedy dynamics. At each step, we take the arg max of the conditional probabilities rather than sampling from them. In this setting, the perturbation level is decoupled from the diffusion time, which is always set to t = 1 t = 1 t = 1 while the fraction of corrupted input tokens is varied, allowing us to cleanly measure the token recovery rate as a function of the input noise level.
Experiment 2: Stochastic retrieval from reference examples. To understand how the standard diffusion dynamics alter the stability and structural boundaries of these basins under realistic operating conditions, we introduce stochasticity back into the UDDMs. In Figure 4.2 and (4.4) we retain the initialization from training and test examples, but restore the standard stochastic reverse dynamics. The perturbation level is now tied to the diffusion time t t t as in the typical UDDM scheme, where each value of t t t determines both the fraction of corrupted tokens and the time step at which the reverse process is initialized, providing a dynamic look at token recovery across varying levels of input noise.
Experiment 3: Standard generative process. Finally, we run the full standard reverse dynamics starting from noise , independent of any reference sequences, e.g., training or test sequences, in Figure 4.5 and Figure 4.3 . Because ground-truth samples are unavailable, token recovery rate is no longer a viable metric. Instead, we use conditional entropy (106) as our metric. In Figure 4.3 we validate the performance of UDDM across the memorization-to-generalization transition by measuring the perplexity of the generated sequences with GPT-2 Large [122 ] used as the critic model.
We analyze these experiments on the LM1B dataset [29 ] via two metrics, as a function of the training dataset size: token recovery rate and conditional entropy , which serve as proxies for the stability and geometry of the attractors, respectively. For more details and results, please refer to § 5.7.1 and § 5.7.5 , respectively.
Corrupt Token Recovery. We define the corrupt token recovery rate as the accuracy with which the model recovers a target or original sequence of length L L L , either a training or a test example, via applying the reverse process on a noisy sequence defined at time t ∈ ( 0 , 1 ] t \in(0,1] t ∈ ( 0 , 1 ] :
R ( x 1 : L , x ^ 1 : L ) = 1 ∣ M ∣ ∑ j ∈ M δ ( x j , x ^ j ) , (105) R(\mathbf{x}^{1:L}, \hat{\mathbf{x}}^{1:L}) = \frac{1}{|\mathcal{M}|} \sum_{j \in\mathcal{M}} \delta(x^j,\hat{x}^j), \tag*{(105)} R ( x 1 : L , x ^ 1 : L ) = ∣ M ∣ 1 j ∈ M ∑ δ ( x j , x ^ j ) , (105)
where x 1 : L \mathbf{x}^{1:L} x 1 : L is the original sequence, x ^ 1 : L \hat{\mathbf{x}}^{1:L} x ^ 1 : L is the recovered sequence after running a denoising process (either greedy or stochastic), M = { j : δ ( x j , z t j ) = 0 } \mathcal{M} = \{j : \delta(x^j,z_t^j) = 0\} M = { j : δ ( x j , z t j ) = 0 } is the set of indices in the input sequence z t 1 : L \mathbf{z}_t^{1:L} z t 1 : L denoting the positions where the tokens of x 1 : L \mathbf{x}^{1:L} x 1 : L have been changed after applying the forward process (35) , and δ ( ⋅ , ⋅ ) \delta(\cdot,\cdot) δ ( ⋅ , ⋅ ) denotes the Kronecker delta function.
Conditional Entropy. While token recovery rates indicate whether the system successfully returns to an attractor, UDDMs also provide direct access to conditional likelihood, allowing us to probe the local geometry and sharpness of these basins. Here, the conditional entropy of an individual token x ℓ x^\ell x ℓ in a sequence, given its associated perturbed sequence z t 1 : L \mathbf{z}_t^{1:L} z t 1 : L at some time t t t is defined as:
H ( x ℓ ∣ z t 1 : L ) = − ∑ k = 1 V [ x θ ℓ ( z t 1 : L , t ) ] k log [ x θ ℓ ( z t 1 : L , t ) ] k , (106) \mathcal{H}(x^\ell\mid\mathbf{z}_t^{1:L}) = -\sum_{k=1}^{V} [x^\ell_\theta(\mathbf{z}_t^{1:L},t)]_k \log[x^\ell_\theta(\mathbf{z}_t^{1:L},t)]_k, \tag*{(106)} H ( x ℓ ∣ z t 1 : L ) = − k = 1 ∑ V [ x θ ℓ ( z t 1 : L , t ) ] k log [ x θ ℓ ( z t 1 : L , t ) ] k , (106)
where x θ ℓ ( z t 1 : L , t ) x^\ell_\theta(\mathbf{z}_t^{1:L},t) x θ ℓ ( z t 1 : L , t ) is the output of the diffusion transformer for position ℓ \ell ℓ of the sequence over a vocabulary of size V V V . Meanwhile, the conditional entropy of a sequence is the sum of each token’s conditional entropy for all positions from 1 to L L L , i.e., H ( x 1 : L ∣ z t 1 : L ) = ∑ ℓ = 1 L H ( x ℓ ∣ z t 1 : L ) \mathcal{H}(\mathbf{x}^{1:L} \mid\mathbf{z}_t^{1:L}) = \sum_{\ell=1}^{L} \mathcal{H}(x^\ell\mid\mathbf{z}_t^{1:L}) H ( x 1 : L ∣ z t 1 : L ) = ∑ ℓ = 1 L H ( x ℓ ∣ z t 1 : L ) . Please refer to § 5.7.3 for our discussion on the relationship between conditional entropy and energy curvature (or sharpness).
Results
Our empirical analysis demonstrates that, as the training set size increases, basins around training examples shrink and basins around test examples expand (see Figure 4.1 ). Changes in the structure of basins are reflected in token recovery rates: for larger datasets the token recovery rate for training examples drops (see Figure 4.2 , solid lines), while the recovery rate for unseen test samples increases (dashed lines in Figure 4.2 ). For a certain size onward, the retrieval behaviors of both seen and unseen sequences converge to an identical recovery rate, mirroring the convergence of training and test basins and completing the transition from memorization to generalization. Scaling up the model size delays this transition, consistently with continuous DMs [168 , 121 ] .
For these results, please note that a high recovery rate on test sequences does not imply that a basin has formed around them, since it could also be explained just by a correct conditional prediction. We keep the naming of ‘basin’ for two reasons. First, the denoising is still non-trivial: the rate remains well above the injected noise, so the dynamics returns close to the original sequence rather than to an unrelated one. Second, a sentence admits many valid completions, and a rate below 100% is what we should expect, since valid alternatives are counted as unrecovered tokens. Both are compatible with the attractor being flat, with the flat directions corresponding to the equivalent formulations of a given sentence, which also accounts for the dependence on the noise level: without corruption the greedy reverse process initialized on a test sequence stays on it, giving 100% recovery, while any finite corruption drops it below 100% (see Figure 4.1 B)), because the state can be moved to a different point of the same basin. Consistently, the unrecovered tokens in the generalization phase are usually grammatically and semantically valid (see Figure 4.1 A), Figure 4.9 , and Figure 4.10 ).
Figure 4.9. An illustration of the model’s ability to recover tokens from perturbed sequences on training examples at three different fractions of the training dataset and sizes of the UDDMs. Results are shown for the Tiny (∼ \sim ∼ 24M, top), Small (∼ \sim ∼ 135M, middle), and Medium (∼ \sim ∼ 384M, bottom) models. Perturbation is computed at t = 0.5 t = 0.5 t = 0.5 and the typical stochastic reverse process is performed afterwards. As the training dataset size increases, the model’s ability to recover perturbed tokens becomes worse and in contrast, its generative ability improves. Meanwhile, there is no distinction among the various UDDMs’ sizes, where the overall trend of memorization and generalization in relation to the training dataset size persists.
Figure 4.10. An illustration of the model’s ability to recover tokens from perturbed sequences on test examples at different fractions of the training dataset and sizes of UDDMs. Results are shown for the Tiny (∼ \sim ∼ 24M, top), Small (∼ \sim ∼ 135M, middle), and Medium (∼ \sim ∼ 384M, bottom) models. Perturbation is computed at t = 0.5 t = 0.5 t = 0.5 and the stochastic reverse process is performed afterwards. In the beginning, the model is unable to recognize unperturbed unseen test tokens, where it often changes them to other tokens. However, as the training dataset size increases, the UDDM is more likely to maintain the unperturbed test tokens rather than ‘flipping’ them.
Moreover, as shown in Fig. (4.4), successful token recovery is characterized by near-zero conditional entropy, whereas unrecovered tokens exhibit higher and non-zero conditional entropy value. Interestingly, a distinct fraction of highly stable and low-entropy tokens persists even at the later generalization phase, suggesting that there are tokens which are very stable and less likely to change through the generative process. Using the average sequence-level conditional entropy of training and generated sequences, we observe a conditional entropy gap at the intermediate regime. of the transition (see Figure 4.5 ): at very low fractions of the training set, the conditional entropy distributions of training and generated sequences coincide and peak near zero. In the intermediate regime, these distributions however separate from each other until the training set size is large enough, and once again overlap each other (but at non-zero values of conditional entropy).
Figure 4. Token-level conditional entropy highlights different token recovery behaviors. (A) Textual examples showing how two Medium UDDMs, trained on two different training dataset sizes, recover corrupted training sequences at noise level t = 0.5 t = 0.5 t = 0.5 . The model trained on a small training set perfectly memorizes and restores the original text. In contrast, the model trained on a large training set recovers some original words but actively alters others to synthesize a novel sentence. (B) Density histograms of conditional entropy for individual tokens from Figure 4.2 for the Tiny (left), Small (middle), and Medium (right) models. Successfully recovered tokens consistently demonstrate much lower entropy, indicating higher model confidence. While this gap between recovered and unrecovered tokens narrows in larger models, a surprising number of highly stable, low-entropy tokens persist even during the generalization phase. The y -axis is clipped to better contrast these two token types.
Perplexity benchmarks using GPT-2 Large validate these phase transitions (see Figure 4.3 ): we observe that the region where perplexity increases (to the left of the transition) corresponds to the memorization phase, which suggest that the perplexity is initially low due to the model’s duplication of training sequences. Conversely, the region where perplexity decreases (to the right of the transition) corresponds to the generalization phase where basins around test sequences start forming, suggesting that these novel basins are related to the generative capabilities of the model.
The correspondence between token recovery rate in Figure 4.2 and perplexity in Figure 4.3 also holds for the rightmost region where the perplexity plateaus: the length of the plateaus is similar in both figure. The plateaus of lower perplexity correspond to the converging token recovery rates, see Figure 4.17 in § 5.7.5 for a combined version of Figure 4.2 and (99) . This alignment suggests that token recovery rate captures the same underlying phenomenon: it identifies the generative regime without an external model and offers a geometrical interpretation, where generalization is defined by the evolution of basins around training and test sequences.
Figure 4.17. Perplexity trends during the memorization-to-generalization transition together with corrupted token recovery. This figure demonstrates the alignment of phase transitions across perplexity (top row) and the average corrupt token recovery rate (bottom row) for the Tiny (left column), Small (middle column), and Medium (right column) models. The vertical dashed lines roughly represent the critical transitional points where the perplexity (calculated using GPT-2 Large Radford et al., [122 ] ) aligns with the initial decrease of corrupt token recovery rate for training and the increase of test tokens’ recovery rate. This alignment of the two metrics showcases the usefulness of the token recovery rate in determining whether generalization has been reached in UDDMs.
Note that recovery under denoising is not the same as training-data extraction [162 ] (Carlini, Hayes, et al. 2023). Our metrics probe the stability of the dynamics near a given sequence, and carry no information on the probability of reaching a specific training or test sequence starting from noise. The non-monotonic perplexity of Figure 4.3 is only indirect evidence in this direction: the low perplexity at small fractions is compatible with the model duplicating training sequences, while the plateau after the transition we can only interpret as good in-distribution generation.
Conclusion
By framing UDDMs as AMs, we show that an explicit energy function is not required to guarantee attractor dynamics. Instead, basins can form through conditional likelihood maximization alone, which reveals a sharp memorization-to-generalization transition governed by the training set size. As training dataset scales up, basins around training examples shrink while basins around unseen test sequences expand until they become indistinguishable. This evolution allows the model to recover both seen and unseen sequences from perturbations, showing a form of co-existence of memory and creativity.
Furthermore, token recovery rate and conditional entropy serve as complementary geometric probes of this transition: conditional entropy vanishes during memorization but remains finite during generalization, providing a measurable entropy gap between training and synthetic sequences that narrows with model scale. Larger models delay this transition, requiring more data to generalize before both metrics stabilize past the phase boundary. In this picture the attractors in the generalization phase are flat, where the flat directions correspond to equivalent formulations of a sentence. We leave the study of these directions, which requires assessing semantic equivalence, to future work.
Finally, a distinct fraction of highly stable, low-entropy tokens persists even during the generalization phase, when novel text is being synthesized. We hypothesize that these tokens correspond to rigid syntactic structures, predictable function words, or common idioms that must remain stable to preserve linguistic fluency, and that act therefore as micro-attractors within an otherwise novel sequence. This leaves an interesting question for us and the community to explore.
Limitations. This chapter opens some directions for future investigation. First, how good the new proposed metrics are in practically relevant cases remains an open question: while we showed a promising consistent picture with the perplexity measurement, an extensive analysis of how token recovery rate and conditional entropy correlate with standard evaluation metrics would be needed to consolidate their validity as proxies for generalization. Second, UDDMs provide a convenient and tractable setting for this study, but extending these ideas to regimes where factual recall appears in practice would require significantly larger models, up to and including large language models, which would introduce conceptual and practical challenges beyond the scope of this chapter.
Supplementary Material
This section collects the experimental details and additional results that support the findings of this chapter.
Additional Details on Memorization to Generalization
Setup. For the experiments in § 5.5 , we trained three sets of UDDMs, labeled as Tiny , Small , and Medium , utilizing the code base and approach of Sahoo et al. [132 ] 6 . For more details on this variant of UDDMs, please refer to the discussion in § 5.7.2 below. Meanwhile, the backbone of our trained UDDMs is the diffusion transformer architecture from Peebles & Xie [119 ] . The configurations of our three variations of UDDMs are described in Table 4.1 .7
Table 4.1. A table showing hyperparameters of the UDDMs for the Tiny , Small , and Medium sets. These variables are obtained from Sahoo et al. [132 ] . Scale by sigma indicates that the model takes the inverse temperature or the appropriate diffusion scheduling parameter at time t t t instead of the typical approach of conditioning on t t t .
Meanwhile, there are a total of 162 models, or 54 models for each of the three UDDM sets we have trained. All models are trained up to 1 million training iterations following the procedures detailed in Sahoo et al. [132 ] . For the selection of the fraction of the training dataset sizes, we initially start with the fraction n = 10 − 2 n = 10^{-2} n = 1 0 − 2 and increment it by Δ n = 0.03 \Delta n = 0.03 Δ n = 0.03 all the way to the full dataset. However, to further magnify the memorization phase, we train more points using linear spacing (of 17 points, inclusively) starting at 10 − 4 10^{-4} 1 0 − 4 to 10 − 2 10^{-2} 1 0 − 2 , and another set of points using linear spacing (of 7 points, inclusively) starting from 10 − 2 10^{-2} 1 0 − 2 to 0.07. Lastly, our models are trained on the LM1B dataset ([29 ] ), using GPT-2 tokenizer ([122 ] ), where our model handles the block size (or sequence length) of 128, and all of them are initialized from the same random seed.
Token Recovery Rate. To obtain the results in Figure 4.2 , we utilized our trained models, from the three sets corresponding to Tiny , Small , and Medium UDDMs. Here, we computed the analysis of randomly chosen 5 × 10 3 5 \times10^{3} 5 × 1 0 3 samples belonging to their respective training set (in accordance with their fraction of training dataset size) and also 5 × 10 3 5 \times10^{3} 5 × 1 0 3 sequences from the test set. We performed the perturbation of these sequences using the forward process (113) at time t t t , and run the reverse process (37) starting at or near the same time t t t back to a small terminal time ϵ = 10 − 5 \epsilon= 10^{-5} ϵ = 1 0 − 5 . Finally, to measure our recovery rate, we applied Eq. (105) , which measures the rate of perturbed tokens being recovered.
Meanwhile, for Figure 4.1 , we are interested in the shrinkage of the basins of our training and unseen test sequences. To obtain a more comprehensive view of this shrinkage without worrying about the stochastic noise added during each reverse process (37) step as t → 0 t \to0 t → 0 , we utilized the greedy or deterministic sampling dynamics instead. Specifically, in Eq. (37) , to obtain z s z_s z s as we traverse back in time, we are effectively sampling from a categorical distribution Cat ( ⋅ ) \operatorname{Cat}(\cdot) Cat ( ⋅ ) . To convert this stochastic process to a deterministic one, we simply replaced Cat ( ⋅ ) \operatorname{Cat}(\cdot) Cat ( ⋅ ) with the arg max ( ⋅ ) \operatorname{arg\,max}(\cdot) arg max ( ⋅ ) operation. Similarly to the previous experiment, we applied perturbation using the forward process (113) , and utilized the greedy process to denoise our sequences. The timesteps we used are { 0.1 , 0.2 , 0.3 , … , 1.0 } \{0.1, 0.2, 0.3, \ldots, 1.0\} { 0.1 , 0.2 , 0.3 , … , 1.0 } and the same values of t t t we used in Figure 4.2 .
Conditional Entropy. In Fig. (4.4), we computed the token conditional entropy following Eq. (106) for unrecovered and recovered tokens at t = 10 − 5 t = 10^{-5} t = 1 0 − 5 identified in Figure 4.2 using 5 × 10 3 5 \times10^{3} 5 × 1 0 3 samples (per training and per test sequences), respectively. Meanwhile, for the results in Figure 4.5 and Figure 4.7 , we generated a synthetic set of 10 5 10^{5} 1 0 5 samples for each of the trained models and performed our analyses – alongside using at most 10 5 10^{5} 1 0 5 sequences belonging to the training set that each model was trained with. It is important to note that the results in Figure 4.7 are the average conditional entropy computed across sequences and their respective tokens, while Figure 4.5 showcases the sequence conditional entropy, which is the sum of all of the tokens’ conditional entropy in a given sequence. Please see Figure 4.14 -Figure 4.16 for the full histograms of conditional entropy on training versus generated samples, and Figure 4.11 -Figure 4.13 for more conditional entropy histograms of the unrecovered versus recovered tokens shown in Figure 4.2 .
Figure 4.7. Average conditional entropy for training versus synthetic sequences. As the training dataset size increases, the average (over sequences and tokens) conditional entropy for both training and synthetic (or generated) sequences naturally rises for the Tiny (left), Small (middle), and Medium (right) models. Here, we plot the dashed horizontal line in each plot to show the location of the separation between the average conditional entropies of training and synthetic sequences. Initially, there exists an “entropy gap” which separates these two sample types given small fractions of the training set, depicting the UDDM’s uncertainty during generation. However, scaling up the model’s size narrows this entropy gap, demonstrating that higher parameter counts increase the model’s confidence in its own generated text during the generalization regime.
Figure 4.11. An illustration of the density of conditional entropy for two categories of tokens, recovered and unrecovered, computed at t = 0.25 t = 0.25 t = 0.25 for the Tiny model. The subplots are ordered by the fraction of training dataset, ranging from 10 − 4 10^{-4} 1 0 − 4 (top-left) to 1.0 (bottom-right). As the fraction of training data increases, recovered tokens concentrate near zero entropy (high confidence), while unrecovered tokens exhibit a broad distribution at higher entropy.
Figure 4.13. An illustration of the density of conditional entropy for two categories of tokens, recovered and unrecovered, computed at t = 0.25 t = 0.25 t = 0.25 for the Medium model. The subplots are ordered by the fraction of training dataset, ranging from 10 − 4 10^{-4} 1 0 − 4 (top-left) to 1.0 (bottom-right). As the fraction of training data increases, recovered tokens concentrate near zero entropy (high confidence), while unrecovered tokens exhibit a broad distribution at higher entropy.
Figure 4.14. An illustration of the evolution of the density of the average conditional entropy for the probabilities of training and synthetic sequences respectively, computed at t = 10 − 5 t = 10^{-5} t = 1 0 − 5 using the Tiny models, as the training dataset size grows. When the fraction of training set is small, there exists a separation in the average conditional entropies of training and synthetic samples. However, as the training dataset size grows, this separation is reduced and the conditional entropy of synthetic samples becomes similar to that of the training samples.
Figure 4.16. An illustration of the evolution of the density of the average conditional entropy for the probabilities of training and synthetic sequences respectively, computed at t = 10 − 5 t = 10^{-5} t = 1 0 − 5 using the Medium models, as the training dataset size grows. When the fraction of training set is small, there exists a separation in the average conditional entropies of training and synthetic samples. However, as the training dataset size grows, this separation is reduced and the conditional entropy of synthetic samples becomes similar to that of the training samples. Due to larger model size, the UDDM exhibits stronger memorization (and chaotic) behaviors, where the two distributions initially merge at certain fractions of the training dataset and later diverge. Nonetheless, with the full training set, both distributions overlap each other at the end.
Textual Examples. In Figure 4.1 and (104) , we are interested in studying the stability of unseen test tokens across different perturbation levels (although we are much more interested in the case where there is little noise for these experiments). For the textual examples illustrated in Figure 4.1 A) and (4.4A), we used the models that have been trained with the fractions of the training dataset: 0.000719 and 1.0. Although these two figures utilize different sampling dynamics (i.e., greedy versues stochastic), in general we do not spot much differences between the greedy and stochastic processes for our token recovery experiments. Please see Figs. (4.4A), Figure 4.9 , and Figure 4.10 for the textual examples that collected using the typical stochastic process.
Perplexity. Similarly to our results on conditional entropy, we utilized the same sets of 10 5 10^{5} 1 0 5 generated sequences belonging to each trained UDDM, respectively. The code to compute perplexity is also from Sahoo et al. [132 ] . Keep in mind, the reported conditional entropy results are computed from our UDDMs, unlike perplexity, which requires the reference or critic model of the pre-trained GPT2-Large (Radford et al. [122 ] ) as mentioned previously.
Hardware. The training of the UDDMs are done using NVIDIA Tesla V100 GPUs. Each GPU has 32GB of memory and is linked with Power9 processors, clocking at 3.15 GHz maximum. For each model, we used 4 GPUs and an effective total (or global) batch size of 512 samples. For each GPU, the local batch size is set as 64, requiring 2 gradient accumulation steps.
Uniform-State Discrete Diffusion and Duality with Gaussian
Further Details on UDDMs. As mentioned in § 5.2 , the true reverse posterior of a previous timestep s < t s < t s < t corresponding to the forward process (35) is
z s ∼ q s ∣ t ( z s ∣ z t , x ) = Cat ( z s ; g ( z t , x ) ) = Cat ( z s ; α t z t ⊙ x + ( α t ∣ s − α t ) z t α t ⟨ z t , x ⟩ + ( 1 − α t ) + ( α s − α t ) x + ( 1 − α t ∣ s ) 1 V α t ⟨ z t , x ⟩ + ( 1 − α t ) ) , (107) z_s \sim q_{s|t}(z_s \mid z_t, \mathbf{x}) = \operatorname{Cat}\left(z_s; g(z_t,\mathbf{x})\right)
= \operatorname{Cat}\left(z_s; \frac{\sqrt{\alpha_t}z_t \odot\mathbf{x} + (\alpha_{t|s}-\alpha_t)z_t}{\sqrt{\alpha_t}\langle z_t,\mathbf{x}\rangle+ (1-\alpha_t)} + \frac{(\alpha_s-\alpha_t)\mathbf{x}+(1-\alpha_{t|s})\frac{1}{V}}{\sqrt{\alpha_t}\langle z_t,\mathbf{x}\rangle+(1-\alpha_t)}\right), \tag*{(107)} z s ∼ q s ∣ t ( z s ∣ z t , x ) = Cat ( z s ; g ( z t , x ) ) = Cat ( z s ; α t ⟨ z t , x ⟩ + ( 1 − α t ) α t z t ⊙ x + ( α t ∣ s − α t ) z t + α t ⟨ z t , x ⟩ + ( 1 − α t ) ( α s − α t ) x + ( 1 − α t ∣ s ) V 1 ) , (107)
where ⟨ ⋅ , ⋅ ⟩ \langle\cdot,\cdot\rangle ⟨ ⋅ , ⋅ ⟩ denotes the dot product, ⊙ \odot ⊙ denotes Hadamard product, the relative diffusion parameter is α t ∣ s = α t α s \alpha_{t|s} = \frac{\alpha_t}{\alpha_s} α t ∣ s = α s α t , and we have a uniform prior over V \mathcal{V} V (π = 1 / V \pi= 1/V π = 1/ V ) ([131 , 132 ] ).
Since the true clean token x \mathbf{x} x is unknown during the generative process (107) , the approximate reverse posterior is defined as p s ∣ t θ ( z s ∣ z t ) = q s ∣ t ( z s ∣ z t , x = x θ ( z t , t ) ) p^\theta_{s|t}(z_s \mid z_t) = q_{s|t}(z_s \mid z_t, \mathbf{x} = x_\theta(z_t,t)) p s ∣ t θ ( z s ∣ z t ) = q s ∣ t ( z s ∣ z t , x = x θ ( z t , t )) . The neural network x θ ( z t , t ) ≈ x x_\theta(z_t,t) \approx\mathbf{x} x θ ( z t , t ) ≈ x is trained to predict the clean token x \mathbf{x} x at any time t t t according to Eq. (37) , where p θ ( x ∣ z t ) = x θ ( z t , t ) p_\theta(\mathbf{x}\mid z_t) = x_\theta(z_t,t) p θ ( x ∣ z t ) = x θ ( z t , t ) . The network’s parameters θ \theta θ are optimized via the Negative Evidence Lower Bound (NELBO) objective (Austin et al., [14 ] ; Sahoo et al. [131 ] ):
L N E L B O = E q [ − log p θ ( x ∣ z 0 ) ⏟ L r e c o n s t r u c t i o n + ∑ s < t D K L [ q ( z s ∣ z t , x ) ∥ p θ ( z s ∣ z t ) ] ⏟ L d i f f u s i o n ] + D K L [ q ( z 1 ∣ x ) ∥ p θ ( z 1 ) ] ⏟ L p r i o r . (108) \mathcal{L}_{\mathrm{NELBO}} = \mathbb{E}_{q}\left[\underbrace{-\log p_{\theta}(\mathbf{x}\mid\mathbf{z}_0)}_{\mathcal{L}_{\mathrm{reconstruction}}} + \underbrace{\sum_{s<t}D_{\mathrm{KL}}\left[q(\mathbf{z}_s\mid\mathbf{z}_t,\mathbf{x})\mathrel{\|}p_{\theta}(\mathbf{z}_s\mid\mathbf{z}_t)\right]}_{\mathcal{L}_{\mathrm{diffusion}}}\right] + \underbrace{D_{\mathrm{KL}}\left[q(\mathbf{z}_1\mid\mathbf{x})\mathrel{\|}p_{\theta}(\mathbf{z}_1)\right]}_{\mathcal{L}_{\mathrm{prior}}}. \tag*{(108)} L NELBO = E q L reconstruction − log p θ ( x ∣ z 0 ) + L diffusion s < t ∑ D KL [ q ( z s ∣ z t , x ) ∥ p θ ( z s ∣ z t ) ] + L prior D KL [ q ( z 1 ∣ x ) ∥ p θ ( z 1 ) ] . (108)
As discussed in § 5.3 , the term L r e c o n s t r u c t i o n \mathcal{L}_{\mathrm{reconstruction}} L reconstruction is more related to our simple setting in that section due to the fact that it only deals with a single finite temperature value (or it does not rely on temperature annealing). However, we suspect that the other terms in NELBO (108) further help the maximization of classification margin (or basin) of the data points.
Duality of Uniform and Gaussian. In continuous diffusion modeling, we typically rely on the diffusion mapping of a data distribution q d a t a q_{\mathrm{data}} q data to a simple prior distribution that is often the standard Gaussian distribution N ( 0 , I V ) \mathcal{N}(0,I_V) N ( 0 , I V ) . The marginal distribution of the noisy latent variable w t ∼ q ~ t ( ⋅ ∣ x ) \mathbf{w}_t\sim\widetilde{q}_t(\cdot\mid\mathbf{x}) w t ∼ q t ( ⋅ ∣ x ) at time t t t is defined as:
w t ∼ q ~ t ( w t ∣ x ; α ~ t ) = N ( w t ; α ~ t x , ( 1 − α ~ t 2 ) I V ) , (109) \mathbf{w}_t\sim\widetilde{q}_t(\mathbf{w}_t\mid\mathbf{x};\widetilde{\alpha}_t)=\mathcal{N}\left(\mathbf{w}_t;\widetilde{\alpha}_t\mathbf{x},(1-\widetilde{\alpha}_t^2)I_V\right), \tag*{(109)} w t ∼ q t ( w t ∣ x ; α t ) = N ( w t ; α t x , ( 1 − α t 2 ) I V ) , (109)
where α ~ t ∈ [ 0 , 1 ] \widetilde{\alpha}_t\in[0,1] α t ∈ [ 0 , 1 ] is the diffusion parameter that is a monotonically decreasing function in t t t . The boundary conditions are q ~ t = 0 ≈ q d a t a \widetilde{q}_{t=0}\approx q_{\mathrm{data}} q t = 0 ≈ q data and q ~ t = 1 = N ( 0 , I V ) \widetilde{q}_{t=1}=\mathcal{N}(0,I_V) q t = 1 = N ( 0 , I V ) .
However, as shown in Sahoo et al. [132 ] , there exists a connection between the Gaussian and Uniform diffusion processes for the discrete setting. Specifically, we can utilize the operator, arg max : R V → V \operatorname*{arg\,max}:\mathbb{R}^V\to\mathcal{V} arg max : R V → V , to map a continuous vector w ∈ R V \mathbf{w}\in\mathbb{R}^V w ∈ R V to the one-hot vector corresponding to arg max z ∈ V z ⊤ w \operatorname*{arg\,max}_{\mathbf{z}\in\mathcal{V}}\mathbf{z}^{\top}\mathbf{w} arg max z ∈ V z ⊤ w . Then, we can define the discrete marginals to be
z t = arg max ( w t ) , (110) \mathbf{z}_t=\operatorname*{arg\,max}(\mathbf{w}_t), \tag*{(110)} z t = arg max ( w t ) , (110)
and the conditional probability mass function p t ( z t ∣ x ) p_t(\mathbf{z}_t\mid\mathbf{x}) p t ( z t ∣ x ) marginalized over w t ∼ q ~ t ( w t ∣ x ; α ~ t ) \mathbf{w}_t\sim\widetilde{q}_t(\mathbf{w}_t\mid\mathbf{x};\widetilde{\alpha}_t) w t ∼ q t ( w t ∣ x ; α t ) such that
z t ∼ P t ( z t ∣ x ; T ( α ~ t ) ) = Cat ( z t ; T ( α ~ t ) x + ( 1 − T ( α ~ t ) ) 1 V ) , (111) \mathbf{z}_t\sim P_t\left(\mathbf{z}_t\mid\mathbf{x};\mathcal{T}(\widetilde{\alpha}_t)\right)=\operatorname{Cat}\left(\mathbf{z}_t;\mathcal{T}(\widetilde{\alpha}_t)\mathbf{x}+\left(1-\mathcal{T}(\widetilde{\alpha}_t)\right)\frac{1}{V}\right), \tag*{(111)} z t ∼ P t ( z t ∣ x ; T ( α t ) ) = Cat ( z t ; T ( α t ) x + ( 1 − T ( α t ) ) V 1 ) , (111)
where T : [ 0 , 1 ] → [ 0 , 1 ] \mathcal{T}:[0,1]\to[0,1] T : [ 0 , 1 ] → [ 0 , 1 ] is the Gaussian Diffusion Transformation operator. This operator is defined as the following Gaussian integral:
α t = T ( α ~ t ) = V V − 1 [ ∫ − ∞ ∞ ϕ ( z − α ~ t 1 − α ~ t 2 ) Φ V − 1 ( z ) d z − 1 V ] (112) \alpha_t=\mathcal{T}(\widetilde{\alpha}_t)=\frac{V}{V-1}\left[\int_{-\infty}^{\infty}\phi\left(z-\frac{\widetilde{\alpha}_t}{\sqrt{1-\widetilde{\alpha}_t^2}}\right)\Phi^{V-1}(z)\,\mathrm{d}z-\frac{1}{V}\right] \tag*{(112)} α t = T ( α t ) = V − 1 V [ ∫ − ∞ ∞ ϕ ( z − 1 − α t 2 α t ) Φ V − 1 ( z ) d z − V 1 ] (112)
where ϕ ( z ) = exp ( − z 2 ) 2 π \phi(z) = \frac{\exp(-z^2)}{\sqrt{2\pi}} ϕ ( z ) = 2 π e x p ( − z 2 ) is the standard Normal distribution and Φ ( z ) = ∫ − ∞ z ϕ ( t ) d t \Phi(z) = \int_{-\infty}^{z} \phi(t)\,\mathrm{d}t Φ ( z ) = ∫ − ∞ z ϕ ( t ) d t is the respective cumulative distribution.
Overall, there exists a fundamental connection between Uniform-state discrete and Gaussian diffusion processes, shown in Sahoo et al. [132 ] . Specifically, this formal connection is expressed as
z t ∼ q t ( z t ∣ x ; T ( α ~ t ) ) = [ arg max ] ∗ q ~ t ( w t ∣ x ; α ~ t ) (113) \mathbf{z}_t \sim q_t(\mathbf{z}_t \mid\mathbf{x}; \mathcal{T}(\tilde{\alpha}_t)) = [\operatorname{arg\,max}]_* \tilde{q}_t(\mathbf{w}_t \mid\mathbf{x}; \tilde{\alpha}_t) \tag*{(113)} z t ∼ q t ( z t ∣ x ; T ( α ~ t )) = [ arg max ] ∗ q ~ t ( w t ∣ x ; α ~ t ) (113)
where ∗ * ∗ denotes the push-forward of the V V V -dimensional Gaussian density q ~ t \tilde{q}_t q ~ t under arg max \operatorname{arg\,max} arg max which yields a categorical distribution of V V V categories. For full details, please refer to [132 ] .
Conditional Entropy and Curvature
In the more common setting, where AM have an energy landscape, the sharpness of the basin dictates retrieval dynamics [101 , 99 , 100 ] . Low entropy implies more deterministic attractors (memorization ), while high entropy signals a flatter landscape with distributed probability mass [18 ] . This flatness facilitates generalization , where basins widen and merge to capture the underlying data manifold, enabling the synthesis of novel patterns (Pham, Raya, et al., 2026).
In this section, inspired by Biroli et al. [18 ] and D’Amico, Bocchi, et al. (2026), we relate entropy and the curvature (or sharpness) of the energy in the continuous setting, using local approximation, to show the connection between these two ideas. Here, assume that the clean data x ∈ R d \mathbf{x} \in\mathbb{R}^{d} x ∈ R d and its perturbed version z t ∈ R d \mathbf{z}_t \in\mathbb{R}^{d} z t ∈ R d at time t t t .
Proof Sketch. Consider the conditional distribution p ( x ∣ z t ) p(\mathbf{x} \mid\mathbf{z}_t) p ( x ∣ z t ) defined by an energy function E ( x ; z t ) E(\mathbf{x}; \mathbf{z}_t) E ( x ; z t ) :
p ( x ∣ z t ) = 1 Z ( z t ) e − E ( x ; z t ) (114) p(\mathbf{x} \mid\mathbf{z}_t) = \frac{1}{Z(\mathbf{z}_t)}e^{-E(\mathbf{x}; \mathbf{z}_t)} \tag*{(114)} p ( x ∣ z t ) = Z ( z t ) 1 e − E ( x ; z t ) (114)
where Z ( z t ) = ∫ e − E ( y , z t ) d y Z(\mathbf{z}_t) = \int e^{-E(\mathbf{y},\mathbf{z}_t)}\mathrm{d}\mathbf{y} Z ( z t ) = ∫ e − E ( y , z t ) d y is the partition function. We assume the distribution is peaked around a mode x ∗ \mathbf{x}^* x ∗ , representing the most likely clean data point given the noisy observation z t \mathbf{z}_t z t .
To analyze the local geometry, we perform a second-order Taylor expansion of the energy E ( x ; z t ) E(\mathbf{x}; \mathbf{z}_t) E ( x ; z t ) with respect to x \mathbf{x} x , centered around the mode x ∗ ( z t ) \mathbf{x}^*(\mathbf{z}_t) x ∗ ( z t ) :
E ( x ; z t ) ≈ E ( x ∗ ; z t ) + ( x − x ∗ ) T ∇ x E ( x ∗ ; z t ) + 1 2 ( x − x ∗ ) T H ( z t ) ( x − x ∗ ) (115) E(\mathbf{x}; \mathbf{z}_t) \approx E(\mathbf{x}^*; \mathbf{z}_t) + (\mathbf{x} - \mathbf{x}^*)^{\mathsf{T}}\nabla_{\mathbf{x}}E(\mathbf{x}^*; \mathbf{z}_t) + \frac{1}{2}(\mathbf{x} - \mathbf{x}^*)^{\mathsf{T}}\mathbf{H}(\mathbf{z}_t)(\mathbf{x} - \mathbf{x}^*) \tag*{(115)} E ( x ; z t ) ≈ E ( x ∗ ; z t ) + ( x − x ∗ ) T ∇ x E ( x ∗ ; z t ) + 2 1 ( x − x ∗ ) T H ( z t ) ( x − x ∗ ) (115)
Since x ∗ \mathbf{x}^* x ∗ is a local minimum of the energy surface defined by z t \mathbf{z}_t z t , the gradient ∇ x E ( x ∗ ; z t ) \nabla_{\mathbf{x}}E(\mathbf{x}^*; \mathbf{z}_t) ∇ x E ( x ∗ ; z t ) vanishes.
The matrix H ( z t ) = ∇ x 2 E ( x ∗ ; z t ) \mathbf{H}(z_t)=\nabla_x^2E(x^*;z_t) H ( z t ) = ∇ x 2 E ( x ∗ ; z t ) is the Hessian of the energy, representing the local curvature or sharpness of the energy basin conditioned on z t z_t z t .
Using Eq. (115) and assuming that we are at the minimum where ∇ x E ( x ∗ ; z ) = 0 \nabla_xE(x^*;z)=0 ∇ x E ( x ∗ ; z ) = 0 , we can perform Laplace approximation for the partition function Z ( z t ) Z(z_t) Z ( z t ) :
Z ( z t ) ≈ ∫ e − ( E ( x ∗ ; z t ) + 1 2 ( x − x ∗ ) ⊤ H ( z t ) ( x − x ∗ ) ) d x = e − E ( x ∗ ; z t ) ∫ e − 1 2 ( x − x ∗ ) ⊤ H ( z t ) ( x − x ∗ ) d x = ( 2 π ) d 2 e − E ( x ∗ ; z t ) det ( H ( z t ) ) − 1 2 (116) \begin{aligned}
Z(z_t) &\approx\int e^{-\left(E(x^*;z_t)+\frac{1}{2}(x-x^*)^\top\mathbf{H}(z_t)(x-x^*)\right)}\,\mathrm{d}x\\
&=e^{-E(x^*;z_t)}\int e^{-\frac{1}{2}(x-x^*)^\top\mathbf{H}(z_t)(x-x^*)}\,\mathrm{d}x\\
&=(2\pi)^{\frac{d}{2}}e^{-E(x^*;z_t)}\det\left(\mathbf{H}(z_t)\right)^{-\frac{1}{2}} \tag*{(116)}
\end{aligned} Z ( z t ) ≈ ∫ e − ( E ( x ∗ ; z t ) + 2 1 ( x − x ∗ ) ⊤ H ( z t ) ( x − x ∗ ) ) d x = e − E ( x ∗ ; z t ) ∫ e − 2 1 ( x − x ∗ ) ⊤ H ( z t ) ( x − x ∗ ) d x = ( 2 π ) 2 d e − E ( x ∗ ; z t ) det ( H ( z t ) ) − 2 1 (116)
The conditional entropy H ( x ∣ z t ) \mathcal{H}(x|z_t) H ( x ∣ z t ) can now be defined. Using the relationship log p = − E − log Z \log p=-E-\log Z log p = − E − log Z and substitute it into H ( x ∣ z t ) \mathcal{H}(x|z_t) H ( x ∣ z t ) , we have
H ( x ∣ z t ) = E x ∼ p ( x ∣ z t ) [ E ( x ; z t ) + log Z ( z t ) ] = E x ∼ p ( x ∣ z t ) [ E ( x ; z t ) + d 2 log ( 2 π ) − E ( x ∗ ; z t ) − 1 2 log [ det ( H ( z t ) ) ] ] (117) \begin{aligned}
\mathcal{H}(x|z_t)&=\mathbb{E}_{x\sim p(x|z_t)}\left[E(x;z_t)+\log Z(z_t)\right]\\
&=\mathbb{E}_{x\sim p(x|z_t)}\left[E(x;z_t)+\frac{d}{2}\log(2\pi)-E(x^*;z_t)-\frac{1}{2}\log\left[\det\left(\mathbf{H}(z_t)\right)\right]\right] \tag*{(117)}
\end{aligned} H ( x ∣ z t ) = E x ∼ p ( x ∣ z t ) [ E ( x ; z t ) + log Z ( z t ) ] = E x ∼ p ( x ∣ z t ) [ E ( x ; z t ) + 2 d log ( 2 π ) − E ( x ∗ ; z t ) − 2 1 log [ det ( H ( z t ) ) ] ] (117)
If we substitute Eq. (115) into the term E ( x ; z t ) E(x;z_t) E ( x ; z t ) in Eq. (117) , we then have
H ( x ∣ z t ) ≈ E x ∼ p ( x ∣ z t ) [ E ( x ∗ ; z t ) + d 2 log ( 2 π ) − E ( x ∗ ; z t ) − 1 2 log [ det ( H ( z t ) ) ] + C ] ≈ E x ∼ p ( x ∣ z t ) [ − 1 2 log [ det ( H ( z t ) ) ] + C ] (118) \begin{aligned}
\mathcal{H}(x|z_t)&\approx\mathbb{E}_{x\sim p(x|z_t)}\left[E(x^*;z_t)+\frac{d}{2}\log(2\pi)-E(x^*;z_t)-\frac{1}{2}\log\left[\det\left(\mathbf{H}(z_t)\right)\right]+C\right]\\
&\approx\mathbb{E}_{x\sim p(x|z_t)}\left[-\frac{1}{2}\log\left[\det\left(\mathbf{H}(z_t)\right)\right]+C\right] \tag*{(118)}
\end{aligned} H ( x ∣ z t ) ≈ E x ∼ p ( x ∣ z t ) [ E ( x ∗ ; z t ) + 2 d log ( 2 π ) − E ( x ∗ ; z t ) − 2 1 log [ det ( H ( z t ) ) ] + C ] ≈ E x ∼ p ( x ∣ z t ) [ − 2 1 log [ det ( H ( z t ) ) ] + C ] (118)
where C C C is a constant involving the omitted terms from our substitution of Eq. (115) .
Discussion. Overall, this derivation highlights that the conditional entropy is inversely proportional to the log-determinant of the Hessian at the mode, and aligns well to the findings of Biroli et al. [18 ] where a collapse in entropy corresponds to the system getting trapped in small-disjoint regions of the configuration space. However, in this chapter, we study UDDMs, which are not continuous DMs. Thus, we lack the formulations that attempt to link up their conditional entropy with the sharpness in the discrete setting of language or text modeling. But we suspect that the connection between Uniform and Gaussian distributions in the discrete setting, laid out by Sahoo et al. [132 ] , provides some clues to further this link between conditional entropy and energy in a future work.
Numerical Validation of the Simplified Setting
In this section we propose a numerical verification of the binary or linear-logit analysis of § 5.3 , specifically that optimizing the conditional likelihood in Eq. (103) implicitly leads to a maximum-margin solution, which in turn leads to basins of attraction around training data points. Please note that these results are all already established [54 , 148 ] (D’Amico, Bocchi, et al. 2026), and that we reproduce them here for convenience.
Setup. We generate P = γ L P = \gamma L P = γ L random i.i.d. binary sequences (or patterns), where each sequence has a length of L = 250 L = 250 L = 250 , and train the recurrent coupling matrix W \mathbf{W} W by minimizing the pseudo-likelihood loss of Eq. (103) for each row independently (unregularized logistic regression), which is known to converge in direction to the maximum-margin solution [148 ] . Here, γ = P L \gamma= \frac{P}{L} γ = L P is the load or the ratio between the number of patterns P P P and their dimension L L L . For each load γ \gamma γ , we then measure the network’s empirical basin of attraction: starting from a stored pattern, we flip a fraction ρ \rho ρ of its bits, run the recurrent dynamics to a fixed point, and record the mean overlap between the recovered state and the original pattern, averaged over multiple patterns and corruption realizations. Basin size ρ c ( γ ) \rho_c(\gamma) ρ c ( γ ) is defined as the largest corruption level for which this overlap remains above 0.99, following the same criterion used in D’Amico, Bocchi, et al. (2026). The results are shown in Figure 4.6 .
Theoretical comparison. We compare ρ c ( γ ) \rho_c(\gamma) ρ c ( γ ) against the noise tolerance implied by the Gardner capacity [54 ] :
1 γ c ( κ ) = ( 1 + κ 2 ) Φ ( κ ) + κ ϕ ( κ ) , (119) \frac{1}{\gamma_c(\kappa)} = (1 + \kappa^2)\Phi(\kappa) + \kappa\phi(\kappa), \tag*{(119)} γ c ( κ ) 1 = ( 1 + κ 2 ) Φ ( κ ) + κ ϕ ( κ ) , (119)
with Φ \Phi Φ the cumulative distribution function and ϕ \phi ϕ the probability density function of the standard normal distribution, inverted numerically to obtain κ max ( γ ) \kappa_{\max}(\gamma) κ m a x ( γ ) . Here κ \kappa κ is normalized so that a neuron’s pre-activation has unit variance under random patterns, i.e. κ \kappa κ is a signal-to-noise ratio (a z z z -score). Corrupting a fraction ρ \rho ρ of the N N N inputs perturbs the pre-activation by a sum of ρ N \rho N ρN independent random contributions, which by the central limit theorem has standard deviation ∼ 2 ρ \sim2\sqrt{\rho} ∼ 2 ρ . A stored pattern with margin κ \kappa κ therefore remains a fixed point as long as the injected noise does not exceed the margin, i.e. κ > 2 ρ \kappa> 2\sqrt{\rho} κ > 2 ρ . This gives a closed-form, margin-derived lower bound on basin size, which we plot alongside the measured ρ c ( γ ) \rho_c(\gamma) ρ c ( γ ) .
Slow convergence to κ max \kappa_{\max} κ m a x . In practice, the margin actually achieved by finite-time training, κ a c h i e v e d ( γ ) \kappa_{\mathrm{achieved}}(\gamma) κ achieved ( γ ) , undershoots the asymptotic optimum κ max ( γ ) \kappa_{\max}(\gamma) κ m a x ( γ ) , since convergence to the max-margin direction under logistic loss is logarithmic in training time ([148 ] ), a phenomenon also reported in D’Amico, Bocchi, et al. (2026). We therefore report both curves: the lower bound computed from the idealized κ max ( γ ) \kappa_{\max}(\gamma) κ m a x ( γ ) , and the one computed from the empirically achieved κ a c h i e v e d ( γ ) \kappa_{\mathrm{achieved}}(\gamma) κ achieved ( γ ) , which is the fair comparison for a network trained for a finite number of steps.
Result. Figure 4.6 shows that the measured basin size lies consistently above the bound derived from κ a c h i e v e d ( γ ) \kappa_{\mathrm{achieved}}(\gamma) κ achieved ( γ ) at every load tested, confirming that the margin does provide a quantitative guarantee on basin size. This directly supports the mechanism claimed in § 5.3 : maximizing the margin is sufficient to produce basins of attraction of predictable size.
Additional Results
This section collects additional results supporting § 5.5 . Figure 4.7 shows the average conditional entropy of training and synthetic sequences as a function of the training set size.
Shrinkage and Expansion of Basins
Figure 4.8 extends Figure 4.1 to all three model sizes, showing the total token recovery rates of training and test sequences across corruption levels and training set sizes.
Figure 4.8. Shrinkage and expansion of training and test samples’ basins of attraction during the memorization-to-generalization transition for various UDDM sizes. Total token recovery rates (%), including non-corrupt and corrupted, are shown across varying levels of corruption for training sequences (left column) and unseen test samples (right column), with the Tiny (∼ \sim ∼ 24M), Small (∼ \sim ∼ 135M), and Medium (∼ \sim ∼ 384M) models in the top, middle, and bottom rows, respectively. The color gradient represents the fraction of the training dataset used, ranging from small to large. As the training dataset grows, the recovery rate for training examples diminishes, reflecting a shrinkage in the basins of attraction around explicitly memorized points. Simultaneously, the recovery rate for unseen test samples improves, demonstrating an expansion of the basins of attraction around novel examples within the broader data distribution. The convergence of these recovery rates at large dataset sizes (red curves) signifies that unseen test samples have effectively become stable attractors, marking the shift from pure memorization to generalization.
Visualizations of Text Recovery Examples
Figure 4.9 and Figure 4.10 show textual examples of token recovery from perturbed training and test sequences, respectively, using the stochastic reverse process.
Conditional Entropy Histograms
Figure 4.11 –Figure 4.13 show the token-level conditional entropy of recovered and unrecovered tokens, and Figure 4.14 –Figure 4.16 show the sequence-level conditional entropy of training and synthetic sequences, for all fractions of the training set and all model sizes. Figure 4.17 combines the token recovery rates of Figure 4.2 with the perplexity of Figure 4.3 .
Figure 4.12. An illustration of the density of conditional entropy for two categories of tokens, recovered and unrecovered, computed at t = 0.25 t = 0.25 t = 0.25 for the Small model. The subplots are ordered by the fraction of training dataset, ranging from 10 − 4 10^{-4} 1 0 − 4 (top-left) to 1.0 (bottom-right). As the fraction of training data increases, recovered tokens concentrate near zero entropy (high confidence), while unrecovered tokens exhibit a broad distribution at higher entropy.
Figure 4.15. An illustration of the evolution of the density of the average conditional entropy for the probabilities of training and synthetic sequences respectively, computed at t = 10 − 5 t = 10^{-5} t = 1 0 − 5 using the Small models, as the training dataset size grows. When the fraction of training set is small, there exists a separation in the average conditional entropies of training and synthetic samples. However, as the training dataset size grows, this separation is reduced and the conditional entropy of synthetic samples becomes similar to that of the training samples.
Conclusion and Future Directions
This thesis began with a question that can be asked of every sample a generative model produces, namely whether that sample is recalled from the training data or created anew. We have argued that Associative Memory offers a common language for both answers. Memory recall and creativity (or generalization) are not two separate mechanisms but two regimes of the same dynamics, distinguished by the geometry of the basins of attraction formed around the data during training. In this chapter, we summarize how the preceding chapters address the questions posed in § 2.5 , and we then outline the directions that we believe follow most naturally from this perspective.
Summary of Findings
Generation as a Failure in Memory Recall. Chapter 3 interpreted continuous diffusion models as DenseAMs, in which training writes data into memory and generation attempts to recall it, and showed that their behavior follows the predictions of DenseAM theory. With a small training set, recall succeeds. Each training sample acts as an attractor with its own basin, and the model reproduces what it has seen. As the training set grows beyond the capacity of the model, recall begins to fail. The basins around individual training samples shrink, and the dynamics settle into new attractors that belong to no single training sample. This failure is where generation begins. At the onset of the transition, we found spurious states, samples with sizable basins of attraction that do not correspond to any training sample, as DenseAM theory predicts. Long regarded as a defect of memory, they are, in our interpretation, the first signs of generative capability, and they mark the onset of generalization, although we do not show that they cause it. The ordering of basin volume and energy curvature across memorized, spurious, and generalized samples held across a two-dimensional toy model, several natural image datasets, and multiple architectures, and a small case study of Stable Diffusion found a similar ordering of energy curvature among candidate memorized, spurious, and generalized samples.
Measurement of Memorization and Generalization. AM theory also provides quantities that describe memorization and generalization through the geometry of basins of attraction, rather than only through how closely a sample resembles a training data point. In Chapter 3, memorized, spurious, and generalized samples were first identified by comparing each generated sample with its nearest neighbors in the training set and in a larger set of generated samples. Once identified, the three sample types were characterized by the volume of their basins of attraction and by the curvature of the energy around them, which follow a largely consistent ordering across datasets and architectures. Because the curvature is computed from the trained model alone, it points toward diagnostics that could flag spurious states, and therefore the onset of generalization, without a nearest-neighbor search over the training set, although developing such a diagnostic remains future work. In language diffusion models, studied in Chapter 4, token recovery rates measure how reliably the model returns to a reference sequence after corruption, and therefore require the training and test sequences themselves. Conditional entropy, in contrast, is read directly from the predictions of the model and can be computed for any sequence, including generated ones. It locates a model along the transition, agrees with perplexity measured by an external critic model, and separates recovered tokens, which have near-zero entropy, from unrecovered ones within the same sequence. In both domains, larger models delay the transition and require more data before they generalize.
Associative Memory Can Be Enabled via Conditional Likelihood Maximization. Building on prior work showing that maximizing the conditional likelihood of each variable given the others can form basins of attraction without an energy function [34 ] , Chapter 4 brought this view to language diffusion models. In a simplified setting of binary variables, this objective yields a Hebbian term that stores the data and a penalty term that concentrates learning on the variables with the smallest classification margins, so that the training data become attractors without symmetric couplings or a global energy function. Uniform-state discrete diffusion models share this conditional-likelihood structure through the cross-entropy terms of their training objective, and empirically they display the retrieval behavior expected of an AM. They undergo a sharp memorization-to-generalization transition governed by the size of the training set, in which basins around training sequences shrink while basins, at least partial ones, form and expand around unseen test sequences, until both are recovered from corruption at the same rate.
Coexistence of Memorizing and Generalizing. Taken together, these results suggest an answer to the central question of this thesis. Memorization and generalization appear to be better understood as local properties of individual attractors than as global properties of a model, which is what allows them to coexist. A single model can hold sharp basins around some data points and broader, flatter basins around novel samples at the same time. In images, spurious states occupy the boundary between the two. In language, generated sequences in the generalization regime still contain a fraction of highly stable, low-entropy tokens, which may act as small pieces of recall embedded in an otherwise novel output. The balance between the two is governed largely by the size of the training set relative to the capacity of the model, mirroring the role of the load in classical AMs.
Future Directions
The perspective developed in this thesis treats a generative model as a memory whose geometry can be measured. We see three directions in which this view can be extended, and a fourth in which it becomes a principle for building models rather than only explaining them.
Scaling laws through the lens of capacity. Neural scaling laws describe how the loss of a model improves as a power law in the number of parameters, the amount of data, and the available compute [87 , 72 ] . These laws are largely empirical, and they say little about what a model does with the data it sees. The capacity of an AM offers a complementary and mechanistic quantity. In both Chapter 3 and Chapter 4, the training set size at which a model leaves the memorization regime grows with the size of the model, although only a few model sizes were studied. A natural next step is to measure this critical size systematically across model sizes, data modalities, and training budgets, and to ask whether it follows a law of its own. Such a law would describe not only how much a model improves with scale but also when it stops reproducing its training data, which matters for privacy and copyright as much as for sample quality. A promising starting point is the recent finding that the implicit bias of gradient-based training produces scaling laws along the entire learning curve, not only at convergence [35 ] . In a single-layer perceptron trained with the logistic loss, the same margin-maximizing bias that forms basins of attraction in Chapter 4 gives rise to dynamical scaling laws in norm-based complexity measures. Combined, these laws recover the familiar scaling of the test error at convergence, and they hold for convolutional networks, residual networks, and vision transformers. Because the simplified AM of Chapter 4 is a collection of such perceptrons, one for each variable, this result offers a path toward scaling laws derived directly from AM theory, relating the growth of the classification margins to the size of the basins and to the location of the transition. Other recent work has connected scaling behavior to the statistics of natural data [24 ] and to associative memory [116 ] . Probes that are computed from the model itself, such as energy curvature and conditional entropy, could make the transition point observable during training.
Alternative learning algorithms for energy-based modeling. Training an energy-based model by maximum likelihood requires the gradient of the log partition function, an expectation under the model that is intractable in high dimensions. Most existing algorithms are ways of approximating or avoiding this term. Contrastive divergence and its persistent variant estimate it with short Markov chains started at or near the data [68 , 151 ] , but the resulting gradients are biased, the chains can mix slowly, and training can become unstable [145 ] (Du et al. 2021). Score matching and its denoising and sliced variants avoid the partition function by matching the gradient of the log density instead [79 , 158 , 144 ] , and noise-contrastive estimation recasts density estimation as classification against a known noise distribution [63 ] . Diffusion models can be viewed as energy-based models trained in this way, with denoising score matching at many noise levels § 3.3.4 . Pseudo-likelihood [17 ] , which Chapter 4 connected to Hebbian learning and margin maximization, is another alternative, since each conditional probability is normalized locally. Each of these objectives shapes the energy landscape differently, and therefore the basins of attraction that determine whether a model memorizes or generalizes, yet they are usually compared only through sample quality or likelihood. In recent work, we showed that for DenseAMs with translation-invariant kernel energies the partition function does not depend on the memories, so maximum likelihood reduces exactly to minimizing the energy of the data [120 ] . This yields a sampling-free training rule, reminiscent of Hebbian learning, that preserves an explicit energy and extends to the latent space of an autoencoder. We are interested in extending such sampling-free rules to broader classes of energy functions, in comparing the objectives above through the geometry of the basins they produce, and in local learning rules, such as equilibrium propagation [134 ] and competitive Hebbian learning [103 ] , that train energy-based networks without backpropagating through the retrieval dynamics. An objective that controls where the memorization-to-generalization transition occurs would turn the analysis of this thesis into a design tool.
Test-time scaling and recursive computation. Retrieval in an AM is an iterative computation. A state is refined step by step until it settles into an attractor, and running the dynamics for longer is a way of spending more compute at inference. This connects AMs to a growing line of work on test-time scaling, in which a model improves by allocating more computation to each input rather than more parameters [139 ] . Diffusion models already scale at inference through the number of denoising steps and through search over the initial noise (Ma et al., 2025). Recursive architectures go further by applying the same block many times, from universal transformers [36 ] and deep equilibrium models [15 ] to recurrent-depth language models [56 ] and small recursive reasoning networks [161 , 82 ] . Energy-based formulations of this idea treat inference itself as the optimization of a learned energy [59 ] (Du et al. 2024). The AM perspective raises questions that, to our knowledge, remain open. In terms of basins, an additional step of computation may pull a state deeper into a memorized attractor, or it may move the state along the flat directions that Chapter 4 associated with generalization. Spurious states, which sit at the boundary between recall and creation, might be reached or avoided by controlling the length of the dynamics. Understanding these effects would connect the geometry studied here with the way models reason at test time.
Alternative architectures. The transformer [156 ] is built from four operations, namely attention, a feed-forward network, residual connections, and layer normalization, which are combined in a sequence of independent blocks. The way these operations are combined has been established largely through empirical search, and the principles that should govern it remain unclear. The AM perspective suggests a different starting point, in which an architecture is derived from an energy function chosen for the task, and the forward pass is the dynamics that minimizes this energy. The observation that attention is the update rule of a DenseAM with a softmax activation [123 ] , and the construction of hierarchical AMs whose neurons and layers are all described by one energy [98 ] , are steps in this direction. Architectures of this kind are recursive by construction, since the same dynamics is applied until it converges, and their energy can make the basins of attraction studied in this thesis directly accessible.
The Energy Transformer [73 ] is an example of this approach. Instead of a stack of feed-forward transformer blocks, it uses a single block that is applied recurrently. Each token is treated as a particle whose state evolves under a global energy with two contributions. The first is an energy-based attention, which aligns the queries of each token with the keys of the tokens it should attend to, so that information flows between tokens. The second is a Hopfield network module, which stores patterns in its weights and pulls each token toward configurations that are consistent with the data. Layer normalization arises as the derivative of a Lagrangian, and the two energy terms act in parallel rather than in sequence. Because every update decreases the energy, the forward pass is a retrieval dynamics whose fixed point is the output of the model. In masked image completion, for instance, the fixed point is a plausible reconstruction of the occluded patches. Requiring a global energy also constrains the architecture in an informative way. The resulting attention contains the conventional attention update together with an additional term that guarantees the decrease of the energy, and it needs no separate value matrix. The Energy Transformer was competitive on image completion, graph anomaly detection, and graph classification, and in the image domain it used far fewer parameters than a standard vision transformer or a weight-sharing variant of it. The results of Chapter 4 also suggest how such architectures could be trained and probed. Because the energy of the Energy Transformer defines a conditional distribution for each token given the others, the model could be trained by maximizing these conditionals directly, in the spirit of pseudo-likelihood [17 ] , rather than by backpropagating through every step of the energy descent. For discrete tokens, each conditional is normalized over the vocabulary, so no negative sampling would be required. The same conditionals also give the conditional entropy of each token, which could signal when the dynamics has settled into a basin. Studying when such architectures memorize and when they generalize, how their recursive dynamics behave as test-time compute grows, and how they can be trained with the learning algorithms discussed above would help close the loop between explaining generative models and building them.
Closing Remarks
Memorization is often treated as a flaw of generative models and generalization as their goal. The view developed in this thesis is that both are expressions of the same mechanism – the formation of basins of attraction – and that a model need not be in one regime alone. Associative Memory, an idea that emerged from physics and the concept of energy, provides the language to describe this mechanism, and, as Chapter 4 and prior work suggest, it does not require an energy function to apply. We hope that this view helps explain why generative models both remember and create, and that it guides the design of models whose balance between the two can be understood and controlled.
REFERENCES