Skip to main content
UKPMC Funders Author Manuscripts logoLink to UKPMC Funders Author Manuscripts
. Author manuscript; available in PMC: 2026 Apr 25.
Published in final edited form as: Cogn Neurosci. 2025 Jul 31;16(1-4):43–48. doi: 10.1080/17588928.2025.2537960

Closing the box

Thomas Parr a,, Giovanni Pezzulo b, Karl Friston c
PMCID: PMC7619033  EMSID: EMS213373  PMID: 40741890

Abstract

We were grateful for the level of engagement and insight from the commentaries on our discussion article, and for the opportunity to pick up on some of the common themes in what follows. Several commentaries focused upon the degeneracy in the relationship in how an internal model – of the sort that might be used either by an AI system or by our brains – might be formulated and the way in which this degeneracy might be resolved. Further themes were the role of model width as opposed to depth, the phenomenology of non-Markovian time, and a useful reminder that linguistic communication is necessarily a multi-agent, collective, endeavor.

Keywords: Memory, attention, transformers, language, prediction

Same problem, different solution?

The phrase ‘closing the box’ in the title is a reference to a procedure used in graphical models, specifically Forney factor graphs (Loeliger et al., 2007), to represent the operation of marginalization. This is analogous to the computation of a partition function for a physicist (Landau & Lifshitz, 1980) or to the computation of model evidence for a statistician (MacKay, 1991). Curiously, it is a procedure that can be interpreted both as the transformation of a model from one form to another, equivalent, form, and as the process of forming inferences about the variables in that model by message passing. The reason this is relevant is that several of the commentaries – associated with our discussion paper – highlighted, in different ways, the insight that we might not have to choose between auto-regressive models and deep temporal models – the two may be entirely equivalent. Perhaps it is just the inferences used to solve them that differ.

This has relevance for the hardware (Muir & Sheik, 2025) or wetware (Isomura et al., 2023; Kagan et al., 2022) used to solve such problems, as solutions based upon distributed sparse message passing might be very well suited for the sorts of synaptic communication in biological brains (Parr et al., 2019). In contrast, the dense connectivity required prior to the application of an attention operator requires a different sort of computational architecture – or might rely upon densely connected (e.g., cortico-subcortical loop) subnetworks within the brain (Granier & Senn, 2025). The process theories (Friston et al., 2017) describing how a physical system might perform inference will differ based upon the system.

Figure 1 highlights the relationship between message passing and marginalisation by using successive marginalisations (‘box closures’) to reformulate a deep temporal model as an autoregressive process. Boxes drawn around groups of factors indicate the summation or integration over all variables within those boxes, leading to the merging of multiple factor nodes in the following graph. This is the same procedure used to compute messages in sum—or integral—product Bayesian message passing schemes (Mooij & Kappen, 2007). This figure reinforces the points made by Singh et al. (this issue) and by (Sajid & Medrano, this issue) in showing, graphically, the equivalence between the two model architectures. One could argue that this means our brains use both deep temporal and autoregressive models, with the latter obtained in the final stages of synaptic message passing used to solve the former. This is an entirely reasonable interpretation. To unpack this further, particularly in relation to neurobiology, it will be useful to address questions of depth and width in generative models as raised by some of the other commentaries.

Figure 1.

Figure 1

From deep temporal models to autoregression. This figure illustrates, through successive box closures, the transformation of a deep temporal (upper graph) to an autoregressive (lower graph) model architecture. Please see (Parr et al., this issue) for details of the graphical formalism. At each step, the factors outlined by the dashed green boxes are combined (by marginalizing over all variables on the internal edges) to give the green factors in the diagram below. The green arrows offer an interpretation of this process in terms of recursive message passing. The final graph, in which the previous values become part of the conditioning set for the green factor, depends upon renormalizing the graph such that the variable on the lower vertical edge of the green factor sums (or integrates) to one. This occurs implicitly when passing messages that originate from previous observations

Depth or width?

