From the parallel postulate to natural gradients, hyperbolic transformers, and flow matching on manifolds — every concept defined from scratch, with intuition, worked numbers, pictures, and the exact papers that turned the math into state-of-the-art AI.
Four topics, one idea: distance is not what you think it is. The shortest path between two points, the "angle" between two directions, even the question "are these two things far apart?" — all of these depend on a hidden object called a metric. Change the metric and you change the geometry. These four fields are four answers to "what is the right metric?"
Everything starts with a 2300-year-old argument about one sentence.
Around 300 BCE Euclid built all of plane geometry from five postulates. The first four are short and "obvious":
The fifth is wordy and feels like a theorem in disguise:
For two millennia mathematicians believed #5 must follow from #1–#4 and tried to prove it. Every "proof" secretly assumed something equivalent to #5. The resolution, reached independently by Gauss (unpublished), Bolyai (1832), and Lobachevsky (1829): the postulate is independent. You can deny it and get a new, fully consistent geometry. There are three outcomes, controlled by how many parallels exist through $P$:
| Property | Euclidean (flat) | Spherical (elliptic) | Hyperbolic |
|---|---|---|---|
| Curvature $K$ | $0$ | $>0$ (e.g. $+1/R^2$) | $<0$ |
| Parallels through a point | exactly 1 | 0 (all geodesics meet) | infinitely many |
| Triangle angle sum | $=180°$ | $>180°$ (bulges out) | $<180°$ (pinched in) |
| "Straight line" (geodesic) | ordinary line | great circle | boundary-⟂ arc (Poincaré) |
| Circumference of radius-$r$ circle | $2\pi r$ | $2\pi\sin r\ (<2\pi r)$ | $2\pi\sinh r\ (>2\pi r)$ |
| Disk area grows like | $r^2$ (polynomial) | bounded (closes up) | $e^{r}$ (exponential) |
| Flatten to paper? | yes (already flat) | no (must tear — maps lie) | no (too much room) |
| Natural data fit | grids, tabular | directions, similarity | trees, hierarchies |
| AI appearance | plain SGD, $\ell_2$ embeddings | CLIP, contrastive (§12.2) | Poincaré/Lorentz emb. (§12.1) |
The exponential area growth row is the single fact that powers all of hyperbolic AI (§12): a tree's nodes grow like $e^{r}$, so only a space whose room grows like $e^{r}$ can hold it without distortion.
The whole trick is to redefine "line" as a geodesic — and the two phrases that sound contradictory are actually the same thing. A geodesic is a path that is straight from the traveler's point of view: walk it without ever turning your steering wheel left or right, and you trace a geodesic. On a flat plane that's an ordinary straight line; on a sphere it's a great circle (the equator, any meridian) — which is why long-haul flights arc toward the poles. Such a no-turning path is automatically the shortest route between nearby points; "locally shortest" means shortest compared to small wiggles around it, even if some longer way around also exists. Two distinct great circles always intersect (at two antipodal points), so there are no parallels at all — and that single fact forces triangles to be fat.
A triangle with three right angles. Start at the North Pole. Walk straight down to the equator (a meridian). Turn 90°, walk a quarter of the way around the equator. Turn 90° again, walk straight back up to the pole. You've traced a triangle with three 90° corners — angle sum $270°$, a full $90°$ over Euclid's $180°$. That excess is not an error; it is the curvature, integrated over the triangle.
This is the seed of the Gauss–Bonnet theorem: $(\text{angle sum}) - 180° = \iint_{\triangle} K \, dA$ (working in radians, $180°=\pi$). Check it: our triple-right-angle triangle has excess $270°-180°=90°=\tfrac\pi2$, and on a unit sphere it covers an octant of area $\tfrac\pi2$, with $K=1$ — so $\iint K\,dA = 1\cdot\tfrac\pi2 = \tfrac\pi2$. Both sides equal. Curvature is literally the angle you gain by going around.
Hyperbolic space is harder to picture because it has "too much room" to fit in flat paper. The Poincaré disk model is the standard cheat: squash the entire infinite hyperbolic plane into the inside of a unit disk. The price is that the ruler shrinks as you approach the boundary — near the edge, a step that looks tiny is actually enormous. The boundary circle is "infinitely far away."
| position $\|\vx\|$ | factor $\frac{2}{1-\|\vx\|^2}$ | a flat step of 0.01 becomes… |
|---|---|---|
| 0 (center) | 2.0 | 0.02 — mild |
| 0.9 | 10.5 | 0.105 — ~5× longer |
| 0.99 | 100.5 | ~1.0 — ~50× longer |
| → 1 (rim) | → ∞ | → ∞ — the boundary is infinitely far |
We keep saying "curvature." Let's make it a number. The cleanest entry point is Gaussian curvature $K$ of a 2D surface.
Stand at a point on a surface and look at how it bends in different directions. There's a most-curved direction and a least-curved direction (always at right angles). Each has a signed curvature $\kappa=1/R$ — and the sign is the whole point. Pick a side of the surface to call "up": a direction that curves toward up gets $\kappa>0$, one that curves away (down) gets $\kappa<0$. The two extremes $\kappa_1,\kappa_2$ are the principal curvatures. Gauss's definition:
| Surface | $\kappa_1,\kappa_2$ | $K$ | Feels like |
|---|---|---|---|
| Plane / cylinder | cylinder: $\kappa_1=1/R$ around, $\kappa_2=0$ along | $K=\frac1R\cdot0=0$ | flat (can unroll to paper) |
| Sphere, radius $R$ | both bend same way | $K=+1/R^2 > 0$ | dome — surface curves toward you everywhere |
| Saddle / Pringle | bend opposite ways | $K<0$ | hyperbolic — up one way, down the other |
A cylinder has $K=0$ even though it looks curved: you can roll a flat sheet of paper into a cylinder without stretching, so "intrinsically" it's still flat. A sphere has $K>0$ and you cannot flatten it without tearing — which is why every world map distorts something.
| surface | circumference of radius-$r$ circle | at $r=1$ | ant concludes |
|---|---|---|---|
| Plane | $C=2\pi r$ | $6.283$ | flat ✓ |
| Cylinder (radius $R$) | $C=2\pi r$ (unrolls flat!) | $6.283$ | flat — same as a plane! |
| Sphere (radius 1) | $C=2\pi\sin r < 2\pi r$ | $2\pi\sin 1 = 5.29$ | curved — a deficit! |
This is also why a flat map of Earth always lies: flattening changes $K$ from $+1/R^2$ to $0$, which by the theorem is impossible without distorting distances. The same theorem is why pizza folds: pinching a slice into a U forces $\kappa_1 \ne 0$ in one direction, and since $K$ must stay $0$ (paper-like dough), the other curvature is forced to $0$ — the slice stiffens and won't flop. You have used the Theorema Egregium to eat lunch.
We now have the two ideas we need to generalize: (a) geometry can be curved, and (b) curvature is intrinsic, derivable from a local ruler. Riemann's framework makes "local ruler" precise and works in any dimension.
Riemann's 1854 lecture answered a radical question: instead of studying surfaces sitting inside 3D space, can we define a curved space abstractly, by only specifying how to measure tiny distances at each point? Yes — and that recipe is all of Riemannian geometry. We build it in four layers.
Earth's surface is a 2-manifold: locally it's a flat map, globally it's a sphere. The key word is locally: zoom in far enough and curvature becomes invisible, which is exactly why people once thought the Earth was flat. This "locally flat" property is what lets us do calculus on curved spaces.
At a point $p\in M$, the tangent space $T_pM$ is the set of all velocity vectors of curves passing through $p$. It is a flat vector space (a copy of $\RR^n$) glued onto the manifold at $p$ — the best linear approximation of $M$ near $p$, like the tangent plane resting on a globe.
This is the single most important object in the whole document. Everything else is built from it.
Read that as a position-dependent Pythagorean theorem. In flat space $\Met=I$ (the identity) and you recover $ds^2 = dx^2+dy^2$. Make $\Met$ vary from point to point and you have bent the space — without ever leaving the coordinates.
| Quantity | Formula from the metric | Meaning |
|---|---|---|
| Length of a vector $\vv$ | $\|\vv\|_g=\sqrt{\vv^\top \Met\, \vv}$ | how "big" a step is — and $\Met$ can make the same coordinate-step count as huge or tiny |
| Angle between $\vv,\vw$ | $\cos\theta=\dfrac{\vv^\top \Met\,\vw}{\|\vv\|_g\|\vw\|_g}$ | the protractor |
| Length of a curve $\gamma$ | $L=\displaystyle\int_0^1\sqrt{\dot\gamma^\top \Met(\gamma)\,\dot\gamma}\,dt$ | add up infinitesimal lengths along the path |
The Poincaré disk metric, concretely. Its metric matrix is a position-dependent rescaling of the identity: $$\Met(\vx)=\left(\frac{2}{1-\|\vx\|^2}\right)^{2} I .$$ At the center $\vx=0$: the factor is $(2/1)^2=4$. At radius $\|\vx\|=0.9$: the factor is $\big(2/(1-0.81)\big)^2=\big(2/0.19\big)^2\approx 111$. So a coordinate-step near the rim costs about $\sqrt{111/4}\approx 5\times$ more "real" length than the same step at the center — and it keeps exploding toward $\|\vx\|\to 1$. That single scalar field is the entire reason hyperbolic space has exponentially expanding room. Choosing this metric = choosing hyperbolic geometry.
torch.Tensor. The array of numbers looks the same, but the geometry word adds a contract: the components must transform under coordinate changes so that physical quantities (lengths, angles) stay invariant. A torch.Tensor is just storage; a geometric tensor is storage + that transformation rule.
The term $\Gamma^k_{ij}\dot\gamma^i\dot\gamma^j$ is the "fictitious force" the curvature exerts. Set $\Gamma=0$ (flat space) and the equation becomes $\ddot\gamma=0$, i.e. $\gamma(t)=a+bt$ — an ordinary straight line. So geodesics are "straight lines bent by the metric." On a globe they're great circles; in the Poincaré disk they're those boundary-perpendicular arcs.
The Christoffel symbols are computed purely from the metric and its first derivatives:
where $g^{kl}$ is the inverse metric matrix. Don't memorize it — just absorb the message: everything about how to move "straight" is encoded in how the metric changes from point to point. If $\Met$ is constant, all derivatives vanish, $\Gamma=0$, and the space is flat. Curvature is the failure of the metric to be constant.
The full Riemann tensor $R^l_{ijk}$ is a beast, but its four indices have a concrete operational reading: $i,j$ pick the two directions spanning the little loop you transport around; $k$ is the direction of the arrow you carry; $l$ is the component of the (rotated) arrow that comes back. So $R^l_{ijk}$ = "how much a $k$-pointing arrow tips into the $l$-direction when carried around an $i$–$j$ loop." Four indices = (loop plane: 2) + (input direction: 1) + (output component: 1). It gets contracted (summed down) into friendlier averages:
| Object | What it is | One-line meaning |
|---|---|---|
| Riemann tensor $R^l_{ijk}$ | full curvature, all directions | holonomy per unit loop area |
| Sectional curvature $K(\vv,\vw)$ | curvature of one 2D slice | the Gaussian $K$ of that slice |
| Ricci curvature $\mathrm{Ric}_{ij}$ | average over directions | does a small ball have more/less volume than Euclidean? (drives general relativity & "Ricci flow") |
| Scalar curvature $S$ | one number per point | total local curvature |
Finally, two maps let us hop between the curved manifold and its flat tangent spaces — these are the workhorses of every geometric deep-learning library:
# Riemannian mean of points A, B, around a base point p
a = log(p, A) # log_p : manifold point -> flat tangent vector in T_pM
b = log(p, B) # both A and B are now ordinary vectors in the SAME flat space
m_tan = 0.5*(a + b) # ordinary Euclidean average — totally legal here
M = exp(p, m_tan) # exp_p : tangent vector -> back onto the manifold
Types: $\log_p:\,M\to T_pM$ (point → flat vector), $\exp_p:\,T_pM\to M$ (flat vector → point), and they're inverses: $\exp_p(\log_p(q))=q$. So in $\theta\leftarrow\exp_\theta(-\eta\vg)$, the object $-\eta\vg$ is a tangent vector and $\exp_\theta$ of it is a new point on the manifold.
We now have the complete machinery of curved spaces: manifold, tangent space, metric, geodesics, curvature, exp/log. The magic of the next two sections is that the space of probability distributions is secretly one of these manifolds — and its metric has a name you already half-know: Fisher information.
Switch worlds. Forget surfaces for a moment. Consider a statistical model: a family of probability distributions $p(x\mid\vth)$ indexed by parameters $\vth$. Examples: all Gaussians (parameter = mean and variance), all coins (parameter = bias $\theta$), or — the AI case — all next-token distributions a neural net can produce as you vary its weights $\vth$.
The question Fisher asked in 1925: how much does the data tell us about the parameter? The answer is a matrix, and that matrix will turn out to be a metric tensor.
Read both forms intuitively:
Fisher information of a coin. A coin lands heads with probability $\theta$. Observe one flip $x\in\{0,1\}$. Then $\log p = x\log\theta+(1-x)\log(1-\theta)$, and a short calculation gives the (scalar) Fisher information $$ \Fish(\theta)=\frac{1}{\theta(1-\theta)}. $$ At $\theta=0.5$ (fair coin): $\Fish = 1/0.25 = 4$ — minimum information; a 50/50 coin's flips are maximally ambiguous about small changes in $\theta$. At $\theta=0.99$: $\Fish=1/(0.99\cdot0.01)\approx 101$ — huge information; a near-certain coin reveals its bias fast, because seeing even one tail is very surprising and strongly updates $\theta$. The parameter space of coins is "stretched" near the edges 0 and 1 and "compressed" in the middle — it is curved, and $\Fish(\theta)$ is its metric.
This is why Fisher information deserves the name "information": it is literally the currency of statistical precision. More Fisher information ⇒ smaller achievable variance ⇒ a more learnable parameter. The maximum-likelihood estimator achieves this bound asymptotically, which is the deep reason MLE (and thus most of deep learning's loss functions) is a sensible thing to do.
Here is the punchline the whole document has been building toward.
The set of all distributions $\{p(x\mid\vth)\}$ in a model is a Riemannian manifold — points are distributions, coordinates are parameters $\vth$ — and its metric tensor is the Fisher information: $$ \boxed{\;g_{ij}(\vth)=\Fish_{ij}(\vth)\;}\qquad\text{the \emph{Fisher–Rao metric}.} $$ Distance on this manifold = statistical distinguishability. Straight lines, curvature, and the Pythagorean theorem all reappear — wearing the costumes of KL divergence, exponential families, and natural gradient.
Why is this the same kind of object as a surface metric? Put the two facts side by side:
A metric is anything that turns a tiny coordinate step into a squared length. On a surface that length is measured in meters; on a statistical manifold it's measured in "how distinguishable," via KL. Same machine, different ruler — so calling $\Fish$ the metric isn't an analogy, it literally satisfies the definition of $g_{ij}$.
The Kullback–Leibler divergence $\KL(p_\vth\,\|\,p_{\vth+\delta})$ measures how distinguishable two nearby distributions are. Taylor-expand it for a tiny step $\delta$. The constant term is 0 (a distribution is identical to itself), the linear term is 0 (KL is minimized at $\delta=0$, so its gradient vanishes there), and the first surviving term is quadratic:
So the Fisher information is the second-derivative (Hessian) of the KL divergence at zero separation. KL behaves like one-half a squared distance, and the matrix defining that squared distance is exactly $\Fish$. This is the rigorous version of "Fisher = local ruler on the space of distributions," and it's the equation that powers TRPO, natural gradient, EWC, and the KL penalty in RLHF — all in §10–§11.
This subsection is the most abstract in the document. On a first read you can skip straight to §9 and lose nothing operationally — come back when you're curious why KL behaves like a squared distance.
Information geometry has one more gift, and it's the structural reason KL "feels like" a squared distance. Amari showed that statistical manifolds carry not one but a dual pair of flat connections — the e-connection (exponential/natural coordinates) and the m-connection (mixture/expectation coordinates) — linked by a Legendre transform. A manifold flat under both is called dually flat, and exponential families (Gaussian, Bernoulli, categorical/softmax, Poisson…) are exactly the dually-flat ones.
The document defines all three in different sections; here's why you'd reach for each. They are three rulers on the same space of distributions.
| KL divergence $\KL(p\|q)$ | Wasserstein $W_2$ (earth-mover) | Fisher–Rao | |
|---|---|---|---|
| Measures | extra bits to code $p$ with $q$'s code | cheapest mass transport (mass × distance) | infinitesimal distinguishability of nearby models |
| Symmetric? | No ($\KL(p\|q)\ne\KL(q\|p)$) | Yes (a true metric) | Yes (a true Riemannian distance) |
| Triangle inequality? | No | Yes | Yes |
| Finite if supports don't overlap? | No (→ ∞) | Yes (stays finite) | n/a (local) |
| Relation to the others | $\approx\tfrac12\delta^\top\Fish\delta$ for small $\delta$ | geodesic distance under the Otto metric | the metric tensor = Hessian of KL at $\delta\!=\!0$ |
| Scale | global (bits/nats) | global (ground-distance × mass) | local / infinitesimal |
| AI appearance | TRPO/PPO/GRPO, VAE ELBO, RLHF | WGAN, OT flow matching, diffusion | natural gradient, EWC, Laplace |
KL is the local picture (§8), Fisher is its second derivative, Wasserstein is the transport picture (§13) — three views of "how far apart are two distributions?"
Now the geometry pays off as an algorithm. This single idea is the trunk from which most of the AI applications branch.
Gradient descent does $\vth \leftarrow \vth - \eta\,\grad L$. But $\grad L$ is the direction of steepest descent only if you measure distance with the plain Euclidean ruler $\|\delta\vth\|^2$. On a statistical manifold that ruler is wrong — the right notion of "how far did the model move" is the Fisher length $\delta\vth^\top \Fish\,\delta\vth$ (≈ KL change), not the parameter-space length. Using the wrong ruler means the gradient points in a distorted direction and the step sizes are inconsistent across coordinates.
Two superpowers fall out immediately:
That completes the mathematical core. From here on, every section is the same four ideas — metric, geodesic, curvature, natural gradient — wearing the clothes of a specific state-of-the-art AI method. Each connection box names the exact papers (verified, with arXiv IDs) so you can go deep.
The most direct application: use the Fisher metric to optimize. This thread runs from a 1998 theorem straight into how every modern reasoning LLM (DeepSeek-R1, etc.) is trained.
Amari, "Natural Gradient Works Efficiently in Learning" 1998Neural Computation 10(2)very-high >5000
Proves that when parameters live on a statistical (Riemannian) manifold, the steepest-descent direction is $\Fish^{-1}\grad L$, not $\grad L$, and that online natural-gradient learning is asymptotically Fisher-efficient (it attains the Cramér–Rao bound — you can't learn faster). This is §9 made into a theorem and is the conceptual root of everything below.
Martens & Grosse, "Optimizing Neural Networks with Kronecker-factored Approximate Curvature" (K-FAC) 2015ICMLhigh >1000 · arXiv:1503.05671
The Fisher of a deep net is billions × billions — un-invertible. K-FAC's insight: each layer's Fisher block factorizes as a Kronecker product $\Fish_\ell \approx A_\ell \otimes G_\ell$ of two small matrices (one from input activations, one from back-propagated output gradients). Since $(A\otimes G)^{-1}=A^{-1}\otimes G^{-1}$, the natural-gradient step becomes cheap.
This is the canonical practical natural-gradient method and it reappears (as the curvature engine) in §11's Laplace approximation and influence functions.
The same "approximate the curvature/metric cheaply" idea drives a 2018–2026 lineage of optimizers, each choosing a different geometry: Shampoo (Gupta et al. 2018, 1802.09568) uses per-dimension Kronecker preconditioners; distributed Shampoo (Anil et al. 2020, 2002.09018; Shi et al. 2023, 2309.06497) scales it to production; Sophia (Liu et al. 2023, 2305.14342) uses a cheap diagonal-Hessian estimate; SOAP (Vyas et al. 2024, 2409.11321) proves Shampoo ≈ Adam in the preconditioner's eigenbasis; and Muon (Jordan et al. 2024; "Muon is Scalable," Liu et al. 2025, 2502.16982) orthogonalizes the update — which Bernstein & Newhouse (2409.20325) show is steepest descent under the spectral norm, a different metric than Fisher but the same "choose your geometry" philosophy.
| Optimizer | Assumed geometry / what it approximates | Curvature structure | Cost |
|---|---|---|---|
| SGD | Euclidean (metric $=I$) | none | cheapest |
| Adam | diagonal (empirical) Fisher — per-coordinate rescale | diagonal | cheap |
| K-FAC | block-diagonal Fisher, Kronecker $A\otimes G$ per layer | block + Kronecker | medium |
| Shampoo | per-dimension Kronecker preconditioners (≈ full Gauss–Newton) | Kronecker, two-sided | medium-high |
| SOAP | Shampoo in Adam's eigenbasis (cheaper, ≈ Shampoo) | Kronecker eigenbasis | medium |
| Sophia | diagonal Hessian estimate (clipped) | diagonal Hessian | cheap |
| Muon | spectral-norm steepest descent (orthogonalized step) | spectral norm, not Fisher | medium |
| Natural gradient (ideal) | exact Fisher $\Fish^{-1}\grad L$ | full $d\times d$ | impossible at scale |
Every row is a different answer to "what metric should steepest descent use?" Most approximate the Fisher (§9's warning: you can never afford the exact one); Muon instead swaps in the spectral norm. This is the "choose your geometry" idea as a menu.
This is the cleanest place where "Fisher = Hessian of KL" (§8.1) becomes a billion-dollar algorithm. Here is the whole lineage as a pipeline — read each box as "what it adds / what it costs":
Term-glosses: trust region · policy gradient · probability ratio.
The through-line: Fisher is the Hessian of KL ⟶ Kakade preconditions by it ⟶ TRPO turns it into a hard KL trust region ⟶ PPO/GRPO approximate that trust region with clipping/penalties. Every time you read "KL penalty" in an RLHF or reasoning-model paper, you are reading information geometry.
Beyond optimization, the Fisher matrix is a Swiss-army knife: it doubles as parameter importance, posterior precision, and influence. The unifying fact (Martens 2020, 1412.1193): for exponential-family losses, Fisher = Generalized Gauss–Newton ≈ Hessian at a minimum, and (Jacot et al. 2018, NTK, 1806.07572) it's the parameter-space dual of the neural tangent kernel. So "use the Fisher" = "use the curvature" = "use the local KL metric." Five places this shows up:
| Use of Fisher | Paper(s) | How the geometry is used |
|---|---|---|
| Continual learning (don't forget old tasks) |
Kirkpatrick et al., EWC 2017 PNAS · 1612.00796 very-high | Anchors each weight to its old value with a penalty weighted by the Fisher diagonal. High-Fisher weights are "stiff" (the loss is sharply curved there → important), low-Fisher weights stay plastic. Formally a Laplace approximation: Fisher = precision of a Gaussian posterior carried across tasks. |
| Bayesian uncertainty (post-hoc, cheap) |
Ritter et al. 2018 ICLR; Daxberger et al., Laplace Redux 2021 NeurIPS · 2106.14806 | Fit a Gaussian around a trained net's weights whose precision matrix is the Fisher/GGN (K-FAC-factored). Gives calibrated uncertainty + marginal-likelihood model selection with no retraining — "effortless Bayesian deep learning." |
| Model merging (combine fine-tunes) |
Matena & Raffel, Fisher-weighted averaging 2022 NeurIPS · 2111.09832 | Merge several models by a per-parameter Fisher-weighted average — each model dominates the merge on the coordinates it's most confident about (high Fisher). The principled cousin of Task Arithmetic (Ilharco et al. 2023, 2212.04089), which deliberately uses no curvature. |
| Pruning (remove parameters) |
Molchanov et al. 2019 CVPR · 1906.10771; LLM-Pruner 2023 · 2305.11627 | Score each weight/filter by a Taylor expansion of the loss; the squared-gradient term is an empirical-Fisher importance. Low-Fisher parameters are safe to delete (the Optimal-Brain-Damage lineage), now applied at LLM scale. |
| Data attribution (which example caused this?) |
Koh & Liang, Influence Functions 2017 ICML best paper · 1703.04730; Grosse et al. 2023 (Anthropic, 52B) · 2308.03296 | Trace a prediction to its most influential training points via an inverse-Hessian-vector product — and at the optimum the Hessian is the Fisher. Scaling to LLMs needs the EK-FAC Fisher approximation; pure §10 machinery reused for interpretability. |
Here the non-Euclidean geometry of §2–§3 returns directly: instead of curving the space of distributions, we curve the embedding space where the model places its representations. The choice of curvature is the choice of inductive bias.
The foundations — embed symbolic hierarchies in the Poincaré/Lorentz ball:
The architectures — make whole networks curved:
The 2023–2026 frontier — curvature reaches foundation models:
A fast-growing 2023–2026 literature measures the geometry of transformer hidden states — and finds it is emphatically not flat Euclidean:
The final thread fuses both halves: generative models that either live on a Riemannian manifold (§4–§6) or that move probability mass under an optimal-transport geometry — itself a Riemannian metric on the space of distributions (§8).
A protein backbone is a sequence of rigid frames — a point on the product manifold $SE(3)^N$ (rotations $\times$ translations). Generating molecules/proteins = running a diffusion or flow on that manifold, respecting its symmetry. This is the most consequential real-world payoff of Riemannian generative modeling.
The Wasserstein distance equips the space of probability distributions with its own Riemannian structure (the Otto metric), where geodesics are mass-transport plans and gradient flows describe diffusion. This is information geometry's transport-flavored sibling.
Even an ordinary VAE/GAN/diffusion latent space is secretly Riemannian: the decoder $g$ pulls the data-space metric back into the latent space, $\Met(\vz)=J_g(\vz)^\top J_g(\vz)$ (the decoder Jacobian), so "straight-line interpolation" in latent coordinates is geometrically wrong — you should follow geodesics.
None of this is whiteboard-only. Every concept above is running inside products you've used this week. Here is the map from idea → shipped system, with the company and model named. The pattern to notice: a geometry paper takes 2–7 years to become an API knob or a frontier training run.
dimensions knob. A NeurIPS paper about nesting representations on the hypersphere (2205.13147) became, in under two years, a literal API parameter: text-embedding-3 lets you truncate a unit-sphere vector from 3072→256 dims and renormalize, trading accuracy for speed with no retraining.text-embedding-3 (2205.13147), Nomic, Cohere — nested sphere-normalized embeddings as an API dimensions knob. E5 → Microsoft (2212.03533), the open-weight RAG workhorse, trained with alignment+uniformity on the sphere (2005.10242).| Concept | Symbol | One-line meaning | AI appearance |
|---|---|---|---|
| Manifold | $M$ | locally-flat curved space | data manifold; embedding space; $SE(3)^N$ of a protein |
| Tangent space | $T_pM$ | local linear space of directions | where gradients/velocities live |
| Metric tensor | $g_{ij}$ | position-dependent Pythagoras, $ds^2=d\vx^\top \Met\,d\vx$ | the central object — choosing geometry = choosing $g$ |
| Geodesic | $\gamma$ | straightest/shortest path | latent interpolation; flow-matching paths; hyperbolic distance |
| Curvature | $K, R^l_{ijk}$ | failure of metric to be constant; holonomy | hyperbolic ($K\!<\!0$, hierarchy) vs sphere ($K\!>\!0$, similarity) |
| $\exp$/$\log$ maps | $\exp_p,\log_p$ | hop between manifold & tangent space | every hyperbolic layer; Riemannian SGD |
| Score (params) | $\grad_\theta\log p$ | likelihood sensitivity to parameters → builds Fisher | MLE, Fisher information (§7–8) |
| Score (data) | $\grad_x\log p$ | direction toward more-probable data | score-based diffusion / score matching (§13) |
| Fisher information | $\Fish$ | var of score = Hessian of KL = metric on distributions | natural gradient, EWC, Laplace, merging, influence |
| Fisher–Rao metric | $g=\Fish$ | the metric of the statistical manifold | information geometry; reparam-invariant updates |
| KL divergence | $\KL(p\|q)$ | $\approx\tfrac12\delta^\top\Fish\delta$; canonical divergence | TRPO/PPO/GRPO trust region; VAE/variational loss |
| Natural gradient | $\Fish^{-1}\grad L$ | steepest descent in Fisher metric | K-FAC, Shampoo, natural policy gradient |
| Wasserstein metric | $W_2$ | Riemannian metric via mass transport | WGAN, OT flow matching, diffusion as gradient flow |
Most accessible route:
Rigorous route: do Carmo, Differential Geometry of Curves and Surfaces → do Carmo / J.M. Lee, Riemannian Geometry → Lehmann & Casella, Theory of Point Estimation (Fisher information done right) → Amari & Nagaoka, Methods of Information Geometry (the canonical text) and Amari, Information Geometry and Its Applications (2016, more pedagogical).
Foundational primary sources: Riemann's 1854 habilitation lecture On the Hypotheses Which Lie at the Bases of Geometry; Gauss's Theorema Egregium (1827); Fisher (1925); Rao (1945, Fisher–Rao metric & Cramér–Rao); Chentsov (1972, uniqueness of the Fisher metric).
| Topic | Best next resource (free where ✓) |
|---|---|
| Geometric deep learning (the unifying frame) | ✓ Bronstein, Bruna, Cohen, Veličković, GDL: Grids, Groups, Graphs, Geodesics, Gauges — arXiv:2104.13478 + lecture course |
| Differential geometry, CS-friendly + code | ✓ Keenan Crane, Discrete Differential Geometry — CMU course + videos; ✓ Carroll's GR notes for index intuition |
| Optimal transport | ✓ Peyré & Cuturi, Computational Optimal Transport — free book; libraries POT & OTT-JAX |
| Information geometry | ✓ Nielsen, Elementary Introduction to Information Geometry — arXiv:1808.08271; Martens, Natural Gradient — 1412.1193 |
| Flow matching (geometric generative) | ✓ Lipman et al., Flow Matching Guide and Code — arXiv:2412.06264 + PyTorch library |
| Hyperbolic / geometry-in-foundation-models | ✓ surveys: Peng et al. 2021 (2101.04562); Mettes et al. IJCV 2024; Hyperbolic DL for Foundation Models 2025 (2507.17787) |
| Intuition warm-up | ✓ 3Blue1Brown — Essence of Linear Algebra / Calculus |
Suggested order: 3Blue1Brown → GDL book+lectures → Crane (hands-on) → Nielsen (info-geo) → Martens (natural gradient) → Peyré–Cuturi (OT) → Lipman (flow matching) → hyperbolic surveys.
A full, organized bibliography of every paper referenced here — with authors, year, venue, arXiv ID, citation tier, and a one-line note on how each uses the geometry — is in REFERENCES.md (and grouped by theme). This HTML is the tutorial; that file is the map of the literature.
Built as a self-contained explainer · all papers verified via web search with arXiv IDs · math rendered with MathJax · diagrams hand-drawn in SVG · interactive demos in vanilla JS.
Geometry is just the rule for measuring small steps. Everything else — intelligence included — is what you build on top of that rule.
从平行公设出发,一路抵达自然梯度、双曲 transformer、流形上的流匹配——每个概念都从零定义,配以直觉、算例数字、图示,以及那些把数学变成最先进 AI 的确切论文。
四个主题,一个思想:距离并不是你以为的那样。两点之间的最短路径、两个方向之间的"夹角",乃至"这两样东西离得远吗?"这个问题——所有这些都依赖于一个隐藏的对象,叫做度量。改变度量,你就改变了几何。这四个领域,是对"什么才是正确的度量?"给出的四个答案。
这一切都始于一场围绕一句话、持续了 2300 年的争论。
大约公元前 300 年,欧几里得用五条公设构建了整个平面几何。前四条简短而"显而易见":
第五条则啰嗦冗长,感觉像是个伪装成公设的定理:
在两千年里,数学家们都相信第 5 条必定能从第 1–4 条推出,并试图去证明它。可每一个"证明"都暗中假定了某个与第 5 条等价的命题。这一难题最终由高斯(未发表)、Bolyai(1832)和Lobachevsky(1829)各自独立地解决:这条公设是独立的。你可以否定它,从而得到一种全新的、完全自洽的几何。根据过 $P$ 的平行线数量不同,共有三种结果:
| 性质 | 欧几里得(平直) | 球面(椭圆型) | 双曲 |
|---|---|---|---|
| 曲率 $K$ | $0$ | $>0$(例如 $+1/R^2$) | $<0$ |
| 过一点的平行线 | 恰好 1 条 | 0(所有测地线都相交) | 无穷多条 |
| 三角形内角和 | $=180°$ | $>180°$(向外鼓) | $<180°$(向内收) |
| "直线"(测地线) | 普通直线 | 大圆 | 与边界垂直的弧(庞加莱) |
| 半径为 $r$ 的圆的周长 | $2\pi r$ | $2\pi\sin r\ (<2\pi r)$ | $2\pi\sinh r\ (>2\pi r)$ |
| 圆盘面积增长方式 | $r^2$(多项式) | 有界(自我闭合) | $e^{r}$(指数) |
| 能摊平到纸上吗? | 能(本就平直) | 不能(必须撕开——地图会失真) | 不能(空间太多) |
| 天然契合的数据 | 网格、表格 | 方向、相似度 | 树、层级结构 |
| 在 AI 中的出现 | 普通 SGD、$\ell_2$ 嵌入 | CLIP、对比学习(§12.2) | 庞加莱/Lorentz 嵌入(§12.1) |
那一行面积指数增长,正是支撑全部双曲 AI(§12)的唯一事实:一棵树的节点数像 $e^{r}$ 一样增长,因此只有空间本身也像 $e^{r}$ 一样增长的几何,才能无失真地容纳它。
整个把戏就是把"直线"重新定义为测地线——而那两个听起来自相矛盾的说法其实是同一回事。测地线是一条从旅行者视角看是笔直的路径:走的时候始终不向左或向右打方向盘,你画出的就是一条测地线。在平直平面上,那就是普通直线;在球面上,它是一条大圆(赤道、任意子午线)——这正是为什么长途航班的航线会朝两极弯曲。这样一条不转弯的路径,会自动成为邻近两点之间的最短路线;"局部最短"是指与它周围的小幅摆动相比是最短的,即便绕一圈可能还有更长的别的走法。两条不同的大圆总是相交(在一对对径点上),所以根本不存在平行线——而正是这一个事实,迫使三角形变"胖"。
一个有三个直角的三角形。 从北极出发。沿一条子午线笔直走到赤道。转 90°,沿赤道走四分之一圈。再转 90°,笔直走回北极。你画出的三角形有三个 90° 的角——内角和 $270°$,比欧几里得的 $180°$ 整整多出 $90°$。这个超出量不是误差;它就是曲率在整个三角形上的积分。
这正是 Gauss–Bonnet 定理的雏形:$(\text{角度和}) - 180° = \iint_{\triangle} K \, dA$(以弧度计,$180°=\pi$)。来验证一下:我们这个三直角三角形的超出量为 $270°-180°=90°=\tfrac\pi2$,在单位球面上它覆盖了面积为 $\tfrac\pi2$ 的一个八分之一球面,且 $K=1$ —— 于是 $\iint K\,dA = 1\cdot\tfrac\pi2 = \tfrac\pi2$。两边相等。曲率正是你绕行一圈所获得的角度。
双曲空间更难想象,因为它有"太多空间",塞不进平直的纸面。庞加莱圆盘模型是标准的"作弊"手法:把整个无限的双曲平面压进一个单位圆盘的内部。代价是:当你靠近边界时,尺子会缩小——在边缘附近,一个看起来很小的步长,实际上是巨大的。边界圆"无限远"。
| 位置 $\|\vx\|$ | 因子 $\frac{2}{1-\|\vx\|^2}$ | 0.01 的平直步长变为… |
|---|---|---|
| 0(中心) | 2.0 | 0.02 —— 轻微 |
| 0.9 | 10.5 | 0.105 —— 约长 5 倍 |
| 0.99 | 100.5 | ~1.0 —— 约长 50 倍 |
| → 1(边缘) | → ∞ | → ∞ —— 边界无限远 |
我们一直在说"曲率"。现在让它变成一个数字吧。最清晰的切入点是二维曲面的高斯曲率 $K$。
站在曲面上某一点,观察它沿不同方向如何弯曲。总存在一个弯曲最厉害的方向和一个弯曲最平缓的方向(两者总是相互垂直)。每个方向都有一个带符号的曲率 $\kappa=1/R$——而符号正是关键所在。选定曲面的某一侧称作"上方":朝着上方弯曲的方向取 $\kappa>0$,背离上方(向下)弯曲的方向取 $\kappa<0$。这两个极端值 $\kappa_1,\kappa_2$ 就是主曲率。高斯的定义是:
| 曲面 | $\kappa_1,\kappa_2$ | $K$ | 感觉像 |
|---|---|---|---|
| 平面 / 圆柱面 | 圆柱面:绕圈方向 $\kappa_1=1/R$,沿轴方向 $\kappa_2=0$ | $K=\frac1R\cdot0=0$ | 平的(可以展开成纸) |
| 球面,半径 $R$ | 两个方向朝同一侧弯曲 | $K=+1/R^2 > 0$ | 穹顶——曲面处处朝你弯曲 |
| 鞍面 / 品客薯片 | 两个方向朝相反方向弯曲 | $K<0$ | 双曲——一个方向向上、另一个向下 |
圆柱面的 $K=0$,尽管它看起来是弯的:你可以把一张平整的纸卷成圆柱而无需拉伸,所以"内蕴"地说它依然是平的。球面的 $K>0$,而你无法在不撕裂的情况下把它压平——这就是为什么每一张世界地图都会扭曲某些东西。
| 曲面 | 半径为 $r$ 的圆的周长 | 当 $r=1$ 时 | 蚂蚁的结论 |
|---|---|---|---|
| 平面 | $C=2\pi r$ | $6.283$ | 平的 ✓ |
| 圆柱面(半径 $R$) | $C=2\pi r$(能展平!) | $6.283$ | 平的——和平面一样! |
| 球面(半径 1) | $C=2\pi\sin r < 2\pi r$ | $2\pi\sin 1 = 5.29$ | 弯曲——有亏损! |
这也是为什么地球的平面地图总会撒谎:压平会把 $K$ 从 $+1/R^2$ 变成 $0$,而根据该定理,这在不扭曲距离的前提下是不可能的。同一个定理也解释了比萨为什么会折弯:把一块比萨捏成 U 形,就在一个方向上迫使 $\kappa_1 \ne 0$,而既然 $K$ 必须保持为 $0$(像纸一样的面团),另一个方向的曲率就被迫为 $0$——这块比萨于是变硬、不再耷拉。你刚刚用绝妙定理吃了顿午餐。
现在我们已经拥有推广所需的两个想法:(a) 几何可以是弯曲的,以及 (b) 曲率是内蕴的,可以从一把局部的尺子推导出来。黎曼的框架把"局部的尺子"精确化,并在任意维度上都成立。
黎曼 1854 年的演讲回答了一个激进的问题:与其研究嵌在三维空间中的曲面,我们能否抽象地定义一个弯曲空间——仅仅通过指定如何在每一点测量微小距离?答案是肯定的——而这套配方就是黎曼几何的全部。我们分四层来搭建它。
地球表面是一个二维流形:局部上它是一张平坦的地图,全局上它是一个球面。关键词是局部:放大得足够近,曲率就变得不可见,这正是人们曾经以为地球是平的原因。这种"局部平坦"的性质,正是让我们能在弯曲空间上做微积分的根基。
在一点 $p\in M$ 处,切空间 $T_pM$ 是所有经过 $p$ 的曲线的速度向量的集合。它是一个平坦的向量空间($\RR^n$ 的一份副本),粘贴在流形上 $p$ 处——是 $M$ 在 $p$ 附近的最佳线性逼近,就像贴在地球仪上的切平面。
这是整篇文档中最重要的单一对象。其余一切都由它构建而成。
把它读作一个依赖于位置的勾股定理。在平坦空间中 $\Met=I$(单位矩阵),你就还原出 $ds^2 = dx^2+dy^2$。让 $\Met$ 逐点变化,你就弯曲了这个空间——而自始至终都没离开过坐标。
| 量 | 由度量给出的公式 | 含义 |
|---|---|---|
| 向量 $\vv$ 的长度 | $\|\vv\|_g=\sqrt{\vv^\top \Met\, \vv}$ | 一步有多"大"——而 $\Met$ 能让同一个坐标步长被算作极大或极小 |
| $\vv,\vw$ 之间的夹角 | $\cos\theta=\dfrac{\vv^\top \Met\,\vw}{\|\vv\|_g\|\vw\|_g}$ | 量角器 |
| 曲线 $\gamma$ 的长度 | $L=\displaystyle\int_0^1\sqrt{\dot\gamma^\top \Met(\gamma)\,\dot\gamma}\,dt$ | 沿路径累加无穷小长度 |
具体的庞加莱圆盘度量。 它的度量矩阵是对单位矩阵做的一个依赖于位置的重缩放: $$\Met(\vx)=\left(\frac{2}{1-\|\vx\|^2}\right)^{2} I .$$ 在圆心 $\vx=0$ 处:该因子为 $(2/1)^2=4$。在半径 $\|\vx\|=0.9$ 处:该因子为 $\big(2/(1-0.81)\big)^2=\big(2/0.19\big)^2\approx 111$。所以靠近边缘的一个坐标步长所付出的"真实"长度,约是圆心处同样步长的 $\sqrt{111/4}\approx 5\times$ 倍——而且随着 $\|\vx\|\to 1$ 它会一直爆炸式增长。仅这一个标量场,就是双曲空间拥有指数级膨胀空间的全部缘由。 选择这个度量 = 选择双曲几何。
torch.Tensor 不是一回事。那一堆数字看起来一样,但"几何"这个词加上了一条约定:这些分量必须在坐标变换下做相应变换,从而让物理量(长度、角度)保持不变。torch.Tensor 只是存储;几何张量是存储 + 那条变换规则。
项 $\Gamma^k_{ij}\dot\gamma^i\dot\gamma^j$ 就是曲率施加的"虚拟力"。令 $\Gamma=0$(平坦空间),方程就变成 $\ddot\gamma=0$,即 $\gamma(t)=a+bt$——一条普通的直线。所以测地线是"被度量弯曲了的直线"。在地球仪上它们是大圆;在庞加莱圆盘里它们是那些与边界垂直的弧。
Christoffel 符号纯粹由度量及其一阶导数算出:
其中 $g^{kl}$ 是逆度量矩阵。别去背它——只要吸收这条信息:关于如何"笔直"移动的一切,都编码在度量从一点到另一点的变化方式之中。 如果 $\Met$ 是常数,所有导数消失,$\Gamma=0$,空间平坦。曲率就是度量未能保持恒定。
完整的黎曼张量 $R^l_{ijk}$ 是个庞然大物,但它的四个指标有一种具体的可操作读法:$i,j$ 选定张成你所移动的那个小回路的两个方向;$k$ 是你携带的箭头的方向;$l$ 是返回时(被旋转的)箭头的分量。 所以 $R^l_{ijk}$ = "当一个指向 $k$ 的箭头被绕一个 $i$–$j$ 回路携带时,它向 $l$ 方向倾斜了多少"。四个指标 = (回路平面:2) + (输入方向:1) + (输出分量:1)。它被缩并(求和约化)成更友好的平均量:
| 对象 | 它是什么 | 一句话含义 |
|---|---|---|
| 黎曼张量 $R^l_{ijk}$ | 完整曲率,所有方向 | 每单位回路面积的和乐 |
| 截面曲率 $K(\vv,\vw)$ | 某个二维切片的曲率 | 该切片的高斯曲率 $K$ |
| Ricci 曲率 $\mathrm{Ric}_{ij}$ | 对方向求平均 | 一个小球的体积比欧几里得的多还是少?(驱动广义相对论与"Ricci 流") |
| 标量曲率 $S$ | 每点一个数 | 局部总曲率 |
最后,有两个映射让我们能在弯曲流形和它的平坦切空间之间往返跳跃——它们是每一个几何深度学习库的主力:
# Riemannian mean of points A, B, around a base point p
a = log(p, A) # log_p:流形点 -> T_pM 中的平坦切向量
b = log(p, B) # A 和 B 现在都是同一个平坦空间里的普通向量
m_tan = 0.5*(a + b) # 普通的欧几里得平均——在这里完全合法
M = exp(p, m_tan) # exp_p:切向量 -> 回到流形上
类型: $\log_p:\,M\to T_pM$(点 → 平坦向量),$\exp_p:\,T_pM\to M$(平坦向量 → 点),并且它们互为逆:$\exp_p(\log_p(q))=q$。所以在 $\theta\leftarrow\exp_\theta(-\eta\vg)$ 中,对象 $-\eta\vg$ 是一个切向量,而它的 $\exp_\theta$ 是一个新的流形上的点。
现在我们拥有了弯曲空间的全套机器:流形、切空间、度量、测地线、曲率、exp/log。接下来两节的魔力在于,概率分布构成的空间暗地里就是这些流形之一——而它的度量有一个你已经懂了一半的名字:Fisher 信息。
切换一下场景。暂时把曲面放到一边。考虑一个统计模型:一族由参数 $\vth$ 索引的概率分布 $p(x\mid\vth)$。例如:所有高斯分布(参数 = 均值和方差)、所有硬币(参数 = 偏置 $\theta$),或者——AI 的情形——当你改变神经网络的权重 $\vth$ 时它能产生的所有下一个 token 分布。
Fisher 在 1925 年提出的问题是:数据能告诉我们多少关于参数的信息?答案是一个矩阵,而这个矩阵最终会成为一个度量张量。
从直觉上理解这两种形式:
硬币的 Fisher 信息。一枚硬币以概率 $\theta$ 落为正面。观察一次抛掷 $x\in\{0,1\}$。则 $\log p = x\log\theta+(1-x)\log(1-\theta)$,简短计算给出(标量的)Fisher 信息 $$ \Fish(\theta)=\frac{1}{\theta(1-\theta)}. $$ 在 $\theta=0.5$(公平硬币)时:$\Fish = 1/0.25 = 4$——信息量最小;一枚 50/50 的硬币,其抛掷结果对 $\theta$ 的微小变化最为模糊。在 $\theta=0.99$ 时:$\Fish=1/(0.99\cdot0.01)\approx 101$——信息量巨大;一枚近乎确定的硬币能很快暴露其偏置,因为哪怕只看到一次反面都非常意外,会强烈地更新 $\theta$。硬币的参数空间在 0 和 1 两端被"拉伸"、在中间被"压缩"——它是弯曲的,而 $\Fish(\theta)$ 就是它的度量。
这就是 Fisher 信息配得上"信息"这个名字的原因:它实实在在地是统计精度的通货。Fisher 信息越多 ⇒ 可达到的方差越小 ⇒ 参数越可学习。最大似然估计量在渐近意义下达到这个下界,这正是 MLE(也因此是深度学习大多数损失函数)之所以合理的深层原因。
这就是整篇文档一直在铺垫的那个点睛之笔。
一个模型中所有分布构成的集合 $\{p(x\mid\vth)\}$ 是一个 黎曼流形 —— 点是分布,坐标是参数 $\vth$ —— 而它的 度量张量就是 Fisher 信息: $$ \boxed{\;g_{ij}(\vth)=\Fish_{ij}(\vth)\;}\qquad\text{即 \emph{Fisher–Rao 度量}。} $$ 这个流形上的距离 = 统计可区分性。直线、曲率、勾股定理统统重新登场 —— 只不过披上了 KL 散度、指数族和自然梯度的外衣。
为什么它和曲面度量是同一类对象?把这两个事实并排放在一起看:
度量就是任何把一个微小坐标步长变成平方长度的东西。在曲面上这个长度用米来量;在统计流形上它用「有多可区分」来量,途径就是 KL。同一台机器,不同的尺子 —— 所以把 $\Fish$ 称作度量并不是类比,它确确实实满足 $g_{ij}$ 的定义。
Kullback–Leibler 散度 $\KL(p_\vth\,\|\,p_{\vth+\delta})$ 衡量两个邻近分布有多可区分。对一个微小步长 $\delta$ 把它泰勒展开。常数项为 0(一个分布与自身完全相同),线性项也为 0(KL 在 $\delta=0$ 处取最小,所以它的梯度在那里消失),第一个存活下来的项是二次的:
所以 Fisher 信息就是 KL 散度在零间隔处的二阶导数(Hessian)。KL 的行为像二分之一个平方距离,而定义那个平方距离的矩阵恰好就是 $\Fish$。这是「Fisher = 分布空间上的局部尺子」的严格版本,也是驱动 TRPO、自然梯度、EWC 以及 RLHF 中 KL 惩罚项的那个方程 —— 全都在 §10–§11。
本小节是全文最抽象的部分。初读时你可以直接跳到 §9,从操作层面不会损失任何东西 —— 等你好奇为什么 KL 的行为像平方距离时再回来。
信息几何还有一份礼物,它正是 KL「感觉像」平方距离的结构性原因。Amari 证明,统计流形携带的不是一个、而是一对对偶平坦联络 —— e-联络(指数/自然坐标)和 m-联络(混合/期望坐标)—— 由一个 勒让德变换相连。在两者下都平坦的流形称为对偶平坦,而指数族(高斯、伯努利、类别/softmax、泊松……)恰好就是那些对偶平坦的族。
本文档在不同章节定义了这三者;这里说明你为何会用到其中的每一个。它们是同一个分布空间上的三把尺子。
| KL 散度 $\KL(p\|q)$ | Wasserstein $W_2$(推土机) | Fisher–Rao | |
|---|---|---|---|
| 衡量什么 | 用 $q$ 的编码去编 $p$ 所需的额外比特 | 最廉价的质量搬运(质量 × 距离) | 邻近模型的无穷小可区分性 |
| 对称吗? | 否($\KL(p\|q)\ne\KL(q\|p)$) | 是(真正的度量) | 是(真正的黎曼距离) |
| 三角不等式? | 否 | 是 | 是 |
| 支撑集不重叠时仍有限吗? | 否(→ ∞) | 是(保持有限) | 不适用(局部的) |
| 与其他两者的关系 | 当 $\delta$ 小时 $\approx\tfrac12\delta^\top\Fish\delta$ | Otto 度量下的测地距离 | 度量张量 = KL 在 $\delta\!=\!0$ 处的 Hessian |
| 尺度 | 全局(比特/奈特) | 全局(地面距离 × 质量) | 局部 / 无穷小 |
| 在 AI 中的出场 | TRPO/PPO/GRPO、VAE ELBO、RLHF | WGAN、OT 流匹配、扩散 | 自然梯度、EWC、Laplace |
KL 是局部视角(§8),Fisher 是它的二阶导数,Wasserstein 是传输视角(§13)—— 关于「两个分布相距多远?」的三种视角。
现在几何作为一种算法开始回报我们了。这一个核心思想,正是后续大多数 AI 应用赖以分叉生长的主干。
梯度下降执行 $\vth \leftarrow \vth - \eta\,\grad L$。但 $\grad L$ 是最速下降方向,仅当你用朴素的欧几里得尺子 $\|\delta\vth\|^2$ 来度量距离时才成立。在统计流形上这把尺子是错的——衡量“模型移动了多远”的正确概念是 Fisher 长度 $\delta\vth^\top \Fish\,\delta\vth$(≈ KL 变化),而不是参数空间的长度。用错误的尺子意味着梯度指向一个被扭曲的方向,而且各坐标方向上的步长彼此不一致。
两项超能力立刻随之而来:
至此,数学核心部分就完成了。从这里开始,每一节都是同样的四个思想——度量、测地线、曲率、自然梯度——只是披上某种当下最先进 AI 方法的外衣。每个关联框都会点出确切的论文(已核实,附 arXiv ID),方便你深入研读。
最直接的应用:用 Fisher 度量来优化。这条线索从 1998 年的一个定理一路通向当今每个推理型 LLM(DeepSeek-R1 等)的训练方式。
Amari, "Natural Gradient Works Efficiently in Learning" 1998Neural Computation 10(2)very-high >5000
证明了:当参数生活在一个统计(黎曼)流形上时,最速下降方向是 $\Fish^{-1}\grad L$,而不是 $\grad L$;并且在线自然梯度学习是渐近 Fisher 高效的(它达到了 Cramér–Rao 下界 —— 你不可能学得更快)。这就是把 §9 写成了一个定理,也是下面一切内容的概念性根源。
Martens & Grosse, "Optimizing Neural Networks with Kronecker-factored Approximate Curvature" (K-FAC) 2015ICMLhigh >1000 · arXiv:1503.05671
一个深度网络的 Fisher 是 数十亿 × 数十亿 —— 无法求逆。K-FAC 的洞见是:每一层的 Fisher 块都分解为两个小矩阵的 Kronecker 积 $\Fish_\ell \approx A_\ell \otimes G_\ell$(一个来自输入激活,一个来自反向传播的输出梯度)。由于 $(A\otimes G)^{-1}=A^{-1}\otimes G^{-1}$,自然梯度步就变得很便宜了。
这是自然梯度的经典实用方法,它(作为曲率引擎)会在 §11 的 Laplace 近似和影响函数中再次出现。
同一个"廉价地近似曲率/度量"的思想,驱动了 2018–2026 年间的一系列优化器,每个都选择了不同的几何:Shampoo(Gupta et al. 2018, 1802.09568)使用逐维度的 Kronecker 预条件子;distributed Shampoo(Anil et al. 2020, 2002.09018;Shi et al. 2023, 2309.06497)把它扩展到生产规模;Sophia(Liu et al. 2023, 2305.14342)使用一个廉价的对角 Hessian 估计;SOAP(Vyas et al. 2024, 2409.11321)证明了在预条件子的特征基下 Shampoo ≈ Adam;而 Muon(Jordan et al. 2024;"Muon is Scalable," Liu et al. 2025, 2502.16982)对更新做正交化 —— Bernstein & Newhouse(2409.20325)证明这是谱范数下的最速下降,一种不同于 Fisher 的度量,但秉持同样的"选择你的几何"哲学。
| 优化器 | 假设的几何 / 它近似的对象 | 曲率结构 | 开销 |
|---|---|---|---|
| SGD | 欧几里得(度量 $=I$) | 无 | 最便宜 |
| Adam | 对角(经验)Fisher —— 逐坐标重缩放 | 对角 | 便宜 |
| K-FAC | 块对角 Fisher,每层用 Kronecker $A\otimes G$ | 块 + Kronecker | 中等 |
| Shampoo | 逐维度 Kronecker 预条件子(≈ 完整高斯-牛顿) | Kronecker,双侧 | 中-高 |
| SOAP | Adam 特征基下的 Shampoo(更便宜,≈ Shampoo) | Kronecker 特征基 | 中等 |
| Sophia | 对角 Hessian 估计(裁剪过的) | 对角 Hessian | 便宜 |
| Muon | 谱范数最速下降(正交化的步) | 谱范数,而非 Fisher | 中等 |
| 自然梯度(理想) | 精确 Fisher $\Fish^{-1}\grad L$ | 完整 $d\times d$ | 大规模下不可行 |
每一行都是对"最速下降应该用什么度量?"的一个不同回答。大多数都近似 Fisher(§9 的警告:你永远负担不起精确的那个);Muon 则换成了谱范数。这就是把"选择你的几何"这一思想做成了一份菜单。
这是"Fisher = KL 的 Hessian"(§8.1)变成一个价值十亿美元算法的最干净的地方。下面把整条谱系作为一条流水线呈现 —— 把每个方框读作"它增添了什么 / 它的代价是什么":
术语注解:信赖域 · 策略梯度 · 概率比率。
贯穿主线:Fisher 是 KL 的 Hessian ⟶ Kakade 用它做预条件 ⟶ TRPO 把它变成一个硬性的 KL 信赖域 ⟶ PPO/GRPO 用裁剪/惩罚来近似那个信赖域。每当你在一篇 RLHF 或推理模型论文里读到"KL 惩罚",你读到的就是信息几何。
除了优化之外,Fisher 矩阵还是一把瑞士军刀:它同时身兼参数重要性、后验精度与影响力三职。统一这一切的事实是(Martens 2020,1412.1193):对于指数族损失,在极小点处 Fisher = 广义高斯–牛顿 ≈ Hessian,并且(Jacot et al. 2018,NTK,1806.07572)它正是神经正切核在参数空间中的对偶。因此"使用 Fisher" =" 使用曲率" = "使用局部 KL 度量"。它会在以下五处现身:
| Fisher 的用途 | 论文 | 几何如何被使用 |
|---|---|---|
| 持续学习 (别忘了旧任务) |
Kirkpatrick et al., EWC 2017 PNAS · 1612.00796 very-high | 用一个以 Fisher 对角元 加权的惩罚项,把每个权重锚定到它的旧值。高 Fisher 的权重是"刚性的"(损失在那里曲率陡峭 → 重要),低 Fisher 的权重则保持可塑。形式上这是一个拉普拉斯近似:Fisher = 跨任务传递的高斯后验的精度。 |
| 贝叶斯不确定性 (事后、廉价) |
Ritter et al. 2018 ICLR;Daxberger et al., Laplace Redux 2021 NeurIPS · 2106.14806 | 在训练好的网络权重周围拟合一个高斯,其精度矩阵就是 Fisher/GGN(经 K-FAC 分解)。无需重新训练即可给出经过校准的不确定性 + 基于边际似然的模型选择——"毫不费力的贝叶斯深度学习"。 |
| 模型合并 (融合多个微调) |
Matena & Raffel, Fisher-weighted averaging 2022 NeurIPS · 2111.09832 | 通过逐参数的 Fisher 加权平均来合并多个模型——每个模型在它最有把握的坐标上(高 Fisher)主导合并结果。它是 Task Arithmetic(Ilharco et al. 2023,2212.04089,该方法刻意不使用任何曲率)有原则的近亲。 |
| 剪枝 (移除参数) |
Molchanov et al. 2019 CVPR · 1906.10771;LLM-Pruner 2023 · 2305.11627 | 用损失的泰勒展开给每个权重/滤波器打分;其中的梯度平方项就是一种经验 Fisher 重要性。低 Fisher 的参数可以安全删除(Optimal-Brain-Damage 一脉),如今已应用到 LLM 规模。 |
| 数据归因 (是哪个样本导致的?) |
Koh & Liang, Influence Functions 2017 ICML best paper · 1703.04730;Grosse et al. 2023(Anthropic, 52B)· 2308.03296 | 通过逆 Hessian 与向量的乘积把一个预测追溯到对它影响最大的训练点——而在最优点处 Hessian 就是 Fisher。扩展到 LLM 需要 EK-FAC 的 Fisher 近似;纯粹是把 §10 的机器复用于可解释性。 |
在这里,§2–§3 中的非欧几里得几何直接回归:我们不再去弯曲分布的空间,而是弯曲模型放置其表示的嵌入空间。曲率的选择,就是归纳偏置的选择。
奠基工作——把符号化层级嵌入庞加莱/洛伦兹球:
架构工作——让整个网络弯曲:
2023–2026 前沿——曲率进入基础模型:
2023–2026 间迅速增长的一批文献开始测量 transformer 隐状态的几何——并发现它绝非平坦的欧几里得:
最后这条主线把前面两半融为一体:要么栖居于黎曼流形之上的生成模型(§4–§6),要么在最优传输几何下搬运概率质量的生成模型——而后者本身就是分布空间上的一个黎曼度量(§8)。
蛋白质主链是一串刚性坐标系——乘积流形 $SE(3)^N$(旋转 $\times$ 平移)上的一个点。生成分子/蛋白质 = 在该流形上运行一个扩散或流,并尊重其对称性。这是黎曼生成建模在现实世界中最具影响力的回报。
Wasserstein 距离为概率分布空间赋予了它自己的黎曼结构(即 Otto 度量),其中测地线是质量传输方案,而 梯度流描述扩散。这是信息几何带有传输风味的姊妹。
即便是一个普通的 VAE/GAN/扩散潜空间,暗地里也是黎曼的:解码器 $g$ 把数据空间的度量拉回到潜空间,$\Met(\vz)=J_g(\vz)^\top J_g(\vz)$(解码器 Jacobian),因此在潜坐标里做“直线插值”在几何上是错的——你应当沿测地线走。
这些都不只是黑板上的推演。上面的每个概念,本周你用过的产品里都在运行。这里给出从想法 → 落地系统的对照图,并指明背后的公司与模型。值得注意的规律是:一篇几何论文要变成某个 API 旋钮或一次前沿训练实验,往往需要 2–7 年。
dimensions 旋钮。 一篇关于在超球面上嵌套表示的 NeurIPS 论文(2205.13147),在不到两年内变成了一个实打实的 API 参数:text-embedding-3 让你把一个单位球面向量从 3072→256 维截断后重新归一化,用精度换速度,无需重新训练。text-embedding-3(2205.13147)、Nomic、Cohere —— 嵌套的球面归一化嵌入,作为一个 API dimensions 旋钮。E5 → Microsoft(2212.03533),开源权重的 RAG 主力,用球面上的对齐+均匀性目标训练(2005.10242)。| 概念 | 符号 | 一句话含义 | 在 AI 中的出现 |
|---|---|---|---|
| 流形 | $M$ | 局部平坦的弯曲空间 | 数据流形;嵌入空间;蛋白质的 $SE(3)^N$ |
| 切空间 | $T_pM$ | 方向所构成的局部线性空间 | 梯度/速度所在的地方 |
| 度量张量 | $g_{ij}$ | 依赖位置的勾股定理,$ds^2=d\vx^\top \Met\,d\vx$ | 核心对象——选择几何 = 选择 $g$ |
| 测地线 | $\gamma$ | 最直/最短路径 | 潜空间插值;流匹配路径;双曲距离 |
| 曲率 | $K, R^l_{ijk}$ | 度量无法保持常数的程度;和乐 | 双曲($K\!<\!0$,层级)vs 球面($K\!>\!0$,相似性) |
| $\exp$/$\log$ 映射 | $\exp_p,\log_p$ | 在流形与切空间之间往返 | 每一个双曲层;黎曼 SGD |
| 得分函数(参数) | $\grad_\theta\log p$ | 似然对参数的敏感度 → 构建 Fisher | MLE、Fisher 信息(§7–8) |
| 得分函数(数据) | $\grad_x\log p$ | 指向概率更高数据的方向 | 基于得分的扩散 / 得分匹配(§13) |
| Fisher 信息 | $\Fish$ | 得分函数的方差 = KL 的 Hessian = 分布上的度量 | 自然梯度、EWC、Laplace、模型合并、影响函数 |
| Fisher–Rao 度量 | $g=\Fish$ | 统计流形的度量 | 信息几何;重参数化不变的更新 |
| KL 散度 | $\KL(p\|q)$ | $\approx\tfrac12\delta^\top\Fish\delta$;典范散度 | TRPO/PPO/GRPO 信赖域;VAE/变分损失 |
| 自然梯度 | $\Fish^{-1}\grad L$ | Fisher 度量下的最速下降 | K-FAC、Shampoo、自然策略梯度 |
| Wasserstein 度量 | $W_2$ | 通过质量传输定义的黎曼度量 | WGAN、OT 流匹配、作为梯度流的扩散 |
最易上手的路线:
严谨路线:do Carmo, Differential Geometry of Curves and Surfaces → do Carmo / J.M. Lee, Riemannian Geometry → Lehmann & Casella, Theory of Point Estimation(把 Fisher 信息讲透)→ Amari & Nagaoka, Methods of Information Geometry(典范著作)以及 Amari, Information Geometry and Its Applications(2016,更注重教学)。
奠基性的一手文献:Riemann 1854 年的就职演讲 On the Hypotheses Which Lie at the Bases of Geometry;Gauss 的 Theorema Egregium(1827);Fisher(1925);Rao(1945,Fisher–Rao 度量与 Cramér–Rao);Chentsov(1972,Fisher 度量的唯一性)。
| 主题 | 最佳进阶资源(标 ✓ 者免费) |
|---|---|
| 几何深度学习(统一性框架) | ✓ Bronstein, Bruna, Cohen, Veličković, GDL: Grids, Groups, Graphs, Geodesics, Gauges — arXiv:2104.13478 + 讲座课程 |
| 微分几何,对 CS 友好 + 含代码 | ✓ Keenan Crane, Discrete Differential Geometry — CMU 课程 + 视频;✓ Carroll 的 GR notes 培养指标直觉 |
| 最优传输 | ✓ Peyré & Cuturi, Computational Optimal Transport — 免费书;库 POT 与 OTT-JAX |
| 信息几何 | ✓ Nielsen, Elementary Introduction to Information Geometry — arXiv:1808.08271;Martens, Natural Gradient — 1412.1193 |
| 流匹配(几何式生成) | ✓ Lipman et al., Flow Matching Guide and Code — arXiv:2412.06264 + PyTorch 库 |
| 双曲 / 基础模型中的几何 | ✓ 综述:Peng et al. 2021(2101.04562);Mettes et al. IJCV 2024;Hyperbolic DL for Foundation Models 2025(2507.17787) |
| 直觉热身 | ✓ 3Blue1Brown — Essence of Linear Algebra / Calculus |
建议顺序:3Blue1Brown → GDL 书+讲座 → Crane(动手实践)→ Nielsen(信息几何)→ Martens(自然梯度)→ Peyré–Cuturi(最优传输)→ Lipman(流匹配)→ 双曲综述。
这里引用的每一篇论文都有一份完整、有组织的参考文献——包含作者、年份、发表场所、arXiv ID、引用层级,以及一句话说明每篇如何运用几何——见 REFERENCES.md(并按主题分组)。这份 HTML 是教程;那份文件是文献地图。
作为一份自洽的讲解材料而构建 · 所有论文均通过网络搜索结合 arXiv ID 验证 · 数学由 MathJax 渲染 · 图示用 SVG 手工绘制 · 交互演示用原生 JS 实现。
几何不过是度量小步长的规则。其余的一切——包括智能在内——都是你在这条规则之上构建出来的东西。