# Mean field sequence: an introduction

This is the first post in a planned series about mean field theory by Dmitry and Lauren (this post was generated by Dmitry with lots of input from Lauren, and a second part should be coming soon). The posts are a combination of an explainer and some original research/ experiments.

The goal of this series is to explain an approach to understanding and interpreting model internals which we informally denote "mean field theory" or MFT. In the literature, the closest matching term is "adaptive mean field theory". We will use the term loosely to denote a rich emerging literature that applies many-body thermodynamic methods to neural net interpretability. It includes work on both Bayesian learning and dynamics (SGD), and work in wider "NNFT" (neural net field theory) contexts. Dmitry's recent post on learning [sparse denoising](https://www.lesswrong.com/posts/siu22scEfuKxpSgfK/a-tale-of-three-theories-sparsity-frustration-and) also heuristically fits into this picture (or more precisely, a small extension of it).

Our team at [Principles of Intelligence](https://princint.ai/) (formerly PIBBSS) believes that this point of view on interpretability remains highly neglected, and should be better understood and these ideas should be used much more in interpretability thinking and tools.

We hope to formulate this theory in a more user-friendly way that can be absorbed and used by interpretability researchers. This particular post is closely related to the paper "[Mitigating the Curse of Detail: Scaling Arguments for Feature Learning and Sample Complexity](https://arxiv.org/abs/2512.04165)". The experiments are new.

What do we mean by mean field theory
====================================

Mean field theory is a vague term with many meanings, but for the first few posts at least we will focus on *adaptive mean field theory* (see for example [this paper](https://www.nature.com/articles/s41467-023-36361-y), written with a physicist audience in mind). It is a theory of infinite-width systems that is different from the more classical (and, as I'll explain below, less expressive) neural tangent kernel formalism and related Gaussian Process contexts.

Ultimately mean field theory is a theory of neurons (which are treated somewhat like particles in a gas). While every single neuron in the theory is a relatively simple object, the neurons in a mean field picture allow for an emergent large-scale structure[^f6m7agmioq] that lets us see complex interactions and circuits in what is a priori a "single-neuron theory". These cryptic phrases will hopefully be better understood as this post (and more generally as this series) progresses.

Why MFT
-------

Ultimately, we want to understand the internals of neural nets to a degree that can robustly (and ideally, in some sense "safely") explain why a neural net makes a particular decision. So one might say that this implies that we should only care about theories that apply directly to real models. Finite width, large depth, etc. While this is fair, any interpretation must ultimately rely on some idealization. When we say "we have interpreted this mechanism", we mean that there is some platonic gadget or idealized model that has a mechanism "that we understand", and the real model's behavior is explained well by this platonic idealization. Thus making progress on interpretability requires accumulating an encyclopedia (or recipe book) of idealizations and simplified models. The famous SAE methodology is based on trying to fit real neural nets into an idealization inherited from [compressed sensing](https://en.wikipedia.org/wiki/Compressed_sensing) (a field of applied math). As we will explain below, if we never had Neel Nanda's interpretation of the modular addition algorithm, we would get it "for free" by [applying a mean field analysis to the related infinite-width model](https://arxiv.org/abs/2310.03789). As it were, the two use the same Platonic idealization[^yxaebc2jkw]. Thus at least one view on the use of theory is to see it as a source of useful models that can be then applied to more realistic settings (with suitable modification, and, at least until a "standard model" theory of interpretability exists, necessarily incompletely). Useful theories should be simple enough to analyse mathematically (maybe with some simplifications, assumptions, etc.) and rich enough to illuminate new structure. We think that mean field theory (and its relatives) is well-positioned to take such a role.

Brief FAQ section
-----------------

"Frequently asked questions about MFT" is a big topic that can be its own post. But before diving into a more technical introduction, we should address a few standard questions which keep cropping up, especially about comparisons between MFT and other better-known infinite-width limits.

1.  **Doesn't infinite width mean that we're in the NTK (or more generally a Gaussian process) regime?** The first analyses of neural nets at infinite width have been in the so-called NTK regime, where in particular the early layers of the model "freeze" to its prior/ initialization and only the last layer learns large-scale structure. This is a remarkably deep picture as is for example [sufficient to learn mnist](https://github.com/IandRover/NTK_MNIST). But approaches in this family exhibit extremely different behaviors from realistic nets (in particular the freezing of early neurons) and they are generalize much worse on problems that cannot be solved by some combination of clustering and linear regression (of which MNIST is an example). For example these methods learn only memorizing circuits in modular addition (at least in known regimes) and, worse, they are known to require exponential training data and complexity for learning algorithms that are well-known to be learnable by SGD (for example the "ladder polynomials" in the [leap complexity paper](https://arxiv.org/abs/2302.11055) by Abbe et al.). this means that these techniques are fundamentally incompatible with these settings (more generally so-called "compositional" models - ones that have multiple serial steps which models tend to need depth for - have similar failures in this regime). This can be partially improved by including so-called "correction terms", but these only work when the Gaussian process has good performance by itself, and fail to ameliorate for the exponential complexity issues. Note that the Gaussian process picture is useful as a heuristic baseline. In particular it makes some predictions on scaling exponents that have some experimental agreement (and is related to the [muP formalism](https://arxiv.org/html/2407.17465v1) by Greg Yang et al.).  
      
    It turns out that the lack of expressivity of the Gaussian limit is due not to its having infinite width to a certain choice of how to take the infinite limit (and in particular how to scale weight regularization terms in the loss). Different limits and scalings give significantly more expressive behaviors as we shall see, and we use MFT as a catch-all term for these. (These different limits are also *harder* in general, at least in terms of exact mathematical analysis: the Gaussian process limit somewhat compensates for its lack of expressivity by having much easier math.)
2.  **Isn't mean field theory only a Bayesian learning theory and doesn't that make it unrealistic?** In physics contexts (like MFT, Gaussian Process learning, etc.) Bayesian learning is often theoretically easier to deal with, and we'll explain Bayesian learning predictions here (validated by tempering experiments). However a version of mean field for SGD learning exists and is called "[Dynamical Mean Field Theory](https://arxiv.org/abs/2304.03408)" (DMFT) by Borderlon and Pehlevan (it extends the NTK in Gaussian process contexts). Probably more relevantly, Bayesian learning experiments frequently find similar structures to gradient-based methods (and are often easier to analyse). This is particularly well demonstrated in empirical results by the [Timaeus](https://timaeus.co/) group.
3.  **Is mean field theory a theory of shallow models?** Most existing papers on mean field theory work in the context of 2-layer neural nets (i.e. 2 linear layers, one nonlinear layer). However there is a fully general, and experimentally robust extension of the theory to a larger number of layers (see for example this [lecture series](https://pehlevan.seas.harvard.edu/sites/g/files/omnuum6471/files/pehlevan/files/princeton_lecture_notes.pdf)), and we will look at such models here. In fact mean field theory can model mechanisms of arbitrary depth - but it works best for shallower models (or for shallow mechanisms in deep models), and would likely be less useful for modeling strongly depth-dependent phenomena.
4.  **What is a success of mean field theory I should know about?** Glad you asked! Most people know about the Modular Addition task, which was first explained mechanistically by Neel Nanda et al.'s [grokking paper](https://arxiv.org/abs/2301.05217). The interpretation is heuristic: it shows that the model exhibits signatures of using a nice and unexpected trigonometric trick. It also interpolates between generalization and memorization in a sudden shift reminiscent of a phase transition. A more ambitious task (that was considered too hard to tackle in the interpretability community) would be to understand exactly what the model learns on a neuron-by-neuron basis in any setting that exhibits generalization/ grokking. Since models have inherent randomness (from initialization, and sometimes from SGD), the task is inherently a statistical one: explain the probability distribution on weights of learned models (at least to a suitable level of precision), and was generally believed to be quite hard. Thus it comes as a surprise to practitioners of interpretability that in fact *there is a context where this is done*.  
      
    In the paper "[Grokking as a First-order Phase Transition in Two Layer Networks](https://arxiv.org/abs/2310.03789)", Rubin, Seroussi and Ringel constructed a complete explanation (experimentally verified to extremely high precision) for the modular addition network in the Bayesian learning setting (there are some other differences from Neel Nanda's approach, most notably the choice of loss function, but variants of the approach extend to these as well). The distribution is first understood at infinite width, then shown to apply at realistic (but large) width in the appropriate regime. When applying the adaptive mean field theory approach to this task, Fourier modes and the trigonometric mechanism fall out as a natural output of the theory – moreover they are fully explained on a statistical distribution level (i.e. we have a complete model "exactly what each neuron does" to an appropriate degree of precision, understood in a statistical physics sense). Of particular interest, the model explains a grokking-like phase transition between memorization (equivalently, a Gaussian process-like behaviour) and generalization (inherently mean field) and predicts the data fraction at which it happens (this is a Bayesian learning analog of predicting the distribution of when grokking happens in SGD-trained neural nets). The phenomenon is a genuine phase transition in the thermodynamic sense.
5.  **Are real models in the mean field regime or the Gaussian process regime, or something else?** This is an interesting question, whose answer is "this question doesn't make sense". The distinction between regimes applies to infinite width nets, i.e. to a totally non-standard setting. One can prove rigorous results with the gist that if the width is (*sufficiently enormous with some giant bound*) compared to the training data, the model is guaranteed to learn in one of these two regimes. However, no real models are that enormous. Instead, some phenomena and some mechanisms can be seen (experimentally or theoretically) to extend from infinite nets to nets of finite width. Sometimes these look more like mean field phenomena, sometimes they look like Gaussian process phenomena. For example in some sense MNIST is "GP-like" (GP stands for Gaussian process). Circuits in modular addition are, as it turns out, entirely explained by the MFT limit as we've explained above.

Introduction to the theory
==========================

The background (and the foreground)
-----------------------------------

In physics, one often looks at systems with a large, stable background. A planet vs. a sun, an electron vs. a proton, a weakly interacting observer vs. a large system being observed. In these settings the "background" is the large system and the "foreground" or "test system" is the small system being studied. The background system may be fixed, or it may be undergoing some motion (like the sun moving around the galaxy's center), but the important idealization is that it does not react to the observer/ test system. In fact, the earth is applying a gravitational pull to the sun (and famously in quantum mechanics, observations always impact a system at a quantum level). But these "reverse" effects are small, so to a good approximation we can treat the sun as doing its own "stable" thing while earth is undergoing physics that depend strongly on the sun.

Self-consistency
----------------

While typically the large "background" is a cleanly separate system from the small test system or the observer, it is sometimes extremely useful to treat the test system as a tiny piece of the background. So: the large background system may be a cup of water and the small test system may be a tiny bit of water at some location. Here while technically the full cup *includes* the tiny "test" bit, the large-scale behaviors (waves etc.) in the water don't really care to relevant precision if the test bit is changed or removed (at least if it's tiny enough). But the tiny bit of water definitely cares about the large-scale behaviors (waves, vortices or flows, etc.), to the extent that bits of water care about things.

Similarly (and in a closely related way), "the economy" is a giant system that includes your neighborhood bakery. The bakery can be viewed as a small "test system": it is affected by the economy. If property prices go up or the economy tanks, it might close. But the economy is not (at least to leading order) affected by this bakery. It is perhaps affected by the union of all bakeries in the world, but if this particular bakery closes due to some random phenomenon (e.g. the lead baker retires), this won't massively impact the economy.

This point of view is remarkably useful, because it introduces a notion of "self-consistency".

**Self-consistency** when applied in this context comes from the following pair of intuitions:

1.  the behavior of each small component is (statistically) determined by the background
2.  the behavior of the background is the sum of its small components.

If both of these assumptions are true, then these two observations (when turned into equations) are usually enough to fully pin down the system. Indeed, you have two functional relationships[^gpqqhsv66ih] :

$$
\text{background} = b(\text{foreground}),\quad \text{foreground} = f(\text{background})
$$

Putting these together, we have the combined "self-consistency" equation:

$$
\text{background} = b(f(\text{background})),
$$

which means that the background field satisfies a *fixed point* equation for the composed function \\(b\\circ f\\). It so happens that in many cases of interest this equation has a unique solution. A classic example of a self-consistency equation is the [supply-demand curve equilibrium](https://en.wikipedia.org/wiki/Supply_and_demand). Here the background is a single number (price of a good) and the test system is the willingness of a single consumer to buy or of a single producer to sell, as a function of price (the actual "tiny components" consisting of individual consumers/producers are abstracted out, and the curve abstracts this out into the average incentive).

### Connectivity

Of the two self-consistency assumptions above, assumption 1 is most problematic. The assumption asks that each "test" component be determined by the "large-scale" stable system. This statement needs to be interpreted statistically: so for example the number of bakeries in a given neighborhood fluctuates due to people retiring/ moving/ etc., even if "the economy" is held constant; similarly, every bit of the sun reacts to magnetic/ gravitational fields from other bits, but in a statistical or thermodynamic sense. And while the big system will generally affect the small pieces, it is not always the case that the statistics of every little piece is independently determined by the background.[^9sooffpegii] Sometimes local or so-called "emergent" effects break this causal relationship (and many interesting thermodynamic systems, such as the 2-dimensional Ising model, are precisely interesting in such contexts).

But surprisingly often (at least with an appropriate formalism) the approximation of the foreground as fully determined by the background (in a statistical sense) is robust. For example if we are modeling the sun, viewing the "background system" too coarsely (as just the mass + electromagnetic field + temperature, say, of the entire sun) is insufficient. Instead here we should view the "background system" as a giant union of many local chunks, maybe comprising a few meters of solar matter. These "chunk backgrounds" are still large in the sense of being much larger than an atom (or a microscopic chunk) which comprises a minimal test system. And studying their behavior (in an appropriate abstraction) offers sufficient resolution to model the sun extremely well. Similarly we can't apply a single supply-demand curve to the entire economy (bread costs different amounts in different places). But in appropriate contexts (for fungible products like oil, and on a "local economy" level where the economy is roughly uniform but not dominated by a single station, for example) self-consistency is a pretty good model.

In many settings, the question of how well "assumption 1" holds is related to a notion of *connectedness*. In the sun's magnetic plasma, the magnetic field experienced by a particle is accumulated over billions and billions of nearby particles - so the graph of interactions is extremely connected. In an oil economy, each consumer can typically choose between dozens of nearby stations which are reachable by car. However other settings (like the Ising model, or markets for rare and hard-to-transport goods) cannot be purely modeled by self-consistency as well.

In physics, systems that are well-modeled by a self-consistency equation (coupled background and foreground systems) are generally called *mean-field* settings. A big triumph of statistical physics is to make situations with local/ emergent phenomena "behave as well as" mean field theories – *renormalization* is a fundamental tool here, and most textbooks on renormalization from a statistical-physics view tend to start with a discussion of mean-field methods. But settings that are directly mean-field (for example due to being highly connected or high-dimensional) are particularly nice, easy-to-study

Neural nets and mean field
--------------------------

Neural nets are physical systems. This is a vacuous statement – anything that has statistics can be studied using a physics toolkit (and in many ways statistical physics is just statistics with different terms). Indeed, real neural nets are immensely complex, and if there is some sense in which they can be locally decomposed into background-foreground consistencies, these must themselves be immensely complex and likely dependent on sophisticated tooling to identify (this is one of the reasons why we are running an agenda on renormalization).

But it turns out that in some settings and architectures neural nets are *extremely* well-modeled by systems with high connectivity – and the reason is, naively enough, precisely the fact that they are *highly connected* (often fully-connected) on a neuron level (note that architectures that aren't "fully-connected" – e.g. CNNs – sometimes still have properties that make them "highly connected" from a physical point of view).

The mean-field background and foreground for a neural net
---------------------------------------------------------

In neural net MFT the foreground (or "system"/ "observer") abstraction is a *neuron*. This is typically a coordinate index \\(i\\) of some layer.

The important "background" thing that each neuron "carries" is what is called an *activation function*, often denoted by the letter \\(z_i\\). This is a function on *data*: given any input x, partially running the model on x returns a vector of activations. \\(z\_i\\) is its i'th component. This function \\(z\_i\\) is now the thing that a neuron contributes to the "background field" of the neural net.[^yy4ysa4w5t]

Now if there are lots of neurons, each neuron's activation function reacts to a background generated by the other neurons: removing the neuron in this limit doesn't change the loss by much, so the background determines each neuron's behavior *as a statistical distribution*. Conversely, the background itself is composed of individual "foreground" neurons. The loop:

> background \\(\\to\\) neuron distribution \\(\\to\\) background

must *close*, i.e. be self-consistent. Making sense of this loop *is* the key content of mean field theory of neural nets.

In later installments we'll explain a bit more about the loop and show some examples of it working (or not). You can also see the original linked paper about the [Curse of Detail](https://arxiv.org/abs/2512.04165) for a more physics-forward view of this.

Experimental setting and pretty picture
=======================================

We'll close with a toy example of "self-consistency", which is visually satisfying.

In this setting we look at a 2-layer model that takes in a two-dimensional input variables \\((x,y)\\) and is trained on the target \\(\\text{out}(x,y) = xy\\) at a large width (here \\(2048\\)) and on infinite data. The activation function \\(\\phi(x)\\) is a bounded sigmoid-like function (the relu version of tanh). Each neuron at layer 1 is a function that only depends on a 2-dimensional row of the weight matrix, so the associated "test" field or particle can be plotted on a 2-dimensional graph. When we plot all of these together we get a good picture of the distribution of single-neuron functions that combine together to form the background system:

![image.png](https://res.cloudinary.com/lesswrong-2-0/image/upload/v1775285774/lexical_client_uploads/mnokrazacdkwdtmldzmp.png)

The neurons above were trained jointly in a way that would allow them to interact.

It has a nice clover-leaf like structure (it will reappear later when we look at continuous xors - a multi-layer setting where mean field performs compositional computation; already in this simple setting, the fact that the cloud of neurons is a "shaped" distribution rather than a flat Gaussian puts us solidly outside the Gaussian process regime). Now we can empirically measure how a single randomly initialized "foreground" neuron would react to the background generated by this model. To do this, we train 2048 iid single-neuron models on the resulting background from the fully trained model.[^umbs6drlxzo] When we do this and combine the resulting 2048 neurons into a new model, we see that indeed it looks exactly the same as the background. When we compute its associated function, we get very similar loss.

![image.png](https://res.cloudinary.com/lesswrong-2-0/image/upload/v1775285805/lexical_client_uploads/bhahclcair20imet9stf.png)

Each neuron in this picture was trained in a fully iid way, without interacting with any neuron, simply by "reacting to the background", i.e. learning the task in combination with the "blue" background above.

Note that this isn't a property that comes "for free". If we were to use the wrong background (for example a the more Gaussian process-like model here) then samples of the foreground would fail to align to the background.

![image.png](https://res.cloudinary.com/lesswrong-2-0/image/upload/v1775285925/lexical_client_uploads/jfiyvxsqt8bnvrk0rwi4.png)

Blue is background, orange is foreground (each orange neuron trained independently in reaction to background).

The case of 2-layer networks is special: neuron functions are particularly simple to characterize, and the mean field has better properties (it's not "coupled"). But we'll see that deeper nets can still be analyzed using this language, and even using empirical methods we can get cleaner pictures of how they learn and process representations.

In the next post, we will explain the physics behind these experiments and the experimental details of the models (github repo coming soon).

  

[^f6m7agmioq]: Sometimes identified with the term "features" though usage of this term in the field is a mess. 

[^yxaebc2jkw]: Technically they differ on whether they use the "pizza" vs. "clock" mechanisms, but the two idealizations are related, and both the mean field and the realistic setting can be modified to make use of either. 

[^gpqqhsv66ih]: Below, f and b should generally be understood as "statistical" functions: job choice is, perhaps, a probabilistic function depending on the economy, which includes both demand/ markets but also supply/ people's interests; conversely "the economy" is the average of production over the distribution of jobs. 

[^9sooffpegii]: A rigorous statement here is conditional independence: the assumption holds when to leading order, small foreground systems are conditionally independent with respect to the background. 

[^yy4ysa4w5t]: Technicalities. Depending on the situation \(z_i\) can either be viewed as a function a finite training set or on an infinite "set of all possible inputs", usually a large Euclidean space (example: an MNIST input is a \(14^2 = 784\) vector of pixel values). Unless we're working with finite training data, this is a priori an infinite-dimensional gadget; and worse, the thing that is actually summed over neurons – the analog of the "market" or "background field" is nonlinear in this objects[4]. There is also a subtlety here about SGD vs. Bayesian learning which I won't get into. But in mean-field settings that admit generalization (or for finite number of inputs), this background is effectively dominated by a small set of "relevant" directions. 

[^umbs6drlxzo]: Technical note: each single-neuron model is trained on the difference \(\text{out}(x,y) - f_{\text{background}}(x,y)\) where \(f_{\text{background}}\) is the trained model. 

[^w1z2agb04vb]: In fact it is quadratic: the thing that sums over neurons is the "external square" of the neuron function, which is a function of a pair of inputs: knowing this sum fully determines the dynamics up to rotational symmetry, even for a finite-width model (it's often called the "data kernel" but is used very differently from the Gaussian process kernels, which do depend on an infinite-width assumption and lose a lot of information in finite-width and mean-field contexts).