One could see the relationship above as analogous to that in which generative models based upon Gaussian processes can be re-expressed in terms of kernel operations (Rasmussen, 2004). Kernel methods predict datapoints based upon some function of previously measured datapoints, rather than from posterior inferences of hidden states. Figure 2 illustrates this idea for a model that predicts data given some explanatory variables. The upper left graph might be consistent with a simple linear model, with the edges coming in from the top representing independent variables (i.e., regressors) whose impact on measured data depends upon some common set of parameters (i.e., regression coefficients) shown along the horizontal line. An alternative expression of the same model is shown in the lower right, following box closures. Here, we have a factor that predicts the rightmost datapoint given all previous pairs of independent and dependent variables and the independent variable associated with the point to be predicted. Effectively, this is a kind of interpolation – which some would argue underwrites the power of all deep learning approaches (Belkin, 2021) – given some underlying metric space.

Figure 2. Thinking laterally.

Figure 2

This figure illustrates the importance of lateral, or horizontal connectivity in relation to some of the ideas in the commentaries. The graphics here illustrate two distinct points that both relate to lateral connectivity. The first point is illustrated in the upper right plot that shows the form of a deep temporal model whose lower level deals with the ordering of symbols, while the upper level factorizes these into temporally invariant (at least, over a short timescale) syntactic groups, replicating syntactic trees of the sort discussed by Murphy (this issue). The second point is illustrated by the sequence of graphs from the upper left to lower right that show the development of a kind of highly lateralized expression characteristic in models (Gaussian processes being a common example) expressed in terms of kernels. The edges coming into each diagram from the top are the independent variables (e.g., pixel location) paired with the dependent variables (e.g., pixel intensity) aligned vertically. By marginalizing out the parameters mediating the mapping from one to the other, we arrive at an interpolative function that predicts the value of a dependent variable given its associated independent variable and previously observed pairs. This interpolation depends upon a metric space—a key element of Kiefer’s (this issue) commentary.

This is an important point of contact with the thoughts (Kiefer, this issue) offers on metric spaces. Kiefer’s commentary is a response to the question we raised concerning the apparently categorical structure of language compared to the metric embeddings used in large language models. In Gaussian processes, interpolation is possible because one expects that small variations in the value of an independent variable will cause only small variations in the value of the dependent variable. However, metric relationships are less obvious when variables are categorical, like words. As Kiefer points out, categorical entities inherit an implicit metric structure from the dependencies in a generative model. For instance, sparse transition probabilities taking us from one point in time to the next impose topological constraints. It may be that to get from one state of the world to another, we must pass through an intermediate state. The relative plausibility of different paths through a categorical state space gives that space a measure of ‘nearness’—i.e., a metric. Perhaps it is this metric that is implicitly captured by the token embeddings on which large language models rely.

Bringing this back to neurobiology, this speaks to subtle differences in the ways in which neuronal networks might be organized. The equivalence between (at least some) autoregressive (or kernel-based) and deep temporal models raises some interesting hypotheses. If our brains solve deep temporal models directly, we might anticipate a hierarchical organization, with relatively sparse synaptic communication between regions representing different timescales. However, if they solve autoregressive models in which some variables have been marginalized out, we might anticipate a flatter organizational structure with dense lateral connectivity within a given hierarchical level. Interestingly, there is evidence for both patterns of organization in biology (Felleman & Van Essen, 1991; Kiebel et al., 2008; Stettler et al., 2002; Zeki & Shipp, 1988), a prominent example being the use of neural field theories – that explicitly incorporate spatiotemporal connectivity kernels – to explain the spread of activity across neuronal populations (Coombes, 2005). This has particular relevance for the commentary by (Queißer et al., this issue), who highlight the importance of lateral connectivity, and argue convincingly that features of hierarchical processing can sometimes be replicated by shallow – but highly factorized – systems, in which different factors mutually contextualize one another. In other words, model width may be as important as (perhaps more important than) depth.

