This brief post is meant to inspire and to start an open dialogue. I am genuinely curious to listen and incorporate your opinions, challenges, and insights.
The Context
I have been pondering for some time about the fact that Multi-Layer Perceptrons are known to be universal approximators and good learners, and yet, they are clearly not as useful as Transformers. The general consensus is that it's mostly due to performance limits: that is definitely true, but the explanation never felt satisfactory to me.
Intuition suggests that self-attention enables contextual-based learning, as opposed to memorization-based learning. Until some days ago, I couldn't point my finger to what "contextual" really meant in practice.
The eye opener was this paper, The Bayesian Geometry of Transformer Attention: I am not going to discuss it since that is beyond my competence, but one of its merits is in posing the correct question: can pure in-context learning be identified at all? The authors succeeded in exactly that: they brainstormed a tool called Bayesian wind tunnels, in which learning is possible, but memorization is prohibitively expensive and doesn't improve the learning process. And they proved exactly what is anecdotically well-known in the ML community: MLPs memorize, while Transformers contextualize. The paper's findings go well beyond this major insight; however I am going to stop here and, instead, I'll follow a tangential path and pose the next correct question: is attention, in the form of automatic contextualization, something that can be formally defined regardless of the chosen ML architecture?
Let me explain the reason why I am interested into this specific question:
we humans know very well what attention means. Most animals can clearly show when they attend to something. That seems to indicate that it may be an emergent phenomenon in the biological world
if attention can be defined, then it will be possible to ask if it is present or not in some model or in some living being. Attention seems to be a major component of consciousness (but likely not sufficient to determine it)
if attention unlocks highly-performant learning, we can attempt to optimize it, and even design it into different architectures - e.g. in diffusion models. We could even measure it, to find out when it is high or low.
Those are all good reasons to discuss about it.
My Hunch
Let me explain what attention seems to be, in general: the correct framing is to use Bayesian Belief propagation, where evidence is used to update your beliefs. What is a context here? It's some collection of trainable queries[1], where each query may happen to explain very well the evidence - in the sense that it can be optimized to minimize its surprise effect, aka the entropy. Lots of queries, lots of context. Where is the interesting idea? The interesting idea is that you may want to reuse the queries: in probabilistic terms, you may want to marginalize them, so they become independent among each other and separated from the evidence.
Once you have lots of queries, you form a big context: you can use it to gate away the information you don't need, and to route the remaining evidence in the belief graph.
At inference time, attention is the factorized, query-gated marginalization of a belief over evidence.
That explains the what, but somehow that's a very static picture. How to describe its dynamics? We could simply minimize entropy everywhere, but there is another way to look at the optimization process: the major insight is that a single layer of a single-head transformer can be interpreted as a REINFORCE loop in Reinforcement Learning. Therefore:
At training time, the marginals are optimized by implicit policy-gradient dynamics for evidence selection, where the ultimate long-run objective is the minimization of entropy.
You can replace entropy with variational free energy, if you prefer to discuss biological minds or robots.
Please note that complexity of the resulting interactions: you need to minimize the global cost (that's pretty much cross-entropy, even for belief updates) while also minimizing the entropy on each node of the graph hosting a query. It is known that transformers, at the first order, seem to implement the EM algorithm for belief propagation: that means that queries converge earlier (mostly driven by information-theoretic forces), while values (=selected evidences) converge more slowly, and carry semantic meaning.
Final technical note: a softmax normalization is usually needed, since it acts as an auto-centering baseline, and it tames its variance. This is what is used in practice in most variants of the transformer architecture.
Caveat aside, I think we can define attention in a way that is architecture-agnostic. That was the whole purpose of this brief post.
Who I am
My name is Gianluca Calcagni, born in Italy, with a Master of Science in Mathematics. I am currently (2026) working in IT as a consultant with the role of Salesforce Certified Technical Architect. My opinions do not reflect the opinions of my employer or my customers. Feel free to contact me on Twitter or Linkedin.
This brief post is meant to inspire and to start an open dialogue. I am genuinely curious to listen and incorporate your opinions, challenges, and insights.
The Context
I have been pondering for some time about the fact that Multi-Layer Perceptrons are known to be universal approximators and good learners, and yet, they are clearly not as useful as Transformers. The general consensus is that it's mostly due to performance limits: that is definitely true, but the explanation never felt satisfactory to me.
Intuition suggests that self-attention enables contextual-based learning, as opposed to memorization-based learning. Until some days ago, I couldn't point my finger to what "contextual" really meant in practice.
The eye opener was this paper, The Bayesian Geometry of Transformer Attention: I am not going to discuss it since that is beyond my competence, but one of its merits is in posing the correct question: can pure in-context learning be identified at all? The authors succeeded in exactly that: they brainstormed a tool called Bayesian wind tunnels, in which learning is possible, but memorization is prohibitively expensive and doesn't improve the learning process.
And they proved exactly what is anecdotically well-known in the ML community: MLPs memorize, while Transformers contextualize.
The paper's findings go well beyond this major insight; however I am going to stop here and, instead, I'll follow a tangential path and pose the next correct question: is attention, in the form of automatic contextualization, something that can be formally defined regardless of the chosen ML architecture?
Let me explain the reason why I am interested into this specific question:
Those are all good reasons to discuss about it.
My Hunch
Let me explain what attention seems to be, in general: the correct framing is to use Bayesian Belief propagation, where evidence is used to update your beliefs.
What is a context here? It's some collection of trainable queries[1], where each query may happen to explain very well the evidence - in the sense that it can be optimized to minimize its surprise effect, aka the entropy. Lots of queries, lots of context.
Where is the interesting idea? The interesting idea is that you may want to reuse the queries: in probabilistic terms, you may want to marginalize them, so they become independent among each other and separated from the evidence.
Once you have lots of queries, you form a big context: you can use it to gate away the information you don't need, and to route the remaining evidence in the belief graph.
That explains the what, but somehow that's a very static picture. How to describe its dynamics? We could simply minimize entropy everywhere, but there is another way to look at the optimization process: the major insight is that a single layer of a single-head transformer can be interpreted as a REINFORCE loop in Reinforcement Learning. Therefore:
You can replace entropy with variational free energy, if you prefer to discuss biological minds or robots.
Please note that complexity of the resulting interactions: you need to minimize the global cost (that's pretty much cross-entropy, even for belief updates) while also minimizing the entropy on each node of the graph hosting a query. It is known that transformers, at the first order, seem to implement the EM algorithm for belief propagation: that means that queries converge earlier (mostly driven by information-theoretic forces), while values (=selected evidences) converge more slowly, and carry semantic meaning.
Final technical note: a softmax normalization is usually needed, since it acts as an auto-centering baseline, and it tames its variance. This is what is used in practice in most variants of the transformer architecture.
Caveat aside, I think we can define attention in a way that is architecture-agnostic. That was the whole purpose of this brief post.
Who I am
My name is Gianluca Calcagni, born in Italy, with a Master of Science in Mathematics. I am currently (2026) working in IT as a consultant with the role of Salesforce Certified Technical Architect. My opinions do not reflect the opinions of my employer or my customers. Feel free to contact me on Twitter or Linkedin.
Revision History
[2026-10-26] Post published.
You can think of them the same as experiments in Active Learning.