Purpose
I review a recent eLife paper titled "A mechanistic theory of planning in prefrontal cortex," which introduces an idea called the Space-Time Attractor (STA). I show the connection between STAs and belief propagation, and explain why belief propagation might be a better framework for planning in the prefrontal cortex.
Why belief propagation might be a better framework for planning in the prefrontal cortex
This is an open post-publication review of the eLife preprint titled ‘A mechanistic theory of planning in the prefrontal cortex’. Earlier I wrote a brief FAQ review on X, and this blog expands on it.
Openly critiquing a preprint with positive reviews is scary. The critic (that’s me!) risks being perceived as angry and petty. If that is your gut reaction, I hope you consider that 1) I had to overcome my fear of being misperceived, and 2) I had to overcome my vanity to be liked by everyone. I believe healthy friction, conflict, and experimentation is needed for progress, especially when we connect disciplines that have different vocabularies and evaluation standards, and as AI threatens our traditional modes of science publication.
All I can promise is that I believe:
- Reading this will be useful for neuroscientists who are curious about how inference/planning might be implemented in the cortex.
- Reading this will be useful for people trying to bridge AI and neuroscience.
Ok. On to the scientific content.
Why the broader idea in the paper is worth attention, and what it got wrong.
Here’s why I’m excited: both the landmark El-Gaby experimental results and the mechanistic theory paper trying to explain them may point to the same idea—that the prefrontal cortex (PFC) plans and executes actions using belief propagation (BeliefProp).
However, you might not get that connection if you read the mechanistic theory paper, because something similar to BeliefProp is introduced as a new idea the paper calls Space-Time Attractor (STA). (Going forward I’ll refer to the paper and idea using STA)
In doing that,
- STA got a crucial detail that makes BeliefProp work wrong, resulting in STA not being able to solve problems that BeliefProp is guaranteed to solve exactly and efficiently,
- This resulted in the STA experiments in the paper looking weak; STA scales poorly and appears to perform better in comparison to baselines in part because the other algorithms were artificially handicapped.
Any experimental evidence from El-Gaby that supports STA also supports standard BeliefProp. Simply using the standard BeliefProp would have produced stronger and more convincing experiments and results, and would have made the connections to value iteration, dynamic programming, linear RL, and the broader planning literature easier to establish. It’d also help everyone to know BeliefProp’s shortcomings and mitigation strategies, which also might be part of planning in PFC. The standard BeliefProp has no hyper parameters (a miracle!), is biologically plausible, and can be implemented using almost the same circuit as STA. These are the things I want to explain. For that, I will have to first tell you about BeliefProp, and what is different in STA.
(Other names for Belief Propagation and variants: message passing, sum-product, sum-prop, max-product, max-prop, cavity method, …)
Maze transitions to factor graph
First, recognize that the adjacency graph in panel A above is what is represented by the factor-graph in panel D. Panel B has two copies of the nodes in Panel A to represent state (diamond nodes) transitions. Panel C is just grouping all the little diamond nodes (states) at time and into categorical variables and . Panel D represents this as a factor graph; the circular nodes represent random variables, and the square node represents factors (which in this case is the adjacency matrix). Each circular node in the factor graph in D hides in it the states (diamond nodes) of the maze-graph in A.
I haven’t used the word “space” so far. That’s because it’s not only unnecessary, it only serves to confuse. Everything forward will be discussed using the factor graph in D. (In a later section I discuss why “space” in the STA is unnecessary, erroneous, and confusing.)
Unrolling the graph in time
If you want to model the dynamics over time of how an agent transitions from state to state in the original maze, simply unroll the graph, and you get a factor graph as shown in B above. Note that the labeling is arbitrary, we give different labels to copies of the same ‘weights’ just to make it easy for us to refer to them.
Inference & Planning
Inference is the generic name for answering questions about variables in the factor graph given evidence. Examples of such queries include, “given noisy observations till now what is the best estimate of the current state”, “what is the most likely state-trajectory of the agent in the last 10 steps”. etc.
One instance of an inference query is planning, the simplest example of which is: find the shortest action sequence from the start state to a goal state.
Belief propagation: Inference/Planning using local computations.
Inference/planning computations, done poorly, can require an exponentially complex search in the worst case. Belief Propagation is an algorithm for efficiently solving inference/planning problems on the factor graph using only local computations. It works extremely well on factor graphs like this.
Belief Prop involves the variable nodes and factor nodes exchanging ‘messages’. These messages can be thought of as evidential support scores for the states of a variable. In the maze-case, each message is a buffer of length N, where N is the number of states in the maze graph, (The graph with diamond nodes in our first figure).
Have a look at the figure below to see what these messages mean.
There is an important detail to note in the above figure:
The gossip-message node sends to the right excludes the gossip it heard from the right, and similarly for the left. This detail is important to make BeliefProp work, and we’ll come back to this again soon.
What the variable nodes and factor nodes compute
Each node in the factor graph does the following during belief propagation:
- Read the messages from the neighbors and sensations/actions.
- Compute outgoing messages to neighbors and sensations/actions.
- In addition, each variable node also computes a “belief”, which has scores for evidential support for its states given all the messages it has consumed so far.
The figure above details the computations inside each node. It’s included here for completeness – you can skip the details and still follow the rest of the argument.
Computation graph message flow of belief propagation.
If you connect the variable nodes and factor nodes together, this is what the computation graph and message flow looks like for BeliefProp.
Some cool properties of BeliefProp
On factor graphs like the one we considered here (chains), and in general on non-loopy factor graphs, Belief Prop has the following nice properties for the usual planning/inference queries:
- No hyperparameters!
- Guaranteed to converge and give the right answer efficiently and quickly.
- Many possible propagation schedules, all guaranteed to work!
The figure above shows different message propagation schedules. Slightly different versions of BeliefProp can compute marginals or Maximum-a-posteriori (MAP) solutions. These are also known as sum-prop, and max-prop. For planning, we are mostly interested in finding a joint configuration of states and actions, which corresponds to the max-prop variant. The computations are often implemented in the log domain.
A crucial detail that makes BeliefProp work is precisely what STA got wrong!
The setup for STA is very similar to the setup for BeliefProp. They share the unrolled graph, messages flowing in both directions, and the idea of trying to arrive at the best trajectory as a settling process that evaluates multiple options in parallel.
There is an important detail that makes Belief Prop work — don’t double-count the evidence because that results in reinforcing false beliefs. Informally, it’s this: If your friend gossiped with you about someone and later you gossiped the same thing back to him, and if he takes that as new evidence, it can result in false beliefs getting amplified.
BeliefProp avoids false counting by making sure the message received from a neighbor is not incorporated into the message sent to that neighbor. You can inspect the computation graph above to affirm this. Unfortunately, STA gets this wrong as seen by the computation graph below: it re-circulates evidence received from a node back to that node. This can also be seen from the equations in the paper.
The following visualizations show BeliefProp and STA finding the shortest path in one of the mazes in the paper. The first panel is BeliefProp, which converges to the correct answer in 8 iterations. What’s shown are the left (Forward) and right (Backward) message buffers in each variable node and the combined “belief” (q) message in each variable node of the factor graph.
The following panel is STA. It fails to find the solution after 400 updates.
This only gets worse for STA as you increase the problem size. Given below is what happens in a 15x15 maze increasing distance to goal. BeliefProp returns the right answer always but STA fails after a separation threshold.
Even for the simpler problems STA has many hyper parameters that need to be set correctly, and there are further tricks involved in how reward is conveyed to the model to get it working. The reason for all this: polluting forward/backward (or left/right) counts by mixing them every step.
The STA paper’s rationale for this approximation is very weak
So what’s the motivation for this approximation, when we know that BeliefProp is exact and efficient in this setting? Unfortunately, the paper doesn’t motivate this very much!
The only reason given is expressed in these 7 words on page 18: “but that requires three separate neural populations”, which I interpret as BeliefProp utilizing separate buffers to keep the forward and backward counts from polluting each other.
Interestingly, STA also requires three neural populations! STA needs to 1) Take messages from left and pass it through W, 2) Take messages from right and pass it through W, and 3) then combine. In a neural circuit 1 & 2 will be implemented as a dedicated hardware (unlike in a software implementation where you could reuse the buffers). Since these intermediate results need to be calculated for every time index anyway, reading from the intermediate result buffers calculated in the previous time step is just a small wiring difference (see figure below). At the very least, this requires further elaboration and a trade-off analysis.
Moreover, the number of buffers (neural populations) used also depends on how BeliefProp itself is implemented, and how it is mapped to cortical circuits. Shown below is a re-arrangement of computations that may use fewer buffers for BeliefProp — in this case, the variable nodes broadcast the same message to every factor node, the factor nodes divides out the message it sent previously to avoid the double counting, which again is a standard technique in BeliefProp implementations.
While the authors are aware of the nature of the approximation, they might have underestimated how destructive STA’s approximation is, especially when the compensating advantage is unclear. The KL divergence derivation in the appendix cannot detect this because the error is built into its local objectives and it doesn’t measure the accuracy against the true posterior.
The paper also misframes the ‘mode-seeking’ behavior they observed as a result of its factorized approximation. This misattribution arose because they considered only marginalization (sum-product) as the exact baseline. The mode-seeking behavior the paper observed, desirable for a planning solution, is naturally obtained in max-product BeliefProp without the approximation-induced spurious local minima.
Loopy Belief Prop is different, and should not be confused with STA
The theoretical guarantees for convergence and exactness of BeliefProp apply only when the factor graph is a chain (all examples in STA are chains) or a tree. But empirically, just applying the same BeliefProp algorithm is also known to work well when the factor graph has loops in it. This is known as Loopy BeliefProp — it is the same algorithm, just applied to more complex factor graphs. One core difference between standard BeliefProp and Loopy BeliefProp is that propagation and damping schedules become important for convergence and accuracy.
Loopy BP should not be confused with STA. In loopy BP, evidence recirculates due to the overall topology of the factor graph even when the BP algorithm is trying to keep left/right (or forward/backward) counts separate locally, which is very different from STA which destroys the counts locally itself.
(Another note: The maze topology being loopy is not the same as the factor graph being loopy. All the nodes in the maze-graph become just one node in the factor graph, so the navigation/planning factor graph is never loopy).
Evaluating all trajectories and multiple time-steps simultaneously is a property of BeliefProp & message-passing
The STA paper highlighted the property of representing all time steps simultaneously and applying all actions at all times, to evaluate multiple futures in parallel. This is a property of message-passing algorithms, including BeliefProp, not just STA. Hopefully I have convinced you that parallel evaluation of multiple futures is how BeliefProp (message-passing) works. At every time step, message-passing applies the effect of every action (not just one action), from every state! It’s searching in a super-position of states, and it still works. It is way more efficient than sequential search. This is why learning representations that enable message-passing based planning might be an important path toward efficiently plannable world-models.
Did RNN’s in the paper learn to plan like STA?
The reason why I would be interested in this question is not because of STA itself, but any evidence that is interpreted as supporting STA might also be evidence for BeliefProp. However, the following details temper my enthusiasm:
- The RNN is trained on expert trajectories extensively using an optimal planner’s output as the training target on a tiny 4x4 maze. The presence of the optimal planner presupposes the very planning ability the model is trying to learn. In addition, there is no held-out evaluation for planning performance.
- Effectively, the RNN might be compiling an optimal planner's input-to-output mapping into its weights. Since the reward input is removed after planning, the RNN has to act like a seq2seq model whose state must carry the information needed to produce the upcoming trajectory, so the decidability of future position isn’t too surprising to me.
A prevalent view in neuroscience is that recurrent attractor networks—and generic RNNs—are the natural neural substrate for holding competing hypotheses in parallel and iteratively settling onto an optimal path. Yet belief propagation is itself a local, iterative computation that does the same in a more general setting, and with exact guarantees. Because these computations rely only on local weighted sums or maxes and normalization, they can also be implemented directly with neurons; the fact that standard RNNs use artificial neurons is no reason to treat them as the only plausible substrate for iterative neural computation. The circuit that does unrolled belief propagation itself can be learned directly with minimal assumptions. While meta-learning a BeliefProp circuit in RNNs is an interesting direction, more experiments are needed to see how feasible this idea is, and under what conditions.
References to learn more about Belief Prop and its potential role in planning/inference in the brain.
If you want to learn more about message-passing based inference and its connections to the brain, here is a biased list of references:
- Probabilistic Reasoning in Intelligent Systems: The classic book from Judea Pearl. Worth knowing what’s in there.
- Generalized Distributive Law: A fun paper connecting many algorithms
- Loopy Belief Propagation, a revolution
- A generative model for vision: Learns a hierarchical representation such that vision problems can be solved using Loopy Belief Prop. The factor graph for vision is very loopy. Companion paper A detailed mathematical theory of cortical microcircuits for visual inference gives a detailed biological circuit mapped to cortical anatomy, that implements the loopy belief prop computations in the paper first paper.
- Clone-structured graphs for cognitive maps: Learns a latent graph model for cognitive maps in partially observable environments such that Belief Prop can be used for planning.
- What kind of inference is planning? Planning with Loopy Belief Prop in factored-state MDPs.
That is most of what I wanted to say about the potential connection between BeliefProp and planning in the prefrontal cortex, but there are some additional comments that might be relevant for those who are reading the STA paper. That continues after this divider.
Some additional comments about the STA paper
Why “space” might cause confusion in the STA paper.
One source of confusion in the STA paper is the use of the word “space” itself. The paper describes two adjacencies being represented — spatial adjacency, and temporal adjacency. This can be confusing because there is really only one adjacency in the whole set up: state-transitions. The states themselves can be arranged arbitrarily in space. ‘Spatial adjacency’ doesn’t play any role in the algorithms.
Comparison experiments are somewhat weak
- Example, the TD method wasn’t given the goal information in the dynamic setting, so it’s not surprising that STA wins here. So while the subtitle “Only the STA solves dynamic tasks” grabs attention, it is true mostly by experiment design.
- Model-based planners, and BeliefProp should have been a baseline.
- Piray & Daw (2021) linear RL would have produced a stronger baseline than flat SR because this more recent work overcomes some of the shortcomings of SR.
Narrative-forward exposition
I think the paper’s exposition focuses too much on the narrative: the main text builds the story through analogies and strong claims, while the approximations, caveats, and limitations appear mostly in the methods and appendices.
Here’s one example that tripped me, and I had to look at the code to confirm that the RNNs are trained on expert trajectories. The main text says only that the RNNs were ‘trained with supervised learning to generate optimal actions,’ which can be read as training the networks to perform optimally. The surrounding framing in that paragraph only adds to the ambiguity. In Methods, the imitation setup is mentioned only in passing, in a sentence about tie-breaking. The discussion section, which would have been a good place to clarify this limitation, choses to frame this as ‘learning from repeated experience’, compounding the ambiguity.
Epilogue
I think the direction the authors have set out on is exciting. Planning by evaluating multiple trajectories in parallel, like in BeliefProp, might be a key property of the world models that humans and other animals build. The El-Gaby experiments are suggestive of a message-passing infrastructure for planning in the PFC, and this is an area ripe for interdisciplinary research.
As AI advances, our traditional publication models are going to be challenged. We will have to experiment with faster ways of how research is conducted, published, reviewed, promoted, and adopted. eLife is experimenting with a new publication model, and even if we disagree with the current model, we can agree that experimentation is necessary to arrive at something better, and I applaud that spirit of experimentation.
Acknowledgments
Thanks to Weinan Sun, Alan Zheng, Tala Fakhoury, Max Bennett, and Jan Zimmerman for their helpful comments.
Be the first to comment on this publication.