The Hidden Shape of What AI Knows

Geometry is quietly becoming the most honest way to look inside an AI system.

Topology · Mathematics · AI · Computer Science
The Shape of What We Know
A new branch of mathematics called topological data analysis is teaching machines to read the hidden geometry of thought itself.
2026

When a neural network learns to recognize a cat, something strange happens inside it. Millions of numbers shift in concert, a landscape of mathematical terrain reshapes itself, and somewhere in that transformation, the system acquires the ability to tell fur from fabric. But ask what that internal rearrangement actually looks like, and most tools for understanding machine learning give an unsatisfying answer. They can tell you the value of the loss. They can show you a histogram of weights. They cannot tell you the shape of what the network learned.

That gap has driven a growing community of mathematicians and computer scientists toward an unlikely toolkit: topology, a branch of mathematics that studies properties of space that survive bending and stretching. A sphere and a cube are topologically identical because one can be deformed into the other without tearing. A donut and a coffee mug share the same topology because each has exactly one hole. The field that has carried this thinking into data science is called topological data analysis, or TDA, and its core claim is that a cloud of data points has a shape, and that shape carries information no distance metric alone can recover. Over the last decade, researchers at institutions from Stanford to Lawrence Berkeley National Laboratory have applied TDA to some of the hardest problems in machine learning, from understanding why certain architectures train more smoothly to detecting when a language model is being manipulated. What they have found suggests the geometry of representation is not a side effect of learning. It is the story.

I. The Filtration

To understand what TDA actually measures, imagine placing a tiny bubble around every point in a dataset and slowly inflating all of them at once. At first, each bubble is an isolated island. As they grow, pairs touch and merge, triplets connect into triangles, larger clusters form. The entire sweep, from isolated points to a single undifferentiated mass, is called a filtration, and it encodes far more than any fixed snapshot of the data.

What topologists extract from this process is a record of when structural features are born and when they die. A connected cluster appears the moment two bubbles overlap; a loop is born when a chain of connections first closes on itself and dies when it gets filled in. These births and deaths are plotted in a persistence diagram, where features that live long, born early, dead late, are genuine structure, and features that flicker briefly are noise. The tool that makes this computationally practical is the Vietoris-Rips complex. A library called Ripser runs the same calculations more than 40 times faster than earlier methods, and Python toolkits like GUDHI brought TDA out of pure mathematics and into machine learning pipelines. A foundational stability theorem ties it all together: small perturbations to the data produce only small changes in the persistence diagram, which means the descriptors are measuring something real.

01 How a filtration works
Bubbles inflate around every data point. As they grow and overlap, edges form, triangles fill in, and a topological structure emerges. The persistence barcode below records which features are born, how long they survive, and when they die — separating genuine structure from noise.
Stage 1: radius = 0 Stage 2: radius grows Stage 3: radius larger 5 components, 0 loops 1 component, 1 loop born 1 component, loop dies Persistence barcode Each bar = one topological feature. Width = how long it persists (birth to death). β₀ comp. ∞ β₁ loops Filtration radius 0 large born dies component (β₀) loop (β₁) Long bars = real structure. Short bars near the diagonal = noise.
Connected components (β₀)
Loops (β₁)
II. Reading the Loss Landscape

A 2024 study from Lawrence Berkeley National Laboratory asked a question practitioners argue about constantly: why do residual connections make networks so much easier to train? Standard visualizations of loss surfaces had suggested they smooth the terrain, but those plots project from a space with millions of dimensions down to two, and such projections discard nearly everything meaningful.

The researchers instead built a merge tree from each loss surface, a topological object that tracks how separate low-loss basins appear and connect as a threshold rises. A ResNet-20 trained with residual connections intact collapsed to a single basin with no saddle points between it and the global minimum. The same network without residual connections fractured into a landscape dense with saddle points, each a place where optimization can stall. The merge tree made quantitative what visualization had only gestured at, coordinate-free and immune to projection artifacts. The same framework extended to physics-informed neural networks pushed into difficult regimes: their landscapes developed the same topological signature of proliferating saddle points and low average persistence, and the topological summary flagged the deterioration before standard training metrics did.