(Murphy, this issue) provides a useful illustrative example, by emphasizing factorization in language of the sort that might underwrite syntactic tree diagrams. The core idea here is that having temporal hierarchy is not enough. Once we have hierarchical levels that represent variables that are slowly changing – such that they appear constant during expression of a simple phrase – syntactic structure depends upon a careful accounting of the factorial structure at that timescale. The upper right panel of Figure 2 highlights how this might work in a model of the deep temporal sort, using colors in place of the symbols in the commentary. The horizontal factorization occurs at a higher, and therefore slower, level than the faster sequence below. The ordering into the sequence appropriate for a given ‘language’ is mediated by the messages passed to the level below. A treelike structure is represented by representing the combination of the red and green balls as a single factor, with the purple ball a factor of its own, replicating the grouping in the syntactic notation shown below. Further hierarchical levels, and their factorizations, might further decompose this tree.

Time, agency, and communication

(Albarracin & Sakthivadivel, this issue) brings things back to our original premise – that one of the core challenges we face in characterizing complex language-like sequences is that they are highly non-Markovian and require models that incorporate long-range dependencies in time. If this were not the case, there would be no need for memory, as the present would tell us everything about the future without needing to recall past events. Albarracin and Sakthivadivel link this to concepts of consciousness and temporal depth, and to the non-Markovian explanations we use to account for the behavior of other creatures more generally. In short, when the observations we make of another creature are non-Markovian, we call upon the concepts of plans or policies that creature may have to explain this.

These themes of temporal extension, agency, and observation of others foregrounds the commentary by Taniguchi (this issue), who reminds us that language is ultimately a collective endeavor. One of the things that makes neurobiology so exciting is that to understand the nervous system, one must understand the world with which it interacts. When that world includes other creatures with nervous systems, capable of speech, then the problem of representing sequences of words cannot be dissociated from the communicative intent of speech and the use of language both to achieve preferred states and to seek answers to questions to resolve uncertainty about our environment and the entities that inhabit it. Perhaps it is the latter that necessitates linguistic internal models that are minimally ambiguous – and might explain why (Equation 9 of our discussion article (Parr et al., this issue)) the objectives for active learning (Friston et al., 2024) and training of autoregressive models appear so similar.

Conclusion

In addition to the technical meaning outlined above, the phrase ‘closing the box’ might be interpreted in terms of the differing agendas of scientific and engineering disciplines. It is relatively common to hear deep learning architectures described as ‘black box’ systems – meaning they are mechanistically opaque. This is not necessarily problematic if one seeks to produce a specific functional outcome. However, scientific investigation depends upon trying to ‘open the box’ and articulate transparent accounts of what goes on inside to cause those functional outcomes. Transformers appear capable of (at least) approximating human linguistic behavior. Perhaps they offer an opportunity to open a box to better define the problem our brains solve when we converse.

Identical issues emerge in the identification of generative models in complex system modeling. In brief, the cause-effect structure of a dynamical system is generally parameterized in terms of a state-space model. For instance, the parameters might include the synaptic efficacies in a neural mass model for functional imaging (or electrophysiological) timeseries data. For any given parameterization, there exists a summary of the input–output relationships in terms of (Volterra) kernels, via the Fliess fundamental formula1 (Fliess, 1981). Volterra series can be thought of as analogous to a polynomial (Taylor) series expansion but in place of sums of polynomials, the terms of the expansion are convolutions of each Volterra kernel with previous measurements. The Volterra kernels can always be expressed in terms of a nonlinear autoregressive process that, effectively, maps data to data, without reference to latent states. Crucially, although one can always derive the kernels from the parameters of the generative model, one cannot derive the parameters from the kernels: see Table 1 in (Friston et al., 2014).

On this view, transformers learn the kernels, not the parameters of a generative model. In this sense, a closed-box architecture remains a black-box from the perspective of the generative model. This is problematic because one cannot place priors over the model parameters. In turn, this precludes Bayesian model selection and the ability to test hypotheses about different architectures (but perhaps allows one to test hypotheses about different kernels). The distinction between generative and autoregressive modeling underwrites some fundamental distinctions in neuroscience, e.g., effective versus functional connectivity, dynamic causal modeling versus Granger causality, mechanistic versus descriptive, and so on. In short, the way in which we close our boxes matters.

Funding

