Abstract
Inspired by striking advances in language modeling, there has recently been much interest in developing autogressive sequence models that are amenable to analytical study. In this short note, we consider extensions of simple disordered kinetic glass models from statistical physics. These models have tunable correlations, are easy to sample, and can be solved exactly when the state space dimension is large. In particular, we give an expository derivation of the dynamical mean field theories that describe their asymptotic statistics. We therefore propose that they constitute an interesting set of toy models for autoregressive sequence generation, in which one might study learning dynamics.
Keywords: sequence modeling, dynamical mean field theory, kinetic Ising model
1. Introduction
There has recently been substantial interest in autoregressive sequence modeling, i.e. in models for probability distributions of the form for some tokens st and a context length K, as modern large language models (LLMs) are fundamentally of this form [1–3]. Given the striking capabilities of such models, developing a theoretical understanding of how those abilities depend on data structure and model architecture is a pressing goal. From the perspective of the statistical physics of learning, we would like to devise a setting in which we could study how a ‘student’ model learns to imitate sequences generated by a ‘teacher’ of similar architecture [4, 5]. The key challenge is to formulate an interesting yet analytically tractable class of models for distributions of this form. Recent work by Rende et al [6] has shown that a modified Potts model is a suitable candidate for a teacher in the context of masked sequence modeling, but the autoregressive setting is still open.
What are the desiderata that a candidate toy autoregressive sequence model should satisfy? We propose that such a model should be analytically tractable, at least in some limits, be easy to sample numerically, display interesting statistical properties, e.g. tunable temporal correlations, and resemble ‘real-world’ sequence models, either in its structure or in its statistical properties. In this note, we take inspiration from statistical physics [7–10], to propose a simple model satisfying these four desiderata.
2. Inspiration: the kinetic Sherrington–Kirkpatrick (kSK) model
From a physical perspective, a natural starting point is the fully asymmetric kSK model. The kSK model is a Markov chain on with
for an inverse temperature β > 0 and a quenched random interaction matrix J with i.i.d. Gaussian elements . For simplicity, we will focus on the ‘pure’ SK case, where the interactions have mean zero and there is no external magnetic field to bias the state distribution.
After being studied by Crisanti and Sompolinsky [7, 8] in the late 1980 s for various continuous-time dynamics, the discrete-time version of the kSK model has recently emerged as a paradigmatic model for the thermodynamics of nonequilibrium complex systems [9, 10]. Moreover, Bal [11] has observed in a series of blog posts that the kSK model bears a strong structural resemblance to the Attention mechanism used in modern autoregressive language models. At large N the kSK model is amenable to solution by mean-field techniques, and it is easy to sample thanks to the fact that the sites are conditionally independent given the local field , i.e. we have the factorization
However, this model is insufficient for our purposes, because it exhibits single-step decorrelation, i.e. for all times t, where denotes averaging over the random process for some fixed initial condition s0 and a fixed realization of J for a quantity depending on times up to T. This decorrelation follows from a simple symmetry argument. Concretely, we observe that the transformation for t odd, for t even, and leaves the combined measure in invariant for any fixed s0. This implies immediately that for any odd t, and that whenever t and t′ have opposite parity. The reason for the structure of this transformation is that the s0-dependent term in the measure is invariant under flipping the sign of J only if s1 is also negated. This argument implies that one always has one-step decorrelation for this model, i.e. . Single-step decorrelation could be avoided by adding a positive mean to J, so as to encourage alignment between st and , but this does not yield flexibly tunable temporal correlations [10]. We will therefore pursue an alternative approach.
3. Construction of the model
We now introduce the three classes of extended-context models we consider in this work. Consider an N-dimensional state space , which we conceptualize as representing the token embedding space of a sequence model. We will take N to be large, consistent with the use of embedding spaces of dimension greater than 10 000 in modern sequence models [2]. Equip with a (possibly un-normalized) probability measure σN that is reflection-symmetric, i.e. invariant under for all . We consider three models:
-
1.
Ising: with σN the uniform counting measure.
-
2.
Gaussian: with and σN the standard Gaussian measure
-
3.
Spherical: and σN the uniform probability measure on the sphere.
Define a Markov chain of order K on by the transition probabilities with density
with respect to σN, for an inverse temperature β > 0 and an energy function
for a set of interaction matrices . Again, we write for the average over the random process for some fixed initial sequence , i.e. for a quantity depending on times up to T, we have
We generalize the fully asymmetric kSK model by taking the interaction matrices Jk to be jointly Gaussian, with zero mean. As a concrete model, we will focus on the case in which the interactions are uncorrelated across sites but possibly correlated across lags, i.e.
for some correlation matrix 3. Our objective is to study the resulting ensemble of random dynamical systems with quenched disorder.
For any context length, all of these models are easy to sample from numerically. In the Ising case, as for the simple kinetic SK model, we have independence of sites conditioned on the local field, as for . In the Gaussian case, we have up to normalization, so here again sites are independent conditioned on the local field. In the spherical case, we see immediately from the expression that, conditioned on the context, st follows a von Mises–Fisher distribution with mean direction and concentration parameter on the N-sphere of radius . This is easy to sample using standard algorithms [13]. Therefore, all three models satisfy the desideratum of efficient sampling.
4. Dynamical mean-field theory
We now turn to the questions of whether these models are analytically tractable, and if they display interesting statistical behavior. In the limit where for fixed T and K, the asymptotic statistics of these models are easy to characterize using standard dynamical field theory (DMFT) approaches from the statistical physics of disordered systems. In particular, we consider the generating function
As usual [7, 8], the fact that for any implies that the generating function can be averaged directly over the quenched disorder to obtain , from which we can immediately compute quenched moments, e.g. .
In the Appendices, we give an expository derivation of the DMFT equations for each variant of the models we consider. For all three models, the DMFT order parameter is the self-averaging two-point function
in terms of which the effective single-site distribution is self-consistently determined. In the Ising-like and spherical models, the Cauchy–Schwarz inequality and triangle inequality together imply that , while in the Gaussian case boundedness is not guaranteed. For all three models, for , is entirely fixed by the initial condition as , while for and we have . For brevity, let
We can now state the results of the DMFT analysis.
4.1. Do we need correlated weights?
Before presenting the details of the DMFT descriptions of each variant of the model at hand, we briefly address the question of what we gain from introducing correlations to the interaction distribution, as the answer for all three model types is the same. In all variants of the model, the DMFT is a causal iterative equation for , with all dependence on previous times being through as defined in (9). We are interested mostly in the long-time properties of these DMFTs, particularly when they admit stationary solutions of the form at long times . A natural question at this point is whether we really need correlations in weights across lags to get a non-trivial stationary state, i.e. whether we could take and get interesting non-vanishing temporal correlation at long times. As anticipated by the fact that we included correlations in the setup, the answer to this question is no. With , we have . Under the assumption of stationarity, , hence . This shows that correlations across lags are required to obtain non-trivial stationary correlations. We demonstrate this for a few arbitrarily-chosen example choices of in figures 1–5, which also show that the DMFT predictions are accurate.
Figure 1.
Simulation of an Ising-like model with and K = 25, with N = 5000. (a). State st over time. Times before t = 0 represent the initial condition, which is chosen arbitrarily. (b). Slices through the DMFT autocorrelation function across time for varying lags k, showing that the DMFT accurately predicts the empirically-measured correlation from a single simulation. The expectation in the DMFT equations is numerically evaluated using 50-point Gauss-Hermite quadrature. We see that autocorrelations at all non-zero lags decay over time. (c). The DMFT autocorrelation function from a single numerical simulation for which the slices are shown at top right. (d). The corresponding DMFT prediction for the autocorrelation function.
Figure 5.
Simulations of a spherical model with for r = 0.25 and K = 25. Here, β = 1. The top row shows heatmaps of the empirical (a) and DMFT (b) correlation functions . The bottom row shows slices through the correlation functions (c).
Figure 4.
Simulations of a spherical model with for r = 0.25 and K = 25. Here, β = 1. The top row shows heatmaps of the empirical (a) and DMFT (b) correlation functions . The bottom row shows slices through the correlation functions (c).
4.2. Ising
In the Ising case, we show in appendix A that the DMFT equation is
for distinct times and . Given the fact that depends on the covariance only at previous timesteps (9), this recurrence can easily be numerically solved forward in time. The only bottleneck is numerical evaluation of the expectation, which can be performed easily using Gauss-Hermite quadrature, at least at high temperatures (see figures 1 and 2). Here, the single-site generating function is
for , which describes an Ising system in a self-consistently determined field.
Figure 2.
As in figure 1, but for an Ising-type model with correlated weights for r = 0.1. Unlike for uncorrelated wights in figure 1, the autocorrelation does not decay to zero over time.
4.3. Gaussian
In the Gaussian case, we show in appendix B that we have the DMFT equation
for . For the Gaussian model, the single-site generating functions are simply
Again, the causal structure means that the DMFT can be solved forward in time. However, this is now a linear system, which allows greater analytical tractability. That said, the Gaussian model is potentially unstable: if the inverse temperature β is too large then the equal-time correlations grow exponentially with time (figure 3). We will return to this issue, and to sufficient conditions for stability, in section 5.
Figure 3.
Simulations of a Gaussian model with for r = 0.1 and K = 4. Here, β = 0.5. The top row shows heatmaps of the normalized empirical (a) and DMFT (b) correlation functions . The bottom row shows the exponential growth of (c) and slices through the normalized correlation functions (d).
4.4. Spherical
The development of the DMFT for the spherical model is somewhat more complicated than that for the Ising and Gaussian models due to the global constraint on the norm of the state vector. We show in appendix C how one can derive DMFT equations for this model by applying the replica trick to the normalization terms in the sequence distribution at each timestep. This leads to a DMFT in terms of and a set of positive scalars Qt, where satisfies the recursive equation
for , and Qt is determined by the self-consistency condition . One finds that the single-site generating functions are in this case , meaning that the fluctuations are Gaussian. These equations are naturally solved via fixed point iteration. For a fixed Qt, this is a linear recurrence for which can be solved forward in time. Then, we can compute Qt from the given using the constraint . Physically, the scalars Qt are up to a shift the Lagrange multipliers that enforce the norm constraint.
5. Stationary solutions for translation-invariant correlations
As uncorrelated weights do not suffice, we now consider whether we can make analytical progress in solving the DMFT equations in the stationary state for translation-invariant correlations of the form
By symmetry, we of course have , where . With this choice, writing and , we have
In the Gaussian and spherical cases, this means that the DMFT equations become a linear convolution equation for :
In the Gaussian case, the variable q in (17) is fixed to q = 1. In the spherical case, we should have assuming stationarity, and we must determine q by imposing the self-consistency condition on the solution to (17).
The fact that this equation is linear makes the Gaussian and spherical models more amenable to analytical study than their Ising-type counterpart. In particular, this is a banded symmetric Toeplitz system for cτ, which we can solve using the z-transform. Before studying the solutions to (17), we remark that we may define the inverse temperature β such that . Then, noting that if β = 0 we have , in this limit we should have q = 1. This will allow us to sanity-check our general solution.
5.1. Warm-up: solution for K = 1
As a warm-up, if K = 1, then (17) reduces to
which has solution
In the Gaussian case, this equation is stable if β < 1. In the spherical case, imposing the condition that , we find that . Together, this recovers our previous result that with K = 1 there must be single-step decorrelation.
5.2. Stationary solutions for K > 1
For K > 1, taking a z-transform
for leads to the equation
which has formal solution
using the fact that . Then, we can formally obtain the solution cτ by taking the inverse transform:
We can see that, if the denominator of (24) does not vanish, then the system will be stable in the sense that for all τ. In the spherical case, this stability condition is satisfied thanks to the fact that q must be self-consistently determined so as to make the system stable. In the Gaussian case, where q = 1, we must check that β and are chosen so as to make the system stable. By the triangle inequality, a sufficient condition for stability is that
where we recall that we have defined β2 such that . One interpretation of this condition is that it gives a conservative estimate of the maximum inverse temperature allowed in the Gaussian model:
If the temperature is too low, the norm of the state vector may diverge, as shown in the example of figure 3. There, K = 25 and , so . Thus, the crude estimate above indicates that is sufficient to ensure stability; in figure 3 we used β = 1, which evidently exceeds the stability threshold.
For general context lengths K > 1 and correlations , the integral (24) cannot be evaluated in closed form. If K = 1, then is constant, and we recover (19). If K = 2, we can make progress because (24) reduces to the arcsine distribution integral
where
Assuming , we can explicitly evaluate the integral to obtain
In the Gaussian case, upon fixing q = 1 we are done. We must only verify that the parameters are chosen such that the system is stable, which requires that and that such that . This means that we must have
such that and such that the weight covariance matrix is positive definite. This threshold is consistent with the sufficient condition for stability that we found above.
In the spherical case, we can use the condition to solve for
where we use the condition that to select the appropriate solution. This leads to a value of
which satisfies , and the simplified form
Thus, with a two-step context, we now have exponentially-fast decorrelation with a length scale determined by the correlation strength and temperature.
5.3. Reverse-engineering weight correlations to achieve a desired stationary correlation
Instead of choosing and trying to figure out the resulting autocorrelation cτ, we can choose a desired stationary autocorrelation cτ and try to reverse-engineer the required correlations . The latter strategy is more in keeping with the overall goal of this note, which is to design a simple data model with tunable correlations.
We start by re-writing the -space equation for the stationary autocorrelation in a spherical model as
where we assume that . Then, we can use the orthogonality of the Fourier modes to extract
In this, we have two degrees of freedom: our choice of q, and that of β. These parameters are constrained by self-consistency conditions, including the fact that we must have . Moreover, K must be large enough so that all relevant Fourier modes are captured.
For example, suppose that we want to have autocorrelations that decay exponentially with some rate λ > 0:
Then, by evaluating (35) we find that we should take K = 2, and
Here, we must clearly choose , so that Γ0 is positive.
But, we can compare this with our previous solution of the self-consistent equation for K = 2. There we set the temperature such that , which means we should take
Substituting these values into (32), we find that for any , which leads to an autocorrelation
Thus, provided that we choose q appropriately, everything is self-consistent.
6. Conclusions
We have analyzed the dynamics of a class of vector spin models generalizing the disordered kinetic Ising model, showing the minimal conditions required to obtain non-trivial correlation structure in the stationary state. Our note is a preliminary step towards an analyses of teacher-student learning in these toy autoregressive sequence models [4]. Moreover, the DMFT equations derived here may be of independent interest in the context of nonequilibrium dynamics [14], as they generalize those derived for single-step context (K = 1) models in prior works [9–11].
Acknowledgments
We thank Blake Bordelon for helpful comments on a previous version of this note.
Appendix A. Ising DMFT
Here we give a detailed derivation of the DMFT in the Ising case.
A.1. Averaging over the disorder
We have the quenched generating function
Under the assumption that the interaction matrices are jointly Gaussian, the local fields
are jointly Gaussian under the distribution of the disorder, and have mean zero at all times. With the specific assumption that
their covariance is
where we define the temporal correlation function of the state:
As the states are binary, we have
at all times.
A.2. Introducing order parameters
We now follow the standard procedure of introducing the correlation functions as order parameters. We enforce the definition of via Fourier representations of the δ-distribution with Lagrange multipliers , writing
where the integral over C is taken over real symmetric matrices with diagonal elements identically equal to one and the integral over is taken over imaginary symmetric matrices with diagonal elements identically equal to zero. We absorb the factors of 2π required to normalize the δ-distribution into the measure .
We then have
As the fields are independent and identically distributed across sites j, we have the factorization
where we have defined the single-site generating functions
This yields
where
At this point, all site-specific dependence is through the initial conditions, which appear in the single-site term multiplying , and through the sources. As a result, the integrals over the order parameters and Lagrange multipliers should be amenable to saddle-point evaluation at large N.
A.3. The saddle-point equations
We can now determine the saddle-point equations. From , we have the self-consistent equation
for any two distinct times . Here, the single-site average is defined via
One must be a bit careful when considering boundary terms for which t or t′ is less than or equal to zero, as the boundary states are deterministic and fixed by the initial condition. For , is entirely fixed by the boundary condition as
Now suppose that and . Then, is fixed by the initial condition, and we have
Our remaining task is to determine the Lagrange multipliers , recalling that by definition. We first remark that the solution
for all is consistent with the normalization condition Z = 1 when b = 0, as we then have
and , which yields .
To show this more carefully, we consider the saddle-point equation , which gives
for any two distinct times , where we recall that we have constrained to be symmetric, which compensates for the factor of 1/2. All of the dependence on in zj is contained in the covariance of hj, which for any is
Then, for any times and any two distinct times , we have
so
We can evaluate the required derivatives of expectations using Price’s theorem [15]. However, we must be careful to account for the fact that t + k and might coincide. First, for any distinct times , we have
Second, we have the equal-time derivatives
Putting these results together and using the definition of the single-site average, we find that for any
in terms of which we have
for any two distinct times . We emphasize that thanks to the constraint on the sum over k and k′, the right-hand-side of this equation does not depend directly on the initial condition; all of the fields that appear are at times greater than or equal to 1.
Then, to show that the solution is self-consistent, we would like to show that the expectations listed above vanish under that assumption. To do so, we will simplify the single-site generating function
and the resulting single-site averages using a Hubbard-Stratonovich transformation. Noting that by construction, we multiply and divide by
for a positive real regulating parameter ρ, which gives
Then, letting be a mean-zero Gaussian field with covariance
we have
Then, for any two distinct positive times , we have
and
Examining these results, if , then the correlations between different vanish, and we can evaluate all of the expectations over the then independent variables using the identity
In particular, all of the dependence on the regulator ρ drops out—as should happen as it is arbitrary—and we can see that we will then have
and
for any two distinct times .
Therefore, for any two distinct times , we have
We now turn our attention to the term
As is binary, we have
Using the result above, we may write
From this, and following the logic above for how to evaluate the expectation over when , we have
thanks to the identity .
Therefore, we conclude that for any two times , whether equal or not, we have
Thus, as the saddle-point equation for is
we find that the solution
is self-consistent, as suggested by the normalization of the generating function.
Moreover, with the single-site generating function simplifies to
and the single-site averages simplify accordingly. In particular, for any two distinct times , we now have
as the single-site average is now manifestly site-independent. As noted previously, for , is entirely fixed by the boundary condition as
Finally, for mixed boundary-bulk correlators with and , we have
A.4. Summarizing the DMFT
In summary, we have derived a DMFT for the temporal correlation of the state, defined by the self-consistent equation
for distinct times and , where ht is a zero-mean Gaussian with covariance
For , is entirely fixed by the initial condition as
while if and .
Appendix B. Gaussian DMFT
We now consider the Gaussian model. Here, we fix a prior over states
which in the large-N limit will give a concentrating norm . Writing the local field at time t as
the normalization factor at that time is then
which of course factorizes over sites. We can then write the single-step transition density as
hence the density with respect to Lebesgue measure simply becomes
B.1. Averaging over the disorder
With this setup, the quenched generating function is
As in the Ising case, with the specific assumption that the interaction matrices are zero-mean Gaussian with covariance
the local fields are zero-mean Gaussian with covariance
where we define the temporal correlation function of the state:
However, in this case the norm of the state is not fixed to unity.
B.2. Introducing order parameters
Again, we enforce the definition of via Fourier representations of the δ-distribution with Lagrange multipliers , writing
where in this case we include the diagonal elements of and . Then, everything factors over sites, yielding
where
for single-site generating functions
B.3. The saddle-point equations
We can now determine the saddle-point equations. From , we have the self-consistent equation
for any two (non necessarily distinct) times . Here, the self-consistent average is defined via
Again, one must be careful when considering boundary terms for which t or t′ is less than or equal to zero, as the boundary states are fixed by the initial condition. For , is entirely fixed by the boundary condition as
Now suppose that and . Then, is fixed by the initial condition, and we have
We now consider . As in the Ising case, it is easily seen that having for all times is consistent with the normalization, as we then have
As we did in the Ising case, we can show this in greater detail by considering the saddle-point equation , which yields
for and
for , where the factor of 1/2 is not present in the off-diagonal terms due to symmetry. Again, writing
we have
Applying Price’s theorem [15], we have for any two distinct times
while the equal-time derivatives are
Then, using the definition of the single-site average, we have
for any two distinct times , while
for any time . Thus, as the saddle-point equation gives as a convex combination of these derivatives, to show that it is self-consistent to have we would like to show that these averages vanish under that assumption. Unlike in the Ising case, this is easily done thanks to the fact that and are jointly Gaussian even for non-vanishing . Recalling the definition of the single-site average as
we expand the term involving as
The term that depends only on the boundary conditions will cancel in the ratio, which leaves
where we define the matrix
and the vector
Completing the square, this implies that the single-site average is computed for
Our task is now to invert the block matrix J. Noting that the push-through identity implies that
the formula for block matrix inversion implies that
where we write
Then, we have
hence
Then, noting that
we can then see that, if for all , we have the single-site averages
From this, it is easy to see that, for ,
while
Therefore, we conclude at last that the solution is consistent with the saddle-point equations, and that under this condition we have
for all interior times , while the boundary terms for and vanish:
More directly, with , the single-site generating function simplifies to
Then, we can immediately read off that the site distribution is zero-mean Gaussian, with the covariance claimed above.
B.4. Summarizing the DMFT
To summarize, the DMFT for the Gaussian model is given by
for ,
for and , and
for .
Unlike in the Ising case, the equation for is now purely linear. We observe that some features of this model cannot carry over to the spherical case, as here may exceed unity.
Appendix C. Spherical DMFT
We now consider the spherical model. Using the notation introduced above, we can read off that the disorder average leads to the quenched generating function
where the local fields
are jointly Gaussian under the distribution of the disorder, and have mean zero at all times. With the specific assumption that
their covariance is
where we define the temporal correlation function of the state:
The spherical constraint means that we have
at all times.
C.1. Introducing order parameters
As for the other two models, we enforce the definition of via Fourier representations of the δ-distribution with Lagrange multipliers , writing
where in this case we include the diagonal elements of and . This yields
Our goal is to factorize
over sites. Given that constant multiplicative factors will cancel thanks to the normalization terms, we can re-write this as
for any positive ρ, as the spherical constraint enforces that for all times t.
At this point, we would like to replace the δ-distributions with their Fourier transforms and interchange the order of integration over the states and Lagrange multipliers, as that would allow us to factor the integral over sites into a product of single-site generating functions. However, the normalizing factor in the denominator means that we cannot proceed so simply. This can be circumvented using the replica trick: we write
More concretely, we introduce copies of the denominator for the tth timestep. As usual, we will proceed for a non-negative integer, and then analytically continue the result. Indexing replicas by , the state-dependent term above becomes
We now replace the δ-distributions with their Fourier transforms, introducing Lagrange multipliers to enforce the constraints and to enforce the constraints . Interchanging the order of integration, this at last allows us to factor the integrals over sites, yielding
for an action
where
are the single-site generating functions.
C.2. The saddle-point equations
Differentiating with respect to for any two (perhaps equal) times , we of course have
Here, the self-consistent average is defined via
As in the Ising and Gaussian cases, one must be careful when considering boundary terms for which t or t′ is less than or equal to zero, as the boundary states are fixed by the initial condition. For , is entirely fixed by the boundary condition as
Now suppose that and . Then, is fixed by the initial condition, and we have
Differentiating with respect to , we have the constraint
while differentiating with respect to , we have
Observing that the auxiliary fields couple to in the same way as , we make a replica-uniform Ansatz for the Lagrange multipliers
Then, the integrals over factor, leaving
We can then see that is consistent with normalization.
To show more carefully that these solutions are consistent, we again turn to the saddle point equation for . As in the Ising and Gaussian cases, this gives
for equal times and
for distinct times . Once again, we write
which gives
Isolating the relevant portion of the single-site generating function, we have for any two distinct times
while the equal-time derivatives are
Using the definition of the single-site average, we then have
for any two distinct times , while
Importantly, in these expectations t and t′ are constrained to be strictly greater than zero.
We can evaluate these expectations using the fact that the single-site distribution of the fields at positive times is in fact Gaussian. We condition on the fields , set , and consider the joint density of the fields and . Defining the matrix
for and the vector
and using the fact that terms depending on for both will drop as they contribute a constant, we have that their joint density is given up to normalization as
We can then see that the replica fields are independent from the fields and are independent across replicas and time, with variance
and mean
Similarly, the fields are Gaussian, with covariance
and mean
Though we can compute the required correlators using these full expressions, we recall that our goal is to show that they vanish provided that and . We will therefore assume that , which yields the drastic simplification
Using these facts, we can easily compute the unequal-time correlators as
for any two distinct times , while the equal-time correlators are
From this, we can see immediately that the replica-uniform Ansatz
gives
and
which vanish as , meaning that the solution is self-consistent in this case.
With , the single-site generating function becomes
Defining the diagonal matrix Q by
we have
where we observe that the Woodbury identity implies that
This gives
for , which as Q is diagonal reduces to
To determine Qt, we use the self-consistency condition
as ρ is arbitrary we can absorb it into the re-definition. Moreover, we have , hence if t > 0 and .
C.3. Summarizing the DMFT
To summarize, for the spherical model we have obtained a DMFT in terms of the two-point functions
and a set of positive scalars Qt, where satisfies the recursive equation
and Qt is determined by the self-consistency condition
These DMFT equations are naturally solved via fixed point iteration. For a fixed Qt, this is a linear recurrence for which can be solved forward in time. Then, we can compute Qt from the given using the constraint . This alternating procedure can be iterated until convergence.
Appendix D. Numerical methods
All simulations were done using MATLAB R2024b (The MathWorks, Natick, MA, USA), and were run on a desktop workstation equipped with an Intel Xeon(R) w5-3525 processor and 128 GB of RAM. They were not compute-intensive, requiring well under one CPU-hour. For the spherical model, we used Sungkyu Jung’s freely available implementation of Wood [13]’s algorithm for sampling from the von Mises-Fisher distribution, available at www.stat.pitt.edu/sungkyu/oldSoftwarePage.html.
Footnotes
As in related random matrix problems [12], one could in principle further generalize the analysis to allow non-trivial correlations between the elements of each row of the interaction matrix Jk—i.e. to replace with some non-diagonal matrix—but here we focus on the minimal setting with spatially uncorrelated interactions.
Data availability statement
No new data were created or analysed in this study.
Funding acknowledgments
At the time of a completion of an initial version of this work in 2023, J.A.Z.-V. and C.P. were supported by NSF Award DMS-2134 157 and NSF CAREER Award IIS-2239 780. At present, J.A.Z.-V. is supported by the Office of the Director of the National Institutes of Health under Award Number DP5OD037354, and by a Junior Fellowship from the Harvard Society of Fellows. C.P. is presently supported by NSF grant DMS-2134 157, NSF CAREER Award IIS-2239 780, DARPA grant DIAL-FP-038, a Sloan Research Fellowship, and The William F. Milton Fund from Harvard University. C.P.’s work is been made possible in part by a gift from the Chan Zuckerberg Initiative Foundation to establish the Kempner Institute for the Study of Natural and Artificial Intelligence.
References
- 1.Radford A, et al. Improving language understanding by generative pre-training. OpenAI preprint. 2018. (available at: https://openai.com/index/language-unsupervised/)
- 2.Brown T, et al. Language models are few-shot learners. In: Larochelle H, Ranzato M, Hadsell R, Balcan M F, Lin H, editors. Advances in Neural Information Processing Systems. vol 33. Curran Associates, Inc.; 2020. pp. pp 1877–901. [Google Scholar]
- 3.OpenAI et al2023GPT-4 technical report (arXiv:2303.08774)
- 4.Engel A, den Broeck C V. Statistical Mechanics of Learning. Cambridge University Press; 2001. [Google Scholar]
- 5.Yue M L, Letey M, Zavatone-Veth J A, Maiti A, Pehlevan C. Asymptotic theory of in-context learning by linear attention. Proc. Natl Acad. Sci. 2025;122:e2502599122. doi: 10.1073/pnas.2502599122. [DOI] [PMC free article] [PubMed] [Google Scholar]
- 6.Rende R, Gerace F, Laio A, Goldt S. Mapping of attention mechanisms to a generalized Potts model. Phys. Rev. Res. 2024;6:023057. doi: 10.1103/PhysRevResearch.6.023057. [DOI] [Google Scholar]
- 7.Crisanti A, Sompolinsky H. Dynamics of spin systems with randomly asymmetric bonds: Langevin dynamics and a spherical model. Phys. Rev. A. 1987;36:4922–39. doi: 10.1103/PhysRevA.36.4922. [DOI] [PubMed] [Google Scholar]
- 8.Crisanti A, Sompolinsky H. Dynamics of spin systems with randomly asymmetric bonds: Ising spins and Glauber dynamics. Phys. Rev. A. 1988;37:4865–74. doi: 10.1103/PhysRevA.37.4865. [DOI] [PubMed] [Google Scholar]
- 9.Miguel Aguilera S A M, Shimazaki H. A unifying framework for mean-field theories of asymmetric kinetic Ising systems. Nat. Commun. 2021;12:1197. doi: 10.1038/s41467-021-20890-5. [DOI] [PMC free article] [PubMed] [Google Scholar]
- 10.Aguilera M, Igarashi M, Shimazaki H. Nonequilibrium thermodynamics of the asymmetric Sherrington-Kirkpatrick model. Nat. Commun. 2023;14:3685. doi: 10.1038/s41467-023-39107-y. [DOI] [PMC free article] [PubMed] [Google Scholar]
- 11.Bal M. Spin-model transformers online blog post. 2023. (available at: https://mcbal.github.io/post/spin-model-transformers/)
- 12.Zavatone-Veth J A, Pehlevan C. Replica method for eigenvalues of real Wishart product matrices. SciPost Phys. Core. 2023;6:026. doi: 10.21468/SciPostPhysCore.6.2.026. [DOI] [Google Scholar]
- 13.Wood A T A. Simulation of the von Mises-Fisher distribution. Commun. Stat. - Simul. Comput. 1994;23:157–64. doi: 10.1080/03610919408813161. [DOI] [Google Scholar]
- 14.Mézard M. Spin glass theory and its new challenge: structured disorder. Indian J. Phys. 2024;98:3757–68. doi: 10.1007/s12648-023-03029-8. [DOI] [Google Scholar]
- 15.Price R. A useful theorem for nonlinear devices having Gaussian inputs. IRE Trans. Inf. Theory. 1958;4:69–72. doi: 10.1109/TIT.1958.1057444. [DOI] [Google Scholar]
Associated Data
This section collects any data citations, data availability statements, or supplementary materials included in this article.
Data Availability Statement
No new data were created or analysed in this study.





