We construct a toy model of when and how neural networks learn compositional circuits during training. Concretely, we use mean-field theory to analyze a two-hidden-layer quadratic MLP with symmetric initializations trained on a staircase dataset . We find that this model exhibits a hierarchy of learning mechanisms with different perturbative onsets at early times . The model first undergoes feature learning from the quadratic label gradients; then improves its prediction of the quartic label using random features that were present at initialization; then undergoes feature learning from the quartic label gradients; and finally starts to use the learned features to solve the quartic parity task in a compositional circuit We comment on how our broader research program could be of direct relevance to some central problems in AI safety.
This blog post is a distillation of a longer technical note.
Introduction
In mechanistic interpretability, a major goal is to understand the primitives of computation. What are the structured representations/features that a neural network learns to use, and how does the neural network operate on them? Since modern models contain trillions of parameters, trying to guess the answer in a vacuum is probably a nonstarter. We need strategies.
Faced with a new scientific problem, it’s often fruitful to look for strategies by analogy. One such analogy is that neural networks look like many-body systems. They have lots of interacting components, and we’re interested in the dynamics that emerge from their interactions. Physicists have spent a lot of time studying problems of this type in systems like magnets and fluids, and our group is pursuing a diverse collection of bets to apply the strategies they’ve developed to ambitious mechanistic interpretability. [1]
But one way that we’re actually better off in mechanistic interpretability than as physicists handed a generic many-body system is that we have prior knowledge - from language data, introspection, etc. - into what might in fact be useful primitives of thought. This knowledge unlocks a new hybrid strategy. First posit an interesting computational organization that we suspect a NN might use on the basis of the prior knowledge. Then construct a toy model to understand when/how/why that type of organization might emerge from the learning dynamics.
Compositionality and the staircase problem
One example of a motivated prior is compositionality. The world we live in, and language data that describes it, appears to be compositional. Objects have recognizable attributes (color, shape) and parts (a dog’s ears, tail, snout). It intuitively seems like it would be efficient, tracking our introspective common-sense, for a thinking machine to learn representations of complicated objects/concepts by building them up from representations of the parts, instead of learning the final answer in one go. [2]
Staircase models are a class of data model for eliciting compositional representations. In a staircase-type problem [3], we ask a network to learn the parity of a high-degree (sub)set of Boolean inputs, . But rather than ask it to learn the high-degree parity alone, we also provide related constituent functions in the label. Such subtasks can elicit learning of intermediate features that the model can then reuse to solve the final task.
Concretely, suppose we give a model four input bits and labels . By multiplying learned representations of , the model can compositionally solve the quartic parity task. The first two labels give the model a reason to learn these features before potentially combining them to build the third.
The potential compositional solution is clear. What’s less clear is when and how gradient descent chooses to build this particular circuit. How does supervision on simple tasks help the network to learn the harder one? Are the intermediate features largely learned from the simple labels, or do gradients from the partly-learned harder task contribute? Can we understand the time scales at which different things happen, and feedback loops that cause the full circuit to appear?
In the rest of this post, I’ll show that analogs of these questions can be answered using mean-field theory [4][5] in a two-layer nonlinear MLP. We’ll see that gradients from both simple and hard tasks in a toy model contribute to building intermediate features at different orders in an early-time expansion, and trace how each contribution subsequently improves the model’s performance on the hard task.
Our group is also working on the staircase model from other perspectives. In a separate post, my colleague Sergey Alekseev will describe an empirical study of a more sophisticated staircase model with a higher-degree final parity.
Solving the staircase problem in a simple 2L MLP
The model that we study is a two-hidden-layer model with quadratic activation functions, trained on the simplest nontrivial staircase dataset [6]
,
with MSE loss.
Importantly, this dataset has a large group of function-level symmetries. For example, it’s invariant under simultaneous flips of and , and equivariant under simultaneous flips of and the labels . If we’re careful to initialize the model to preserve the symmetries, they will make analysis of the joint model-and-data system unusually tractable while not detracting from its value as a toy model of compositional feature learning. [7] In a companion note, we derive dynamical mean-field equations for the joint model-and-data system under such a choice of initialization, and analyze the mean-field equations’ qualitative properties.
Our main result so far is that the equations can be solved perturbatively at early times to demonstrate a hierarchy of learning mechanisms that first appear at different orders in the small- expansion. Namely:
At initialization, the model starts with nonzero activation strength on random quadratic features in its first hidden layer.
At order , gradients from the staircase labels start to improve the layer-1 quadratic features. However, the learned features aren’t used by the model until higher orders in the small- expansion.
At order , the model first improves its prediction of the quartic label by doing lazy learning w.r.t. the random layer-1 features seeded at initialization.
At order , gradients from the quartic label start to improve the layer-1 quadratic features.
At order , the model starts to improve its prediction of the quartic label via the feature-learning from staircase labels at , going beyond lazy learning.
Finally, at order , the model starts to improve its prediction of the quartic label via the feature-learning from the quartic label itself at .
Figure 1. The early-time learning hierarchy. Arrows link learned features to the higher-order use of the learned features for prediction. See the bullet points in the text for details.
In short, both the staircase and quartic labels contribute to the building of intermediate quadratic features that in turn are used to improve the quartic prediction. These results provide a first look at how MFT machinery can be converted into a qualitative story for when and how gradients from simple and more complicated tasks cooperate to build a compositional circuit.
Figure 2. Numerical results from integrating the MFT equations in the note with learning rate (solid lines), and early-time perturbative results (dashed lines). On the left-hand side, we plot the time-integrated contribution to of in eq. (35) of the note (blue line), and from in eq. (38) (orange line). Along the y-axis, where for and . The two curves sum to . On the right-hand side, we plot the time-integrated value of the first two lines in eq. (34) (gray line), the part of the last line in (34) driven by the staircase labels (teal line), and the part of the last line in (34) driven by the quartic label (purple line). These curves sum to , the amplitude of the quartic prediction. Since we take a mean-field average over initializations, the plots are deterministic up to error from the numerical solver.
Next steps
We’re currently working to extend the results discussed here to finite times at the cost of further simplifying the toy model, exploring the Pareto frontier of model realism versus solvability. As a preview, we’ve tentatively found that if we also work in a vanishing-initialization regime and impose a set of symmetric lower-weight initializations, we can not only push our results to finite time, but also model when and how some neurons specialize to one feature while others become more polysemantic during training.
In the future, we’d like to generalize our analysis to staircase labels only, letting the model’s learning of an feature be a toy model of unsupervised feature learning. We’d also like to perturb away from symmetric initializations to study how different compositional circuits e.g. might compete with the symmetry-favored one, as a toy model of circuit selection. Another direction is to characterize how each discovered theoretical result manifests in realistic finite-width models. [8]
It would also be interesting to push our analysis to higher-degree activation functions, to model the results that will be discussed in Sergey’s forthcoming post. In his project, Sergey found a phase boundary between a ReLU model learning a compositional staircase circuit versus learning higher-order features directly, as a function of the weight decay and weight initialization.
Finally, we believe that this line of work serves as a good example-in-principle of the type of safety-relevant knowledge that one can hope to get from deep learning theory. In AI safety, a lot of highly consequential lore follows from conceptual reasoning about empirically observed phenomena. For example:
The possibility that a model could have very different circuits when undertrained vs. overtrained - pointedly illustrated by the phenomenon of grokking - raises the concern that dangerous capabilities could emerge very suddenly over the course of training. [9]
The fact that neurons can be polysemantic raises the possibility that dangerous capabilities could hide in an uninterpreted ‘long tail’ of neural representations, even if we’re able to identify one or a few primary features represented by each neuron.
As long as they remain conceptual concerns illustrated by a sparse set of examples, these issues seem very hard to put safety guarantees on.
What theory offers is a route to explanations of when/how/why these phenomena occur, opening up the possibility of rigorously establishing their presence or absence under certain conditions, or making models exhibit more or less of such properties by design. In particular, our hope is that these things might fall out of a theory of learning dynamics that can trace how different types of features form and how the rest of the model comes to use them over training. We’ll have more to say about these specific items in future posts (including in our follow-up work on this very model!), but for now, we hope this post serves as an appetizer for why we’re excited by this research direction.
Thanks to Ari Brill, Lauren Greenspan and Andrew Mack for comments on this post.
The problem of (n,k) parity is a crisp mathematical model of the computational challenges of learning a complicated representation directly, without going through incremental parts.
Mean-field theory is a technique to analytically derive the distribution of a typical weight or neuron by treating that weight or neuron as a microscopic component living self-consistently in a background generated by many copies of it. See here for an introduction.
At a purely technical level, this project may be of interest to deep learning theorists because there are, to the best of my knowledge, relatively few (partial) analyses of concrete 2L+ nonlinear MLP’s.
This dataset is very small, but the conceptual properties of the joint model+data setup that make it amenable to analysis generalize to larger datasets.
In the precise sense that the symmetries don’t constrain whether the model prefers to learn a quadratic-to-quartic compositional circuit versus directly learning the quartic feature.
As a first step in this direction, we checked that for finite-width versions of this model with more input spins, networks with conventional small random inits still preferentially use the supervised pair features, and ablating the , features from first layer activations drops the quartic test accuracy from 100% to ~chance.
TL;DR
We construct a toy model of when and how neural networks learn compositional circuits during training. Concretely, we use mean-field theory to analyze a two-hidden-layer quadratic MLP with symmetric initializations trained on a staircase dataset . We find that this model exhibits a hierarchy of learning mechanisms with different perturbative onsets at early times . The model first undergoes feature learning from the quadratic label gradients; then improves its prediction of the quartic label using random features that were present at initialization; then undergoes feature learning from the quartic label gradients; and finally starts to use the learned features to solve the quartic parity task in a compositional circuit We comment on how our broader research program could be of direct relevance to some central problems in AI safety.
This blog post is a distillation of a longer technical note.
Introduction
In mechanistic interpretability, a major goal is to understand the primitives of computation. What are the structured representations/features that a neural network learns to use, and how does the neural network operate on them? Since modern models contain trillions of parameters, trying to guess the answer in a vacuum is probably a nonstarter. We need strategies.
Faced with a new scientific problem, it’s often fruitful to look for strategies by analogy. One such analogy is that neural networks look like many-body systems. They have lots of interacting components, and we’re interested in the dynamics that emerge from their interactions. Physicists have spent a lot of time studying problems of this type in systems like magnets and fluids, and our group is pursuing a diverse collection of bets to apply the strategies they’ve developed to ambitious mechanistic interpretability. [1]
But one way that we’re actually better off in mechanistic interpretability than as physicists handed a generic many-body system is that we have prior knowledge - from language data, introspection, etc. - into what might in fact be useful primitives of thought. This knowledge unlocks a new hybrid strategy. First posit an interesting computational organization that we suspect a NN might use on the basis of the prior knowledge. Then construct a toy model to understand when/how/why that type of organization might emerge from the learning dynamics.
Compositionality and the staircase problem
One example of a motivated prior is compositionality. The world we live in, and language data that describes it, appears to be compositional. Objects have recognizable attributes (color, shape) and parts (a dog’s ears, tail, snout). It intuitively seems like it would be efficient, tracking our introspective common-sense, for a thinking machine to learn representations of complicated objects/concepts by building them up from representations of the parts, instead of learning the final answer in one go. [2]
Staircase models are a class of data model for eliciting compositional representations. In a staircase-type problem [3], we ask a network to learn the parity of a high-degree (sub)set of Boolean inputs, . But rather than ask it to learn the high-degree parity alone, we also provide related constituent functions in the label. Such subtasks can elicit learning of intermediate features that the model can then reuse to solve the final task.
Concretely, suppose we give a model four input bits and labels . By multiplying learned representations of , the model can compositionally solve the quartic parity task. The first two labels give the model a reason to learn these features before potentially combining them to build the third.
The potential compositional solution is clear. What’s less clear is when and how gradient descent chooses to build this particular circuit. How does supervision on simple tasks help the network to learn the harder one? Are the intermediate features largely learned from the simple labels, or do gradients from the partly-learned harder task contribute? Can we understand the time scales at which different things happen, and feedback loops that cause the full circuit to appear?
In the rest of this post, I’ll show that analogs of these questions can be answered using mean-field theory [4] [5] in a two-layer nonlinear MLP. We’ll see that gradients from both simple and hard tasks in a toy model contribute to building intermediate features at different orders in an early-time expansion, and trace how each contribution subsequently improves the model’s performance on the hard task.
Our group is also working on the staircase model from other perspectives. In a separate post, my colleague Sergey Alekseev will describe an empirical study of a more sophisticated staircase model with a higher-degree final parity.
Solving the staircase problem in a simple 2L MLP
The model that we study is a two-hidden-layer model with quadratic activation functions, trained on the simplest nontrivial staircase dataset [6]
with MSE loss.
Importantly, this dataset has a large group of function-level symmetries. For example, it’s invariant under simultaneous flips of and , and equivariant under simultaneous flips of and the labels . If we’re careful to initialize the model to preserve the symmetries, they will make analysis of the joint model-and-data system unusually tractable while not detracting from its value as a toy model of compositional feature learning. [7] In a companion note, we derive dynamical mean-field equations for the joint model-and-data system under such a choice of initialization, and analyze the mean-field equations’ qualitative properties.
Our main result so far is that the equations can be solved perturbatively at early times to demonstrate a hierarchy of learning mechanisms that first appear at different orders in the small- expansion. Namely:
Figure 1. The early-time learning hierarchy. Arrows link learned features to the higher-order use of the learned features for prediction. See the bullet points in the text for details.
In short, both the staircase and quartic labels contribute to the building of intermediate quadratic features that in turn are used to improve the quartic prediction.
These results provide a first look at how MFT machinery can be converted into a qualitative story for when and how gradients from simple and more complicated tasks cooperate to build a compositional circuit.
Figure 2. Numerical results from integrating the MFT equations in the note with learning rate (solid lines), and early-time perturbative results (dashed lines). On the left-hand side, we plot the time-integrated contribution to of in eq. (35) of the note (blue line), and from in eq. (38) (orange line). Along the y-axis, where for and . The two curves sum to . On the right-hand side, we plot the time-integrated value of the first two lines in eq. (34) (gray line), the part of the last line in (34) driven by the staircase labels (teal line), and the part of the last line in (34) driven by the quartic label (purple line). These curves sum to , the amplitude of the quartic prediction. Since we take a mean-field average over initializations, the plots are deterministic up to error from the numerical solver.
Next steps
We’re currently working to extend the results discussed here to finite times at the cost of further simplifying the toy model, exploring the Pareto frontier of model realism versus solvability. As a preview, we’ve tentatively found that if we also work in a vanishing-initialization regime and impose a set of symmetric lower-weight initializations, we can not only push our results to finite time, but also model when and how some neurons specialize to one feature while others become more polysemantic during training.
In the future, we’d like to generalize our analysis to staircase labels only, letting the model’s learning of an feature be a toy model of unsupervised feature learning. We’d also like to perturb away from symmetric initializations to study how different compositional circuits e.g. might compete with the symmetry-favored one, as a toy model of circuit selection. Another direction is to characterize how each discovered theoretical result manifests in realistic finite-width models. [8]
It would also be interesting to push our analysis to higher-degree activation functions, to model the results that will be discussed in Sergey’s forthcoming post. In his project, Sergey found a phase boundary between a ReLU model learning a compositional staircase circuit versus learning higher-order features directly, as a function of the weight decay and weight initialization.
Finally, we believe that this line of work serves as a good example-in-principle of the type of safety-relevant knowledge that one can hope to get from deep learning theory. In AI safety, a lot of highly consequential lore follows from conceptual reasoning about empirically observed phenomena. For example:
As long as they remain conceptual concerns illustrated by a sparse set of examples, these issues seem very hard to put safety guarantees on.
What theory offers is a route to explanations of when/how/why these phenomena occur, opening up the possibility of rigorously establishing their presence or absence under certain conditions, or making models exhibit more or less of such properties by design. In particular, our hope is that these things might fall out of a theory of learning dynamics that can trace how different types of features form and how the rest of the model comes to use them over training. We’ll have more to say about these specific items in future posts (including in our follow-up work on this very model!), but for now, we hope this post serves as an appetizer for why we’re excited by this research direction.
Thanks to Ari Brill, Lauren Greenspan and Andrew Mack for comments on this post.
For example, extrapolating from solvable limits, rigorously solving minimal toy models (with generic data), or looking for persistent or amplified inference-time modes (1, 2).
The problem of (n,k) parity is a crisp mathematical model of the computational challenges of learning a complicated representation directly, without going through incremental parts.
The model that we study below is a variation of the original staircase model in Abbe et al., which had a single label .
Mean-field theory is a technique to analytically derive the distribution of a typical weight or neuron by treating that weight or neuron as a microscopic component living self-consistently in a background generated by many copies of it. See here for an introduction.
At a purely technical level, this project may be of interest to deep learning theorists because there are, to the best of my knowledge, relatively few (partial) analyses of concrete 2L+ nonlinear MLP’s.
This dataset is very small, but the conceptual properties of the joint model+data setup that make it amenable to analysis generalize to larger datasets.
In the precise sense that the symmetries don’t constrain whether the model prefers to learn a quadratic-to-quartic compositional circuit versus directly learning the quartic feature.
As a first step in this direction, we checked that for finite-width versions of this model with more input spins, networks with conventional small random inits still preferentially use the supervised pair features, and ablating the , features from first layer activations drops the quartic test accuracy from 100% to ~chance.
This issue in particular motivates the study of dynamical deep learning theory, as done here.