Epistemic status: Assuming no major oversights in the math here, the core concept is broadly correct. Much of the math is applying basic concepts from Boolean fourier analysis and many-body physics. This is the first part in what is going to be a multi-part series.
LLM usage disclosure: This post is not written or heavily edited by an LLM. LLMs were used in research, to help pick better math notation, and double check calculations. Any math mistakes are my own. Also I think math heavy posts are just more likely to get flagged by the automated LLM detection system because math can sound robotic at times, which is unfortunate.
Introduction
Sometimes I feel bad for my colleagues who have to deal with the fact that eventually almost everything I work on becomes some sort of weird many-body problem. Obviously, you work with what you know so having been involved with quantum many-body junk over the years there's some predisposition towards it. That being said, this line of thinking actually did not start with me going "hey, what if I applied ideas from the quantum many-body problem to deep learning?" Instead, it went the other way. Thinking about learning naturally leads one to think about interactions between different pieces of information. While I have written about this before, there is much more one can do by thinking this way. In fact, many-body interactions are a generically useful description for learning in general. In particular, we can actually build a pretty general many-body theory of computation and frame learning within this. This post is meant to present the first foundational piece of this. To motivate one actually reading this post, I would like to outline what it is we are going to do here.
- Given a hypothesis class defined by an interpreter which takes in programs and datapoints , each program can be written as many-body interactions between the bits when running on as the input.
- For every , its many-body expansion can be written in terms of spins instead of bits.
- Using the spin representation, we can show how all the different possible inputs couple to one another through the program based on how they respond to the changes in the bits/spins of , meaning that defines a field mediated interaction between inputs.
- From this, we can show that the bit-couplings and data couplings are dual objects.
- We then can show that the difference between local learning (like steepest descent) vs. global methods (finding the global empirical risk minimizer) is matter of the highest degree of bit-correlation your algorithm can see.
- We show that this holds in general given any hypothesis space with a well-defined notion of locality and any notion of local updates on them.
- We relate all this to how locality handles the frequency of terms in the loss.
- Finally, we discuss how the bit picture is effectively a spin generated field.
This sounds like a lot, but we will see it is all surprisingly natural, and most of it can be done without a ton of sophisticated machinery.
Author note: Similar ideas have recently been explored in Interpretability for Turing Machines, which shows that tools from singular learning theory can detect algorithmic structure in Turing machines. That work, and the work done here are related, but are rather substantially different. That paper makes a machine's transition table have a degree of probabilistic fuzziness so that every time the machine reads its own instructions it might misread them. They then measure how the loss responds near one particular correct machine under some distribution of possible errors. Here we take the interpreter as a black box, then show that one can build a many-body expansion out of bit flips which turns out to be a spin system with its own natural couplings between parameters and between data points. There are a bunch of other differences as well, especially in the math used, the desired results, etc. but the main conceptual difference is how we handle the machine.
The many-body expansion of computation
To start with, we want to assume that we have an interpreter , which takes in programs and inputs. There is an important subtlety about this construction which is that we must have that halts. There are different ways to enforce this, such as forcing the machine to halt at some fixed timestep. However, the natural one for learning is to fix the class of possible programs we can have, which creates a hypothesis class . So, we have an interpreter , a set of programs up to some length and inputs $ up to some length such that for all and the machine halts. In this case basically behaves like the "architecture" and is the set of parameters. However, we should not think of as fixing something like a neural network architecture. It could be as large as all computationally valid parameter-architecture pairs. In the following, as a shorthand we denote as and dually . Further, we denote flipping a bit value as .
Now to get the many-body expansion (that is, the expansion which defines bit interaction) we are going to start with a reference program . Identify a nearby program with a mutation mask by . For each input define For , write , with , and let denote the indicator mask of . That is, specifies the bits whose interaction we want to measure and specifies which bits we actually flip. This distinction matters because of how we construct the many-body/bit expansion. Below we are going to start by presenting it as a proposition and we will explore what it is actually saying and see it's not actually particularly complicated.
Proposition 1 (Exact local interaction expansion). For every input and program , there is a unique collection of coefficients for each subset such that with the coefficients are by
Proposition 1 (Exact local interaction expansion). For every input and program , there is a unique collection of coefficients for each subset such that
with the coefficients are by
If you know what Mobius inversion on a boolean subset lattice is, this is a two line proof like "Evaluating 6 at yields . Mobius inversion on the Boolean subset lattice gives 7, establishing both existence and uniqueness" but this is bad and not particularly helpful. At first maybe this seems cursed, but it is actually a very simple construction, and kind of dumb. First, we start with our reference program , which, for simplicity let's just consider the program given by (though this need not be the case, it just makes it simpler as the actual string and its perturbation correspond in this basis). Denote the output , which is simply a or a . Now, suppose we change the bit in the first position . If we do this, clearly either the output stays the same, our the output bit flips. Writing this down: where is a "correction" that shifts either by or 0. Notice then that if we write with if we flip the bit or otherwise, we can simply plug in for to shift the computation. If we have a second bit that we could perturb we could take . If we only perturb the first bit, , then if we only perturb the second bit, . If we perturb both bits, the only zero terms are ones where the perturbation does nothing. To really hammer home how dumb this is, it is simply the observation that we can always simply add some number to the original output turn it into the thing we want and the binary structure of the program gives us a natural encoding of this.
So we can see that if there are say different possible bits we can flip, there are different possible order 1 terms. So the first order "corrections" can be computed off of the expansion: where only a single is non-zero for a single bit flip. Now if we perturb two bits, then we need to work with the expansion where two of the first order terms are "active" as well as one second order term.
Continuing in this way we get that the full expansion is
The order- terms simply enumerate every way of choosing distinct bits,
so the whole expansion is a sum over orders . These are essentially the "moments" of the computation.
From bits to spins
So now we have something like a many-body expansion in bits. However, there are some aspects of this expansion that are not ideal, as we shall see. Consider a space of programs with two program bits. Suppose that on some input , every program outputs the AND of its two bits. We get the following table:
| 00 | 0 | 0 | 0 | 0 |
|---|---|---|---|---|
| 10 | 1 | 0 | 0 | 0 |
| 01 | 0 | 1 | 0 | 0 |
| 11 | 1 | 1 | 1 | 1 |
Now for any two functions and of the program we can take the dot product as:
Since the perturbations are functions on the program we simply write . However, using the monomials as a basis does not give us nice orthogonal components. From the table,
and in general , which is never zero. Every monomial overlaps with every other, so their coefficients interfere and can't be read as separate amounts, so it becomes very hard to separate effects. However, we can fix this, and the fix actually makes the whole many-body interpretation thing kind of natural because we can put it in ising land.
To do this, we simply recenter each bit
For those familiar with the Ising model, the re-centring of each variable from to is moving us from the world of bits to the world of spins! Doing this means that now is for half the programs and for the other half, so . The monomials in the bit picture now become products of spins:
So now monomial is the parity of a subset of bits, which is much nicer to work in. Furthermore, these monomials are like of sine waves. If we flip a single bit in then flips sign, which is the simplest possible oscillation. A larger means the function oscillates along more directions, which is essentially the same as having higher frequency. Thus we call the subset the frequency, and the order. What we have done here is essentially just employed a fourier transform on boolean functions. Now if we denote the output of the program on a fixed as we can take
So is the correlation between the output and the parity of the bits in , averaged over all programs. Going back to our AND table from earlier, we can write out he expansion in bit space. Each coefficient is the average over the four rows of times the relevant column:
We call this sort of expansion the Fourier expansion.
Coupling through the loss
To introduce the loss function write for the spin output on input , and for its label as a spin. For simplicity we are going to use the 0-1 loss but this can be replaced with other loss functions, it is simply the natural one when the output is a single bit. On a single sample , we can write the zero–one loss in our spin-monomial basis as:
This says that if the output matches the label, and the loss is ; if not, and the loss is . Averaging over the data and substituting each 's expansion:
We can then take the expansion (we drop the constant factor), with, for every nonempty ,
Notice that each data point votes on each interaction term. its vote is how strongly its output depends on the parity , signed by its label. So data points that agree on a term reinforce it and data points that disagree cancel it.
The Data Coupling
Up to this point we mostly looked at how parameters couple together, but there is actually a dual to this, given by how parameters induce "field mediated coupling" between datapoints. For each data point and each set of program bits , take
which says how strongly the output on depends on the parity of the spins. Notice that we can build a matrix/operator from this. Each row is a datapoint and each column is a set of program bits .
where we leave out the constant column , which only shifts averages. This is actually a very dumb object, in that it literally just records the outputs of each possible program on the data. However, we can read off a ton of information from this thing. Above we saw how the loss couples parameters through the inner product . We can now look at how the data points themselves get coupled.
Because the parity monomials are an orthogonal basis, the covariance between two outputs over random programs is
Two data points are coupled when their outputs depend on the same parities with the same signs. Keeping only the columns with gives the order- coupling , and these add up to the full covariance.
This gives us a duality between parameter coupling and data coupling. First is the the parameter coupling whose entry measures how often the interactions between bit sets and appear together across the data. We can then take the data coupling which is how strongly each pair of datapoints is coupled by the parameters. These must have the same nonzero eigenvalues, since both come from the singular value decomposition of . This is cool because each singular value pairs a pattern over data points with a pattern over parameter interactions. This is an obvious fact, though I think maybe somewhat underappreciated.
Local vs. global learning
How does learning work in this picture? Imagine now we start at some reference program , and we want to learn the program which gives the correct outputs given our set of possible inputs. What is the simplest thing we can possibly do to learn? The obvious answer is look at the programs right next to us and move to whichever one is best. However, we need to know what "right next to us" means. This is actually determined by the interpreter and whatever the geometry it puts on programs is. However, for simplicity we start by working with the Hamming distance which is simply the number of bit positions in which the bit string descriptions differ, so the neighbours of are the programs we get by flipping a single bit,
Starting with the simplest possible case of the zero-one loss we can write the empirical loss as a function of the program like
Using this we can we can define a very simple learning algorithm.
Definition (Bit descent). Starting from , iterate
and stop as soon as no neighbour is strictly better, that is, when . Ties are broken by some fixed rule, say the lowest index.
Interaction order and learning
The main point of this section is actually kind of straightforward. Local versus global learning is really just a question of what order of bit correlation you can see. Bit descent only sees how flipping a single bit changes the loss, which is as local as it gets. Now imagine you could see how flipping every pair of bits changes the loss, and move accordingly. That is slightly less local. Keep going to higher and higher orders, and at the top you see everything and can go from the initial point to the minimum in one shot.
To formalize this we take radius- descent be like a generalized version of bit descent on the radius -ball
Bit descent is , but we can in theory search all mutations of a program within radius and take the best one. Now recall that proposition 1 was stated for the output , but nothing in it actually used anything about beyond it being a function of the program. This means we can use it for the loss. Taking the current program as the reference, writing for the local coefficients of around ,
The important thing now is that every move in the radius- ball has , so radius- descent can use only the coefficients of order at most . This lets us give the following proposition:
Proposition 2 (Nested local minima). Let be the set of programs where radius- descent stops. Then
Proof: Since , a program with no strictly better neighbour in has none in either. And is every other program, so having no strictly better neighbour there means it must be a global minimum.
Why is this interesting? Well, each order of correlation you can see removes exactly the things that trapped you because you simply couldn't see to high enough order. This should be sort of unsurprising though! Suppose that you know your function is of order and you have evaluated on every program. From this you can construct the global empirical risk minimizer, jumping directly into the optimal basin.
There is one subtlety to address before we move on, which is that radius- descent naturally puts two things together. Namely, seeing the order- correlations and moving bits at a time. These are, strictly speaking, not really the same thing. Suppose the loss only has terms up to order two. Then the coefficients of order at most two around any single program determine the entire landscape. After evaluations you would know the entire landscape, and could in principle jump straight to the global minimum. However radius-2 descent does not do this. It still only moves within the 2-ball and can still get stuck when there are no good moves to make.
Bit descent in spins
Now we are going to move from the bit descent picture to the spin descent picture as it lets us write everything out into a nice, neat form. This is straightforward since flipping bit sends , so this negates exactly the parities with . So from ,
The quantity is the local field on spin . This is the sum of every interaction that spin feels, with the other spins in each interaction frozen at their current values. A flip lowers the loss exactly when . That is, when the spin points against its field. So, local descent is trying to slowly align each spin with the field it feels. For those familiar with Ising models/spin glasses this is kind of what one would expect this. Furthermore, we can actually write this in the familiar many-body Hamiltonian form. For illustration we keep only the terms with , giving
This is literally a sort of spin glass, and is an external field plus the field produced by every other spin through the couplings . Bit descent is then single-spin-flip dynamics. At each step we flip the spin most misaligned with its field, and stop when every spin is aligned. The places it stops are the states where no single flip will decrease the loss/energy anymore. The fact that a spin glass has enormous numbers of these is exactly the rugged landscape problem.
Beyond Hamming: local descent on any neighbourhood
Nothing about bit descent actually used the fact that the neighbours were given by single bit flips. It just needs a rule saying which programs count as adjacent to which. In a future post we are going to make this a bit more explicit but to see that it is indeed a general construction. We simply let be any hypothesis class and pick a neighbourhood map (or equivalently a graph on ). The natural way to get thus is from a metric then taking the ball
So we now give the basic definition of local descent:
Definition (Local descent). Starting from , iterate , stopping when no neighbour is strictly better.
Bit descent is the case = Hamming, . Unsurprisingly, GD is effectively a type of local learning under this definition. For , take a small ball under some norm (usually ) . As , the best move in the ball becomes steepest descent with respect to that norm.
Looking forward
Let's consider what we actually did here. If we put it in more mathy language, let be the adjacency operator of the Hamming graph, so the graph bit descent walks on . Flipping bit negates when so
The parities are exactly the eigenfunctions of the graph Laplacian of the hypercube, and the order is literally its frequency. It turns out that this basis actually provides in some sense the most natural basis for studying what it is that an algorithm "knows" about the data. Furthermore actually much more general though than just the Hamming graph. For any neighbourhood graph on we can take the eigenbasis of its graph Laplacian as the natural basis. We explore this in a depth in the next post.