The Geometry of Belief: How Transformers Transcend Memorization to Master Bayesian Logic
When a Transformer maintains perfect entropy calibration on sequences 2.5x longer than its training data while MLPs fail, does this prove it has transcended rote memorization to truly master the universal algorithm of belief updating?

The Geometry of AI Reasoning: How Transformers Learn Bayesian Logic
In the world of artificial intelligence, a fundamental question hangs over the field: are the large language models (LLMs) we use daily genuinely "thinking" and "reasoning," or are they merely mimicking and parroting patterns from the vast datasets they've ingested in an incredibly sophisticated way?
This is the heart of the "Stochastic Parrots" versus "Reasoning Engines" debate.
Answering this is notoriously difficult, largely because natural language is inherently ambiguous, and the internet's corpus is so immense that it's nearly impossible to determine if a model's answer stems from true logical deduction or simply from having "memorized" a similar problem. A recent paper from Columbia University, however, offers a clear, empirically-grounded answer.
Titled The Bayesian Geometry of Transformer Attention, the paper cleverly sidesteps the quagmire of natural language. The researchers designed a controlled mathematical environment called the "Bayesian Wind Tunnel." Think of it like engineers testing an aircraft model in a wind tunnel rather than flying a prototype directly into a storm—it allows us to quantitatively measure the model's true capabilities under perfectly controlled conditions.
This "wind tunnel" has two critical features:
- A near-infinite problem space: The realm of possible questions is enormous (e.g., over 10⁴⁰ combinations), making it impossible for the model to succeed through rote memorization.
- A single, verifiable correct answer: For these mathematical tasks, the correct probability distribution at every step has a precise analytical solution, calculable via Bayes' theorem.
With such an experimental setup, we can directly test if a Transformer can actually perform the complex operations its architecture promises.
Wind Tunnel Tests: The Necessity of the Attention Architecture
The researchers designed two core experiments to test whether a Transformer can think like a true Bayesian statistician.
Experiment 1: The Art of Elimination
The first task, Bijection Learning, can be thought of as a simplified version of a "guess the name" game. The rules are simple: there are 20 symbols with hidden one-to-one pairings. Each time you see a pair (e.g., X -> A), you gain a piece of information. The core of Bayesian inference is that with each new piece of information, uncertainty (entropy) should decrease accordingly.
The results revealed a stark architectural divide.
Bijection wind tunnel: transformer matches the Bayesian posterior; MLP cannot

source: Arxiv, The Bayesian Geometry of Transformer Attention
In the chart above, the blue line, representing the Transformer model's calculated uncertainty, almost perfectly overlaps with the orange dashed line—the mathematical optimum—with a mean absolute error (MAE) as low as 3 × 10⁻³ bits.
In contrast, an MLP with the same number of parameters but lacking the Attention mechanism (the yellow line) failed to learn. Its uncertainty curve is nearly flat, indicating it failed to grasp the concept of "elimination" altogether. This comparison powerfully demonstrates that the architecture of the Attention mechanism, not just the sheer number of parameters, is the key to this form of logical reasoning.
Experiment 2: Dynamic State Tracking
The second task is Hidden Markov Model (HMM) state tracking, which more closely resembles problems we encounter in macroeconomic research. Imagine the true state of the economy (e.g., "expansion" or "recession") is hidden, and we can only observe a series of economic data points. Our job is to infer the most likely current state based on this continuous stream of data.
This requires the model to perform recursive reasoning—to constantly update its "beliefs" in light of new evidence.
HMM wind tunnel: calibration across sequence lengths

source: Arxiv, The Bayesian Geometry of Transformer Attention
Once again, the Transformer demonstrated remarkable precision. As shown above, it not only matched the Bayesian posterior on the sequence length it was trained on (K=20) but, more importantly, it maintained high accuracy when generalized to sequences 2.5 times longer than its training data (K=50).
This provides strong evidence that the Transformer wasn't just memorizing patterns of a specific length but had truly learned the algorithm of Bayesian filtering itself. It grasped the universal ability to process information flow and update judgments over time.
The MLP, in stark contrast, produced results with an error rate over 5,000 times higher than the Transformer's, as it was essentially just outputting an average value.
Inside the Black Box: The Geometry of Reasoning
With these experimental results, the next natural question is: what is actually happening inside the Transformer?
By "dissecting" the model, the researchers observed a methodical, three-step geometric process that reveals the source of its reasoning ability.
Step 1: Building an Orthogonal Hypothesis Framework (Layer 0)
- Bayesian Logic: Before analyzing a problem, one must first define all possible scenarios.
- Model Behavior: The study found that the Transformer's very first layer (Layer 0) automatically maps all input "hypotheses" into a nearly orthogonal vector space. This means each hypothesis is given its own independent coordinate, preventing interference and laying the groundwork for subsequent elimination and selection.
Key Orthogonality

source: Arxiv, The Bayesian Geometry of Transformer Attention
Step 2: Sequential Elimination via Attention (Middle Layers)
- Bayesian Logic: As new evidence emerges, progressively rule out inconsistent hypotheses.
- Model Behavior: In the middle layers, the Attention mechanism begins its work of "routing" and "focusing." The Query vector (representing the current question) gradually aligns precisely with the Key vectors (representing historical information) that match the observed evidence, thereby achieving a geometric "suppression" of invalid hypotheses.
The "focusing" process of attention from Layer 0 to Layer 5


source: Arxiv, The Bayesian Geometry of Transformer Attention
Comparing the attention heatmaps of Layer 0 (top) and Layer 5 (bottom) visually illustrates this focusing process. In the deeper layer, attention concentrates almost exclusively on a few critical pieces of information—the geometric embodiment of Bayesian elimination.
Step 3: Unfolding the Value Manifold to Refine Confidence (Final Layers)
- Bayesian Logic: After eliminating impossible options, precisely calculate the posterior probability for each remaining hypothesis.
- Model Behavior: Late in training, the model develops a structure in its final layers known as "Value-Space Manifolds." The initially jumbled internal states unfold along a one-dimensional smooth curve parameterized by posterior entropy.
Value Manifold (PCA of final representation) at 150k steps

source: Arxiv, The Bayesian Geometry of Transformer Attention
This visualization looks like an exquisite clock. Each point represents a different state of uncertainty, with colors smoothly transitioning from high uncertainty (purple) to low uncertainty (yellow). This means the model has internally constructed a perfect "probability ruler," enabling it to finely quantify and calibrate its own confidence level.
Some Implications
The findings of this research point to several significant implications.
First, architecture dictates function. The Transformer's ability to reason is not accidental; its core Attention mechanism and Residual Stream provide a natural inductive bias for Bayesian computation.
Second, depth is crucial. The research shows that Bayesian inference is a layered, step-by-step refinement process. Removing any layer, especially the late-stage attention layers, causes a sharp decline in the model's reasoning ability, particularly when dealing with longer, unseen sequences.
Negative impact of disabling late-stage attention layers (No-Late-Attn) on model performance

source: Arxiv, The Bayesian Geometry of Transformer Attention
Finally, this work offers a valuable glimmer of hope for understanding the "black box." The geometric structures discovered in the paper—such as orthogonal keys, the sharpening of Q-K alignment, and the unfolding of the value manifold—could become effective diagnostics for determining whether an LLM is truly reasoning or simply "hallucinating."
In summary, this paper provides compelling evidence that the Transformer architecture is naturally suited to performing Bayesian inference. It accomplishes precise probability calculations within its internal vector space through a series of ordered geometric transformations.
Perhaps this means that the "machine intelligence" we have long sought has an underlying logic that is closer than we imagined to the beauty of pure mathematics.