TP is supported by an NIHR Academic Clinical Fellowship [ref: ACF-2023-13-013]. KF is supported by funding from the Wellcome Trust [Ref: 203147/Z/16/Z]. GP is supported by the European Research Council under the Grant Agreement No. [820213] (ThinkAhead), the Italian National Recovery and Resilience Plan (NRRP), M4C2, funded by the European Union – NextGenerationEU (Project IR0000011, CUP [B51E22000150006], “EBRAINS-Italy”; Project PE0000013, “FAIR”; Project PE0000006, “MNESYS”), and the PRIN PNRR P20224FESY.

Footnotes

1

Technically, the Fliess fundamental formula means that any transformer architecture can be expressed as a functional Taylor expansion and thereby characterized in terms of (high order) Volterra kernels.

Disclosure statement

The authors declare that they have no known competing financial interests or personal relationships that could have appeared to influence the work reported in this paper.

References

  1. Albarracin M, Sakthivadivel DAR. Non-Markovian systems, phenomenology, and the challenges of capturing meaning and context. Cognitive Neuroscience. doi: 10.1080/17588928.2025.2523889. (this Issue) [DOI] [PubMed] [Google Scholar]
  2. Belkin M. Fit without fear: Remarkable mathematical phenomena of deep learning through the prism of interpolation. Acta numerica. 2021;30:203–248. doi: 10.1017/S0962492921000039. [DOI] [Google Scholar]
  3. Coombes S. Waves, bumps, and patterns in neural field theories. Biological Cybernetics. 2005;93(2):91–108. doi: 10.1007/s00422-005-0574-y. [DOI] [PubMed] [Google Scholar]
  4. Felleman DJ, Van Essen DC. Distributed hierarchical processing in the primate cerebral cortex. Cerebral Cortex. 1991;1(1):1–47. doi: 10.1093/cercor/1.1.1-a. [DOI] [PubMed] [Google Scholar]
  5. Fliess M. An algebraic approach to functional expansions, application to a singular optimal control problem. IFAC Proceedings. 1981;14(2):331–336. doi: 10.1016/S1474-6670(17)63505-5. [DOI] [Google Scholar]
  6. Friston K, FitzGerald T, Rigoli F, Schwartenbeck P, Pezzulo G. Active inference: A process theory. Neural Computation. 2017;29(1):1–49. doi: 10.1162/NECO_a_00912. [DOI] [PubMed] [Google Scholar]
  7. Friston KJ, Bastos AM, Oswal A, van Wijk B, Richter C, Litvak V. Granger causality revisited. Neuroimage. 2014;101:796–808. doi: 10.1016/j.neuroimage.2014.06.062. [DOI] [PMC free article] [PubMed] [Google Scholar]
  8. Friston KJ, Da Costa L, Tschantz A, Kiefer A, Salvatori T, Neacsu V, Koudahl M, Heins C, Sajid N, Markovic D, Parr T, et al. Supervised structure learning. Biological Psychology. 2024;193:108891. doi: 10.1016/j.biopsycho.2024.108891. [DOI] [PubMed] [Google Scholar]
  9. Granier A, Senn W. Multihead self-attention in cortico-thalamic circuits. arXiv preprint. 2025:1–12.:arXiv: 2504.06354. doi: 10.48550/arXiv.2504.06354. [DOI] [Google Scholar]
  10. Isomura T, Kotani K, Jimbo Y, Friston KJ. Experimental validation of the free-energy principle with in vitro neural networks. Nature Communications. 2023;14(1):4547. doi: 10.1038/s41467-023-40141-z. [DOI] [PMC free article] [PubMed] [Google Scholar]
  11. Kagan BJ, Kitchen AC, Tran NT, Habibollahi F, Khajehnejad M, Parker BJ, Bhat A, Rollo B, Razi A, Friston KJ. In vitro neurons learn and exhibit sentience when embodied in a simulated game-world. Neuron. 2022;110(23):3952–3969.:e3958. doi: 10.1016/j.neuron.2022.09.001. [DOI] [PMC free article] [PubMed] [Google Scholar]
  12. Kiebel SJ, Daunizeau J, Friston KJ. A hierarchy of time-scales and the brain. PLOS Computational Biology. 2008;4(11):e1000209. doi: 10.1371/journal.pcbi.1000209. [DOI] [PMC free article] [PubMed] [Google Scholar]
  13. Kiefer A. Embeddings as Dirichlet counts: Attention is the tip of the iceberg Cognitive Neuroscience. doi: 10.1080/17588928.2025.2530430. (this Issue) [DOI] [PubMed] [Google Scholar]
  14. Landau LD, Lifshitz EM. In: Statistical physics. Landau LD, Lifshitz EM, editors. Butterworth-Heinemann; 1980. Chapter IV - Ideal gases; pp. 111–157. [DOI] [Google Scholar]
  15. Loeliger HA, Dauwels J, Hu J, Korl S, Ping L, Kschischang FR. The factor graph approach to model-based signal processing. Proceedings of the IEEE. 2007;95(6):1295–1322. doi: 10.1109/JPROC.2007.896497. [DOI] [Google Scholar]
  16. MacKay D. Bayesian model comparison and backprop nets. Advances in Neural Information Processing Systems. 1991;4 https://proceedings.neurips.cc/paper_files/paper/1991/file/c3c59e5f8b3e9753913f4d435b53c308-Paper.pdf . [Google Scholar]
  17. Mooij JM, Kappen HJ. Sufficient conditions for convergence of the Sum-product algorithm. IEEE Transactions on Information Theory. 2007;53(12):4422–4437. doi: 10.1109/TIT.2007.909166. [DOI] [Google Scholar]
  18. Muir DR, Sheik S. The road to commercial success for neuromorphic technologies. Nature Communications. 2025;16(1):3586. doi: 10.1038/s41467-025-57352-1. [DOI] [PMC free article] [PubMed] [Google Scholar]
  19. Murphy E. Beyond prediction: Comments on the format of natural intelligence. Cognitive Neuroscience. doi: 10.1080/17588928.2025.2521403. (this Issue) [DOI] [PubMed] [Google Scholar]
  20. Parr T, Markovic D, Kiebel SJ, Friston KJ. Neuronal message passing using mean-field, Bethe, and marginal approximations. Scientific Reports. 2019;9(1):1889. doi: 10.1038/s41598-018-38246-3. [DOI] [PMC free article] [PubMed] [Google Scholar]
  21. Parr T, Pezzulo G, Friston K. Beyond Markov: Transfomers, memory, and attention. Cognitive Neuroscience. doi: 10.1080/17588928.2025.2484485. (this issue) [DOI] [PubMed] [Google Scholar]
  22. Queißer JF, Oyama H, Tani J. How deep will you go? Hierarchy in predictive coding and transformers. Cognitive Neuroscience. doi: 10.1080/17588928.2025.2518945. (this Issue) [DOI] [PubMed] [Google Scholar]
  23. Rasmussen CE. In: Advanced lectures on machine learning: ML Summer schools 2003, Canberra, Australia, February 2 - 14, 2003, Tübingen, Germany, August 4 - 16, 2003, revised lectures. Bousquet O, von Luxburg U, Rätsch G, editors. Springer; 2004. Gaussian processes in machine learning; pp. 63–71. [DOI] [Google Scholar]
  24. Sajid N, Medrano J. Dissociating model architectures from inference computations Cognitive Neuroscience. doi: 10.1080/17588928.2025.2532604. (this Issue) [DOI] [PubMed] [Google Scholar]
  25. Singh R, Tschantz A, Buckley CL. Paying attention to process. Cognitive Neuroscience. doi: 10.1080/17588928.2025.2520313. (this issue) [DOI] [PubMed] [Google Scholar]
  26. Stettler DD, Das A, Bennett J, Gilbert CD. Lateral connectivity and contextual interactions in macaque primary visual cortex. Neuron. 2002;36(4):739–750. doi: 10.1016/s0896-6273(02)01029-2. [DOI] [PubMed] [Google Scholar]
  27. Taniguchi T. Beyond individuals: Collective predictive coding for memory, attention, and the emergence of language. Cognitive Neuroscience. doi: 10.1080/17588928.2025.2518942. (this issue) [DOI] [PubMed] [Google Scholar]
  28. Zeki S, Shipp S. The functional logic of cortical connections. Nature. 1988;335(6188):311–317. doi: 10.1038/335311a0. [DOI] [PubMed] [Google Scholar]

RESOURCES