02 Loss landscape topology
Two cross-sections of a neural network loss surface. Left: a smooth single basin with residual connections intact and a clean merge tree. Right: a fractured, saddle-point-dense surface without them. The merge tree makes the topological difference quantitative.
global minimum With residual connections Merge tree 1 basin 0 saddle points threshold rising saddle points Without residual connections Merge tree 3 basins multiple saddle points local basin (filled) saddle point (open) Merge tree encodes topological complexity of the loss surface
Local basin
Smooth single basin (residuals intact)
III. What Happens Inside

If the loss landscape is the terrain a network navigates during training, the activation space is where it keeps everything it has learned. Each input to a trained network produces a vector of activations at every layer, and those vectors taken together form a point cloud in high-dimensional space. That cloud has topology, and studying it turned out to reveal something fundamental about learning itself.

A landmark study from the University of Chicago statistics department ran more than ten thousand experiments on image classifiers and found that well-trained networks operate by progressively simplifying the topology of their data. At the first layer, activation clouds of different classes are entangled and complex, riddled with loops, holes, and disconnected fragments. Layer by layer, the network contracts and fuses those clouds until each class collapses into a single connected component with no holes. The topological complexity, measured by Betti numbers, falls toward zero as accuracy rises. The research also offered a geometric answer to a long-standing empirical puzzle: why do deeper networks outperform shallower ones on complex tasks? Because higher topological complexity in the input requires more layers to unravel. The depth requirement is not a quirk of optimization. It is a topological necessity.

Topological data analysis visualization

A persistence diagram from a trained image classifier. Each point represents a topological feature of the network's activation space. Points far from the diagonal, born early and dying late, correspond to genuine learned structure. Points near the diagonal are noise.

IV. Toward the Shape of a Thought

The most speculative direction in TDA research circles a question that has animated AI for decades: whether machines can reason about structure, not just recognize patterns. Topological descriptors are unusually well suited to the attempt. Connected components in a persistence diagram correspond naturally to concept clusters. Loops correspond to cyclic relationships. If a network has built a genuinely structured representation, the topology of its activation space should reflect that structure in a form readable without ever inspecting the weights.

Two recent results suggest this is already happening. A 2025 study from Imperial College London computed persistent homology of activations across six large language models and found that barcodes cleanly separated normal inputs from adversarial ones: prompts poisoned through backdoor fine-tuning produced a measurable topological compression in the latent space, invisible in the model's output but visible in its geometry. A 2026 preprint found that the onset of generalization in a network trained on modular arithmetic, the grokking phenomenon, coincides with a sharp increase in the persistence of loops that mirror the cyclic group structure of the task. The network was not just getting answers right. It was building a topological representation of the underlying pattern. The shape of what we know, it turns out, is not a metaphor. It is a measurement waiting to be taken.

03 From activations to meaning
A five-stage pipeline showing how TDA transforms raw neural network activations into symbolic, human-readable structure. Each stage peels back a layer of abstraction until the topology of what a model learned becomes visible.
Activation cloud Network hidden layers point cloud Filtration Vietoris-Rips complex growing radius Persistence diagram Birth and death of features birth death β₀ β₁ Topological features β₀, β₁, persistence scores • Connected component count • Loop count and persistence • Void (β₂) presence • Barcode stability score interpret Symbolic structure Human-readable topology β₀ cluster = concept group β₁ loop = cyclic relation gap = failure or blind spot Topological features are coordinate-free and stable under small perturbations, making them reliable descriptors of what a model has learned.
Filtration and persistence
Persistence diagram
Topological features

Key references: Loss landscape topology study, Lawrence Berkeley National Laboratory in collaboration with university statistics groups, 2024. "Topology of Deep Neural Networks," University of Chicago Department of Statistics, Journal of Machine Learning Research, 2020. "The Shape of Adversarial Influence: Characterizing LLM Latent Spaces with Persistent Homology," Imperial College London, arXiv, 2025. "Topological Signatures of Grokking," arXiv preprint, 2026. Bauer, U., "Ripser: efficient computation of Vietoris-Rips persistence barcodes," Journal of Applied and Computational Topology, 2021. GUDHI Library, Inria, gudhi.gforge.inria.fr. Topological data analysis tools referenced in this article, including Ripser, GUDHI, and Mapper, are open source and available for research use.