Put a binary tree in a flat plane and, by depth 5, neighbouring leaves sit closer than one edge. Put it in a hyperbolic plane and they never crowd, in only two dimensions.
Drag the depth up and watch the warm leaves fuse while the teal ones stay apart. Then we build, piece by piece, the disk, its distance, the training rule, the cones and the limits.
You need a vector is a list of numbers and a little Python. We build curvature, the distance formula and the rest from zero.
Built on Nickel and Kiela, Poincaré Embeddings (2017); Ganea, Bécigneul and Hofmann, Hyperbolic Entailment Cones and Hyperbolic Neural Networks (2018); and Desai et al., MERU (2023).
Both panels use the same rule: each child gets an equal slice of its parent's angle, one edge (length 1) further out. The distances are exact for that layout; the layout itself is a simple illustration, not a trained model.
Chapter 0
Count the room a flat plane offers a tree, and see it run out at depth five
You have a taxonomy: a dalmatian is a dog, a dog is a carnivore, and so on up to "entity". You give each node a vector and train so that parents sit near their children. The top looks fine. At the bottom, dalmatian, dachshund and tabby cat all sit about the same distance apart.
More dimensions and more epochs do not fix it. The problem is room, and we can count it.
Take a complete binary tree: every node has two children. Give every edge length 1. Put the root at the centre of a flat plane, so the nodes at depth k sit on a circle of radius k.
| Depth k | Nodes (2 to the k) | Circle length (2πk) | Room per node |
|---|---|---|---|
| 3 | 8 | 18.85 | 2.36 |
| 5 | 32 | 31.42 | 0.98 |
| 10 | 1,024 | 62.83 | 0.061 |
| 20 | 1,048,576 | 125.66 | 0.00012 |
The demand doubles at each level. The supply grows by 6.28 at each level. At depth 5, neighbouring leaves get 0.98 of room, less than one edge. At depth 10 they get 0.061, about 16 times less than one edge.
Distortion is how much the embedding stretches or squeezes the tree's distances. At depth 10, two neighbouring leaves on either side of the root's split are 20 edges apart in the tree but 0.061 apart in the plane. That is a squeeze of about 330 times.
Warm is the flat plane, teal the hyperbolic plane of Chapter 1. The dashed line is one edge. Drag the depth and read the gap.
Exact arithmetic, binary tree, unit edges. Flat room is 2πk / 2k. Hyperbolic room is 2π sinh k / 2k (Chapter 2).
In D flat dimensions, the room inside radius r grows like r to the power D. That is a polynomial. The tree grows like 2 to the depth, an exponential. For any fixed D, the exponential wins once the tree is deep enough.
This is a theorem. Bourgain (1986) showed that a complete binary tree of depth h needs distortion that grows like the square root of log h. That holds in every Euclidean space, whatever the dimension. Sarkar (2011) showed that any tree fits in the two-dimensional hyperbolic plane with distortion as close to 1 as you like.
The failure. Symptom: deep siblings and deep cousins sit at the same distance. Measure: for each leaf, compare the distance to its sibling with the distance to a cousin; a healthy embedding keeps the sibling closer. Fix: change the geometry, not the dimension.
Chapter 1
Squeeze an endless space into a unit disk with a ruler that shrinks toward the rim
A world map fits a sphere on a page by changing the scale. We do the reverse: we squeeze an endless space into the open unit disk, and a centimetre near the rim stands for a long true distance. This is the Poincaré disk: all points x with length below 1.
Call the map length of a point x ‖x‖. Call the factor that turns a short map step at x into true length λx, the conformal factor.
Lambda-x equals two over one minus the norm of x squared.
Square the map radius of x, take it from one, and divide two by the result. A short map step at x is worth λx times its length.
At the centre, λ = 2. At ‖x‖ = 0.9, λ = 2 / 0.19 = 10.5. At 0.99, λ = 2 / 0.0199 = 100.5. Each extra nine in the radius makes the ruler about ten times shorter.
Add up the true lengths of tiny steps from the centre to map radius r: the integral of 2 / (1 − t2) = 1/(1 − t) + 1/(1 + t). It gives:
d(0, x) = ln((1 + r) / (1 − r)) = 2 artanh(r)
At r = 0.5 this is ln 3 = 1.10; at 0.99 it is 5.29. As r goes to 1 the distance goes to infinity, so the rim is never reached. The inverse is r = tanh(d / 2).
For two points u and v, call their map gap ‖u − v‖ and their true distance d(u, v):
d of u and v equals arc-cosh of one plus two times the norm of u minus v squared, over the two rim factors.
Square the map gap. Divide by both rim factors, double, add one, and take arc-cosh. The same gap counts for more near the rim.
u = (0.5, 0), v = (0, 0.5): gap squared 0.5, each rim factor 0.75. Inside: 1 + 1.0 / 0.5625 = 2.78, so d = 1.68. Now u = (0.99, 0), v = (0, 0.99): inside is 1 + 3.92 / 0.000396 = 9,901, so d = 9.89.
Compare each with the route through the centre. Near the centre the direct path saves 23% (1.68 against 2.20). Far out it saves only 6.5% (9.89 against 10.59). Far out, the shortest path almost goes through the common ancestor, as in a tree.
Rings sit at true radius 1 to 5. Teal is the shortest path, warm dashed the chord. Drag a dot outward.
Exact formulas. The curve is the true geodesic: an arc that meets the rim at right angles, because a path that bends inward uses the cheaper ruler.
pythondef poincare_dist(u, v, eps=1e-7): # u, v: (..., d), norms below 1 su, sv = (u*u).sum(-1), (v*v).sum(-1) duv = ((u - v)**2).sum(-1) a = (1 - su).clamp_min(eps); b = (1 - sv).clamp_min(eps) # no divide by zero at the rim return torch.acosh((1 + 2*duv/(a*b)).clamp_min(1 + eps)) # acosh needs an input of at least 1
The failure. Symptom: nan spreads through the table. Measure: log the smallest acosh input each step. Fix: keep both clamps, because round-off can hand acosh 0.9999999.
Chapter 2
Measure a hyperbolic circle and find the edge length that lets any tree fit
Chapter 0 said the flat plane fails because its circles grow linearly. Now measure a circle in the disk. Call its true radius s and its true length L(s).
On the map the circle has radius r = tanh(s/2) and map length 2πr. Every bit of it sits where the ruler factor is 2/(1 − r2). Multiply, and use two hyperbolic identities:
L of s equals two pi times sinh of s.
Take the radius s. Work out sinh of s and multiply by two pi. For small s this is the flat answer, 2πs. For large s, each extra unit of s multiplies L by about e = 2.72.
At s = 1, L = 7.38 against a flat 6.28. At s = 10, L = 69,198 against 62.8, about 1,100 times more. At s = 20, L is 1.5 billion against 126.
The derivation: r/(1 − r2) = tanh(s/2) cosh2(s/2) = ½ sinh s, so L = 4π × ½ sinh s. A point is still two numbers. The room comes from how we read them.
Give the tree a branching factor b (children per node) and an edge length ℓ. Level k holds bk nodes on a circle of length about πekℓ. Room per node is about π(eℓ/b)k. It grows with depth when eℓ is bigger than b:
Ell is greater than the natural log of b.
Count the children per node, b. Take its natural log. Make every edge ℓ longer than that, and the room per node grows at every level instead of shrinking.
A binary tree needs ℓ above ln 2 = 0.69. With ℓ = 1, e/2 = 1.36, so room per leaf grows 36% per level: 7.87 at depth 3, 14.57 at depth 5. A node with 500 children needs ℓ above ln 500 = 6.21.
Teal is hyperbolic room per node by level, warm is flat. Set b to 4 and ℓ to 0.7, then push ℓ past 1.39.
Exact: room per node at level k is 2π sinh(kℓ) / bk (hyperbolic) and 2πkℓ / bk (flat).
The change at ℓ = ln b is sharp. Below it, room shrinks by a fixed factor at every level. Above it, room grows by a fixed factor.
That is why Poincaré figures look like confetti on the rim. Two leaves at true radius 9.8 that are 4.2 apart sit 0.051 degrees apart on the map. The crowding is the map's scale, not the model.
The failure. Symptom: the children of a huge category pile on top of each other. Measure: for each node, compare its edge length to its parent with ln(number of siblings). Fix: let norms grow (more radius) for high fan-out nodes, or raise the curvature.
Chapter 3
Turn a flat vector into a point in the ball and back, so ordinary layers can work on it
Your encoder outputs a flat vector. A linear layer multiplies flat vectors. The ball has no plain "add" or "scale": doubling a stored point can push it outside the ball. We need a bridge between the flat world and the ball.
At the centre of the ball, picture a flat sheet that touches it: the tangent space. A vector on that sheet is a direction and a length. The exponential map walks that length along the shortest path in that direction. The logarithmic map undoes it.
Call the flat vector v, its true length ‖v‖, and the point where the walk ends exp0(v). From Chapter 1, a point at true distance s from the centre sits at map radius tanh(s/2). So:
Exp-zero of v equals tanh of half the norm of v, times v over the norm of v.
Keep the direction of v. Turn its length ‖v‖ into a map radius with tanh of half of it. The log map runs backward: log0(x) keeps the direction of x and sets the length to 2 artanh(‖x‖).
v = (1.2, 1.6) has length 2. tanh(1) = 0.762, so exp0(v) = (0.457, 0.609). Its true distance from the centre is 2 artanh(0.762) = 2.00, the length of v.
Ganea, Bécigneul and Hofmann (2018) build hyperbolic neural networks on this bridge. Their Möbius matrix-vector product is exp0(M log0(x)): go to the flat sheet, apply the matrix M, come back. The answer is always inside the ball.
Teal is x. Purple is the Möbius scaling, log then scale then exp. Warm is the naive scaling of the stored numbers. Drag the scale past 1.3.
Exact maps at the centre. The direction is fixed at 53 degrees so the two scaled points stay on one ray.
Work the default. x is at true radius 2, map radius 0.762. Doubling the stored numbers gives map radius 1.52: outside the ball, not a point at all. The Möbius scale doubles the true radius to 4, map radius 0.964. Halving gives true radius 1, map radius 0.462.
The failure. Symptom: a layer's output has norm above 1, and the distance returns nan. Measure: assert every output norm is below 1 after each layer. Fix: route each flat operation through log0 and exp0, or use a library layer that does.
Chapter 4
Rank true parents above random nodes, and correct each gradient step for the shrinking ruler
Nickel and Kiela (2017) train on the WordNet nouns plus their transitive closure: a dalmatian is a dog and a dog is a carnivore, so (dalmatian, carnivore) counts as a pair too. That gives 82,115 nouns and 743,241 pairs.
For each true pair (u, v), v should sit closer to u than unrelated nodes do. Call the set of v plus 10 sampled unrelated nodes N(u), and the loss for one pair ℓ(u, v).
The loss for u and v equals minus the log of a fraction. On top: e to the minus d of u and v. Below: the sum over v-prime in N of u of e to the minus d of u and v-prime.
Turn each distance from u into a score, e to the minus distance. Divide the true parent's score by the total. The loss is minus the log of that share.
With made-up distances: the true pair at d = 1.2 scores 0.301. Five negatives at 2.8, 3.0, 3.5, 4.0, 5.0 score 0.166 in total. The share is 0.301 / 0.467 = 0.645, so the loss is 0.439. If the pair drifts to d = 2.5, the loss rises to 1.105.
It is word2vec's softmax with a distance in place of a dot product. The nearest negative gets 9 times the push of the farthest (shares 0.130 and 0.014).
Autograd gives the Euclidean gradient ∇E, the slope in stored numbers. Near the rim a tiny stored change is a huge true move, so the true steepest step is ∇E divided by λ2. Call the stored vector θ and the learning rate η.
Theta becomes proj of: theta minus eta, times one minus the norm of theta squared, all squared, over four, times grad-E.
Shrink the autograd gradient by the rescale. Step against it by η. If the point leaves the ball, put it back just inside.
At ‖θ‖ = 0.99 the distance gradient has map size 100.5 and the rescale is 0.000099. With η = 0.1 the map step is 0.000995, worth 100.5 × 0.000995 = 0.1 true units. The true step is η at every radius.
Warm is plain SGD, teal is Riemannian. Slide the node outward.
η = 0.1, and the gradient is the radial gradient of the distance from the centre, of map size 2 / (1 − r2). Exact arithmetic.
pythondef rsgd_step(emb, lr, eps=1e-5): # emb.weight: (n, d) points in the ball with torch.no_grad(): w, g = emb.weight, emb.weight.grad a = 1 - (w*w).sum(-1, keepdim=True) # (n, 1) w -= lr * (a**2 / 4) * g # the metric correction n = w.norm(dim=-1, keepdim=True) w[:] = torch.where(n >= 1, w / n * (1 - eps), w) # proj
The paper starts points uniform in (−0.001, 0.001) and runs a burn-in: 10 epochs at a tenth of the rate. Turning a node by Δφ at true radius s costs sinh(s)Δφ, so angles must settle before nodes move out.
The result on WordNet reconstruction (the paper's Table 1): 5 Poincaré dimensions reach mean rank 4.9 and MAP 0.823; 200 Euclidean dimensions reach mean rank 1157.3 and MAP 0.168.
The failure. Symptom: after one epoch every deep node sits on the rim. Measure: a histogram of true radii. Fix: the rescale, or geoopt's RiemannianAdam; plain Adam moves outer nodes 375 times farther per step.
Chapter 5
Read the branch from the angle and the depth from the true radius
Training ends with 82,115 vectors, each with norm below 1. A Euclidean embedding gives one reading: distance means related. A hyperbolic embedding gives two. Distance still means related. Distance from the centre means how specific a concept is. Nobody labels this; training produces it.
"Mammal" must be near thousands of descendants spread over many directions. Only a point near the centre is close to a wide fan of directions. The distance formula shows this. Take two points at true radii su and sv, with an angle φ between them seen from the centre. When both radii are above about 3:
d of u and v is about s-u plus s-v plus two times the natural log of sine of phi over two.
Add the two depths su and sv. Subtract a shortcut that grows as the angle φ shrinks. That is the tree distance: depth of u plus depth of v minus twice the depth of their lowest common ancestor.
Two points at map radius 0.99 (true radius 5.293), 90 degrees apart: 5.293 + 5.293 + 2 ln 0.707 = 9.893. The exact formula of Chapter 1 gives 9.894.
So the angle says which branch. The radius says how far down that branch. Nobody designed this split; the metric forces it.
Top: the disk. Middle: the stored norm from 0 to 1. Bottom: the true radius. Pick a level and compare the rulers.
The chain is WordNet's hypernym path for dalmatian. The placement, 0.7 of true radius per level, is illustrative.
Look at the middle ruler. Mammal (level 9) has stored norm 0.99633 and dalmatian (level 14) has 0.99989. Five levels differ by 0.0036. Always convert with 2 artanh(‖x‖): that number grows by 0.7 per level.
Distance is symmetric, so it cannot say who is the parent. Nickel and Kiela add the norms: score(u is-a v) = −(1 + α(‖v‖ − ‖u‖)) d(u, v), with α = 1000. For dog and dalmatian at distance 0.7, the right direction scores −0.621 and the wrong one −0.779. It works, with a thin margin. Chapter 6 builds order into the shape instead.
The failure. Symptom: a node with two unrelated parents reads as too general. Measure: compare its true radius with its depth in the graph. Fix: read norms only within one subtree. If you rely on norms, pin a known root at the centre; the loss does not fix the centre.
Chapter 6
Give every point a cone, and call everything inside it a descendant
A dalmatian is a dog; a dog is not a dalmatian. Distance cannot say that, because d(u, v) = d(v, u). Ganea, Bécigneul and Hofmann (2018) use a shape that is one-way by nature: a cone. Each point x owns a region that opens outward from it. Then v is a descendant of u when v lies in u's cone.
The order must be transitive: if w is under v and v is under u, then w is under u. So a child's cone must sit inside its parent's cone. That rule fixes the cone's width. Call the half-width of the cone at x its half-aperture ψ(x), and call a constant K.
Psi of x equals arc-sine of K times one minus the norm of x squared, over the norm of x.
Take the map radius of x. Compute K times one minus its square, divided by it. The arc-sine of that is the half-width. Near the centre the cone is wide; far out it is a needle.
With K = 0.1: at ‖x‖ = 0.2, ψ = arcsin(0.48) = 28.7°. At 0.5, 8.6°. At 0.9, 1.2°. At 0.99, 0.12°. The arc-sine needs the inside at most 1, so no apex may sit within 0.099 of the centre.
To test membership, measure Ξ(x, y): the angle at x between the outward axis and the shortest path toward y. The point y is inside when Ξ is at most ψ(x). The energy E(x, y) = max(0, Ξ − ψ) is how far y must swing to get in.
Purple is the apex x; its pink cone has the width the formula gives. Blue is the candidate y. The faint inner cone belongs to a point further out on the axis. The grey disk is forbidden.
K = 0.1, as in the paper. Cone edges are exact geodesics; Ξ uses the paper's closed form, checked here against a direct geodesic computation.
Work the default. The apex x = (0.3, 0) has ψ = arcsin(0.1 × 0.91 / 0.3) = 17.7°. The candidate (0.6, 0) is straight outward: Ξ = 0, energy 0. The candidate (0.35, 0.3) is further out but sideways: Ξ = 86.3°, energy 68.6°. Radius alone would call it a descendant. The cone does not.
Training uses a hinge: true pairs pay their energy, false pairs pay max(0, γ − E) with margin γ = 0.01. Once a pair is right, it stops pulling. The cost is a cold start, so the paper starts from Poincaré embeddings trained for 100 epochs.
The failure. Symptom: cone training from random vectors does not organise. Measure: the share of true pairs with zero energy after a few epochs. Fix: initialise from a trained distance embedding, then refine with the cone loss.
Chapter 7
Let a caption's cone hold its images, and let the encoder's output length mean specificity
A photo shows a dalmatian asleep on a red sofa. "A dog" and "a dalmatian sleeping" both describe it, and each leaves out detail. So a caption is more general than its image: a hierarchy nobody wrote down.
CLIP scales every embedding to length 1, so every point sits at the same radius and nothing is "further out". Desai et al. (2023) built MERU: CLIP's two encoders and contrastive loss in hyperbolic space, plus a cone term.
MERU uses the Lorentz model (the hyperboloid). A point stores its space part xspace. Its time coordinate is xtime = √(1/c + ‖xspace‖2), where c is the learned curvature size. The Lorentzian inner product is 〈x, y〉L = −xtimeytime + 〈xspace, yspace〉.
d of x and y equals one over root c, times arc-cosh of minus c times the Lorentz inner product of x and y.
Rebuild both time coordinates. Take the space dot product minus the product of the time coordinates. Multiply by minus c, take arc-cosh, divide by root c.
With c = 1, put x at distance 0.8 from the root on one axis: xtime = cosh 0.8 = 1.337. Put y at distance 1.5 on a perpendicular axis: ytime = 2.352. The space parts are perpendicular, so the inner product is −3.146 and d = arcosh(3.146) = 1.81.
Why not the disk? Far out, the disk subtracts two numbers near 1 and loses precision. On the hyperboloid far points have large coordinates (xtime = cosh s), which keep their precision.
The exponential map at the root turns the encoder output v into xspace = sinh(√c ‖v‖) v / (√c ‖v‖). With c = 1 the distance from the root is ‖v‖: the length CLIP threw away now means specificity.
Left: CLIP. Right: MERU, purple caption, blue images. Slide the caption outward.
Aperture is MERU's formula with K = 0.1 and c = 1; the image positions are illustrative, all at distance 2.0 from the root.
MERU's half-aperture is arcsin(2K / (√c ‖xspace‖)) with K = 0.1. Since ‖xspace‖ = sinh s for c = 1, at s = 0.8 it is arcsin(0.2 / 0.888) = 13.0°. Ganea's disk formula at the same point gives 13.0° too: it is the same cone.
The authors trained MERU and a matched CLIP on RedCaps, 12 million image-text pairs. MERU matches or beats CLIP on 13 of the first 16 zero-shot classification datasets; the paper calls it competitive. The clear gain is structure: moving an image toward the root passes ever more generic captions.
The failure. Symptom: a large MERU model trains poorly. Measure: compare runs with c learned and c fixed at 1. Fix: learn c; the paper reports that fixed c = 1 makes ViT-L hard to optimise.
Chapter 8
Measure how tree-like your data is, then count the levels your float type can hold
Hyperbolic embeddings help on tree-like data at low dimension. Elsewhere they add cost. Check two things before you commit.
Gromov δ-hyperbolicity measures it. Take four points w, x, y, z and pair them up in the three possible ways. Add the two distances in each pairing. Then δ is half the gap between the largest and the middle sum, at its worst over all quadruples.
| Four points | The three sums | δ | 2δ / diameter |
|---|---|---|---|
| Four leaves of a binary tree (two sibling pairs) | 4, 8, 8 | 0 | 0 |
| Four corners of a square, edge 1 | 2, 2, 4 | 1 | 1 |
The ratio 2δ / diameter runs from 0 (a tree) to 1. Sample a few thousand quadruples from your graph. Near 0, hyperbolic space should help. Near 1, the data is full of squares, and it will not.
At true radius s, the rim factor 1 − ‖x‖2 is about 4e−s. A float type cannot tell numbers near 1 apart below its machine epsilon ε. Call the largest usable true radius smax.
s-max equals the natural log of four over epsilon.
Set the rim factor 4e−s equal to epsilon and solve for s. Past smax, the stored norm rounds to 1 and the distance becomes infinite. Divide smax by the edge length to get the levels you can hold.
float32: smax = ln(4 / 1.19 × 10−7) = 17.3. float64: 37.4. A tree with 100 children per node needs ℓ above ln 100 = 4.61, so float32 holds 17.3 / 4.61 = 3 levels.
The dashed line is perfect storage. Yellow is what float32 gives back. Drag the radius past 15.
Real float32 rounding (Math.fround) of tanh(s/2), read back with 2 artanh in float64.
In float32, radius 17 and radius 18 store the same number, 0.99999994. Radius 20 stores exactly 1.0, and its distance is infinite. The loss looks healthy the whole time, because it uses the same broken distances.
| Cost | Why |
|---|---|
| Optimiser | Needs the rescale of Chapter 4; momentum needs extra care. |
| Averaging | No closed-form mean; the Fréchet mean needs iteration. |
| Vector database | Stock ANN indexes search inner product, cosine or L2. In the Lorentz model, d grows with −〈x, y〉L, so you can rewrite the search as maximum inner product over (−xtime, xspace). The Poincaré form needs that conversion first. |
| Precision | Silent wrong answers past smax. |
The failure. Symptom: deep nodes return identical distances, or nan mid-epoch. Measure: the histogram of true radii against smax. Fix: compute distances in float64, use the Lorentz model, or lower the curvature so the tree needs less radius.
Chapter 9
Put the sphere, the plane and the saddle on one dial, and match it to your data's growth
You already choose a geometry every time you train an embedding. If you scale vectors to length 1 and score with cosine, you work on a sphere. Chapter 2's measurement, the length of a circle of radius r, sorts every constant-curvature space by one number: the curvature K.
| Curvature K | Circle length at radius r | Fits | You have seen it in |
|---|---|---|---|
| Positive (sphere) | 2π sin(√K r)/√K: grows, peaks, returns to 0 | directions, bounded variety | cosine similarity, CLIP |
| Zero (plane) | 2πr: linear | additive, compositional structure | PCA, word2vec analogies |
| Negative (hyperbolic) | 2π sinh(√−K r)/√−K: exponential | trees, taxonomies | this lesson |
Faint curves are the sphere (K = 1), the plane and the saddle (K = −1). The bold curve is your K. Drag from positive to negative.
Exact formulas. On a sphere the largest circle sits at radius π/(2√K). The readout uses it when it is under 5.
Work three cases at radius 5. The plane gives 31.4. The saddle with K = −1 gives 466. A gentler saddle, K = −0.25, gives 76. Lower curvature means less room per unit radius, which is the knob Chapter 8 used to save precision.
| Method | Order rule | Worked case |
|---|---|---|
| Order embeddings (Vendrov et al., 2016) | u is under v when every coordinate of u is at least v's. Penalty: the squared norm of max(0, v − u). | dalmatian (3, 5, 2), dog (1, 4, 2): penalty 0 one way, 5 the other way. |
| Box embeddings (Vilnis et al., 2018) | Each concept is a box; P(u | v) is the overlap volume over v's volume. | dog [0,4]×[0,3], dalmatian [1,2]×[0,3]: P(dalmatian | dog) = 3/12 = 0.25. |
| Product spaces (Gu et al., 2019) | A point is a tuple across hyperbolic, spherical and flat parts; squared distances add. | Search the mix of parts as a hyperparameter. |
The failure. Symptom: the embedding is mushy at the bottom of a hierarchy. Measure: count how many points lie within k steps of a node as k grows. Fix: match the space to that growth: polynomial means flat, bounded means sphere, exponential means hyperbolic.
Chapter 10
Keep the numbers, the checklist and the core code in one place
A tree's demand grows exponentially; flat space's supply does not. The Poincaré disk's shrinking ruler gives circles of length 2π sinh s, so trees fit when edges are longer than ln b. Train with a distance softmax and a rescaled step. Read the angle as the branch and the true radius as the depth. Use cones for order, the hyperboloid for precision, and measure δ before you start.
| Term or number | Value |
|---|---|
| Conformal factor | λ = 2/(1 − ‖x‖2) |
| Distance from the centre | 2 artanh(r); map radius = tanh(s/2) |
| Circle length | 2π sinh s |
| Edge-length rule | ℓ > ln b (0.69 for b = 2) |
| Riemannian rescale | (1 − ‖θ‖2)2/4, projection to 1 − 10−5 |
| WordNet closure | 82,115 nouns, 743,241 pairs |
| Poincaré 5-dim (reconstruction) | mean rank 4.9, MAP 0.823 |
| Euclidean 200-dim (reconstruction) | mean rank 1157.3, MAP 0.168 |
| Cone constant | K = 0.1, forbidden radius 0.099 |
| MERU | RedCaps 12M pairs; matches or beats CLIP on 13 of 16 zero-shot datasets |
| Float ceiling | smax 17.3 (float32), 37.4 (float64) |
pythonimport torch, torch.nn.functional as F emb = torch.nn.Embedding(n_nodes, 5) # same (n, d) floats as a flat embedding torch.nn.init.uniform_(emb.weight, -1e-3, 1e-3) # start near the centre for epoch in range(epochs): lr = 0.1 if epoch >= 10 else 0.01 # burn-in for u, v, neg in batches: # (B,), (B,), (B, 10) d_pos = poincare_dist(emb(u), emb(v)) # (B,) d_neg = poincare_dist(emb(u).unsqueeze(1), emb(neg)) # (B, 10) logits = torch.cat([-d_pos[:, None], -d_neg], 1) # (B, 11) F.cross_entropy(logits, torch.zeros(len(u), dtype=torch.long)).backward() rsgd_step(emb, lr) # rescale + project emb.weight.grad = None depth = 2 * torch.atanh(emb.weight.norm(dim=-1)) # read depth, never the raw norm
Now press Present or Teach and explain from memory: why a tree crowds the plane, the distance formula, the edge-length rule, the Riemannian step and the cone width. Then go back to the hero and grow the tree again. This time predict the flat gap before you look.