Hyperbolic Embeddings

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).

Grow one tree in two spaces

4

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

Trees Do Not Fit in Flat Space

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.

Count the demand and the supply

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 kNodes (2 to the k)Circle length (2πk)Room per node
3818.852.36
53231.420.98
101,02462.830.061
201,048,576125.660.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.

Find where the room runs out

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.

5

Exact arithmetic, binary tree, unit edges. Flat room is 2πk / 2k. Hyperbolic room is 2π sinh k / 2k (Chapter 2).

More dimensions only delay the wall

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.

The road

  1. The Poincaré disk: one rule for length, and the distance it gives.
  2. Exponential room: the circle length 2π sinh s, and the edge-length rule.
  3. Exp and log maps: how to move between a flat vector and a point in the ball.
  4. Training on WordNet: the loss and the Riemannian step.
  5. Reading the embedding: angle is the branch, radius is the depth.
  6. Entailment cones: order as a shape.
  7. MERU: captions and images on a hyperboloid.
  8. When it wins, when it breaks: tree-likeness and float precision.
  9. Curvature is a design choice: sphere, plane and saddle on one dial.
  10. Field guide: numbers, code and links.
Why do more flat dimensions fail to fix a deep tree?

Chapter 1

The Poincaré Disk: One Rule for Distance

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.

Say it aloud

Lambda-x equals two over one minus the norm of x squared.

λx
lambda-x the conformal factor: how much true length one unit of map length is worth at the point x.
‖x‖2
the norm of x squared the squared map distance from the centre to x, from 0 up to, but not reaching, 1.
In plain words

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.

With numbers

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).

The distance between any two points

For two points u and v, call their map gap ‖u − v‖ and their true distance d(u, v):

Say it aloud

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.

d(u,v)
d of u and v the true distance between the points u and v.
arcosh
arc-cosh the inverse hyperbolic cosine; for large z it is about ln(2z).
‖u − v‖2
the norm of u minus v squared the ordinary squared gap between the two points on the map.
1 − ‖u‖2
one minus the norm of u squared the rim factor of u: it goes to 0 at the rim.
1 − ‖v‖2
one minus the norm of v squared the rim factor of v.
In plain words

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.

With numbers

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.

Drag two points in the disk

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.

Two points at map radius 0.99, ninety degrees apart, are 9.89 apart. The route through the centre costs 10.59. What does that tell you?

Chapter 2

Exponential Room, and the Edge-Length Rule

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:

Say it aloud

L of s equals two pi times sinh of s.

L(s)
L of s the true length of a circle of true radius s.
sinh s
sinh of s the hyperbolic sine, (es − e−s)/2. It is about s when s is small and about es/2 when s is large.
In plain words

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.

With numbers

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.

When does a tree fit?

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:

Say it aloud

Ell is greater than the natural log of b.

ℓ
ell the true length of one parent-to-child edge.
ln b
the natural log of b where b is the number of children per node.
In plain words

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.

With numbers

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.

Set the edge length until the tree fits

Teal is hyperbolic room per node by level, warm is flat. Set b to 4 and ℓ to 0.7, then push ℓ past 1.39.

4
0.70

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.

A category has 500 direct children and the edges have length 1.0. What does the rule predict?

Chapter 3

Exp and Log: Moving Between Flat and Curved

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:

Say it aloud

Exp-zero of v equals tanh of half the norm of v, times v over the norm of v.

exp0(v)
exp-zero of v the point in the ball you reach by walking from the centre along v.
tanh(‖v‖/2)
tanh of half the norm of v the map radius of a point at true distance ‖v‖. It is always below 1.
v / ‖v‖
v over the norm of v the unit direction of v.
In plain words

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‖).

With numbers

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.

A layer that keeps you inside the ball

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.

Scale a point the right way and the wrong way

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.

2.00
2.00

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.

Why does a hyperbolic layer compute exp0(M log0(x)) instead of M times x?

Chapter 4

Training on WordNet

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.

The loss

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).

Say it aloud

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.

ℓ(u,v)
the loss for u and v the penalty for one true pair.
e−d(u,v)
e to the minus d of u and v the true parent's score; closer scores higher.
Σv′ ∈ N(u)
the sum over v-prime in N of u one term for v and one for each of the 10 negatives.
e−d(u,v′)
e to the minus d of u and v-prime the score of one candidate v-prime.
In plain words

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 numbers

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).

The step: correct for the map

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 η.

Say it aloud

Theta becomes proj of: theta minus eta, times one minus the norm of theta squared, all squared, over four, times grad-E.

θ
theta one node's stored vector inside the ball.
proj
proj if the norm reaches 1, pull the point back to norm 1 − 10−5.
η
eta the learning rate.
(1 − ‖θ‖2)2/4
one minus norm theta squared, squared, over four the rescale, one over lambda squared: 0.14 at norm 0.5, 10−6 at 0.999.
∇E
grad-E the Euclidean gradient of the loss that autograd returns.
In plain words

Shrink the autograd gradient by the rescale. Step against it by η. If the point leaves the ball, put it back just inside.

With numbers

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.

Take one step at your chosen radius

Warm is plain SGD, teal is Riemannian. Slide the node outward.

2.9

η = 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.

Why does Nickel and Kiela's training run a burn-in at a tenth of the learning rate?

Chapter 5

Reading a Trained Embedding

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.

Why the general concepts go to the middle

"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:

Say it aloud

d of u and v is about s-u plus s-v plus two times the natural log of sine of phi over two.

d(u,v)
d of u and v the true distance between the two nodes.
su
s-u the true radius of u: how deep u is.
sv
s-v the true radius of v.
2 ln sin(φ/2)
two log sine phi over two a negative number. Its size, −2 ln sin(φ/2), plays the part of twice the depth of the common ancestor.
In plain words

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.

With numbers

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.

Read one chain three ways

Top: the disk. Middle: the stored norm from 0 to 1. Bottom: the true radius. Pick a level and compare the rulers.

9

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.

In the tree-like formula, what does a small angle φ between two deep nodes mean?

Chapter 6

Entailment Cones: Order as Geometry

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.

Say it aloud

Psi of x equals arc-sine of K times one minus the norm of x squared, over the norm of x.

ψ(x)
psi of x the half-aperture: the angle between the cone's axis (straight outward) and its edge.
arcsin
arc-sine the angle whose sine is the number inside. The number must be at most 1.
K
K a constant that sets how wide cones are; the paper uses 0.1.
1 − ‖x‖2
one minus norm x squared large near the centre, near 0 at the rim.
‖x‖
the norm of x the map radius of the apex x.
In plain words

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 numbers

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.

Drag the apex and the candidate

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.

Why must a cone's half-aperture shrink as its apex moves away from the centre?

Chapter 7

MERU: Images and Captions on a Hyperboloid

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.

The Lorentz model

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⟩.

Say it aloud

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.

d(x,y)
d of x and y the true distance between two embeddings on the hyperboloid.
1/√c
one over root c sets the unit of distance from the curvature size c.
⟨x, y⟩L
the Lorentz inner product of x and y minus the product of the time coordinates, plus the ordinary dot product of the space parts. It is at most −1/c.
In plain words

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 numbers

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.

Move the caption and watch its cone

Left: CLIP. Right: MERU, purple caption, blue images. Slide the caption outward.

0.50

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.

Why does MERU use the Lorentz model rather than the Poincaré ball?

Chapter 8

When It Wins, and When It Breaks

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.

Check one: is the data tree-like?

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 pointsThe three sumsδ2δ / diameter
Four leaves of a binary tree (two sibling pairs)4, 8, 800
Four corners of a square, edge 12, 2, 411

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.

Check two: how many levels fit in your floats?

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.

Say it aloud

s-max equals the natural log of four over epsilon.

smax
s-max the largest true radius the disk can store before 1 − ‖x‖2 rounds to zero.
ln
the natural log undoes the e−s.
ε
epsilon machine epsilon: 1.19 × 10−7 for float32, 2.22 × 10−16 for float64.
In plain words

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.

With numbers

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.

Store a point in float32 and read it back

The dashed line is perfect storage. Yellow is what float32 gives back. Drag the radius past 15.

12.0

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.

CostWhy
OptimiserNeeds the rescale of Chapter 4; momentum needs extra care.
AveragingNo closed-form mean; the Fréchet mean needs iteration.
Vector databaseStock 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.
PrecisionSilent 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.

A float32 Poincaré embedding must hold a taxonomy 12 levels deep with up to 100 children per node. What happens?

Chapter 9

Curvature Is a Design Choice

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 KCircle length at radius rFitsYou have seen it in
Positive (sphere)2π sin(√K r)/√K: grows, peaks, returns to 0directions, bounded varietycosine similarity, CLIP
Zero (plane)2πr: linearadditive, compositional structurePCA, word2vec analogies
Negative (hyperbolic)2π sinh(√−K r)/√−K: exponentialtrees, taxonomiesthis lesson

Turn the curvature dial

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.

−1.00

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.

Order without curvature

MethodOrder ruleWorked 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.

A team uses cosine similarity and cannot express "this caption is more general than that one". Why?

Chapter 10

Field Guide

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 numberValue
Conformal factorλ = 2/(1 − ‖x‖2)
Distance from the centre2 artanh(r); map radius = tanh(s/2)
Circle length2π sinh s
Edge-length ruleℓ > ln b (0.69 for b = 2)
Riemannian rescale(1 − ‖θ‖2)2/4, projection to 1 − 10−5
WordNet closure82,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 constantK = 0.1, forbidden radius 0.099
MERURedCaps 12M pairs; matches or beats CLIP on 13 of 16 zero-shot datasets
Float ceilingsmax 17.3 (float32), 37.4 (float64)

Checklist before you go hyperbolic

  1. Is the relation an order (is-a, part-of, reports-to)?
  2. Is 2δ / diameter on sampled quadruples near 0?
  3. Is low dimension a real need (memory, serving cost, a device)?
  4. Can you search neighbours: by brute force, or with the Lorentz inner-product rewrite?
  5. Is depth times ln(branching) well under 17 for float32?
  6. Do you have a Euclidean baseline at the same dimension and budget?
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

Keep going

Sources

The takeaway. Pick the space whose room grows like your data. For a deep hierarchy at low dimension, that is hyperbolic space, read with true radii and stored with enough precision.
A colleague moved a 768-dimension sentence retriever to hyperbolic space: no gain, and ANN search stopped working. What do you tell them?

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.

Hyperbolic Embeddings
Poincaré Embeddings · Entailment Cones · Hyperbolic Neural Networks · MERU · Back to Gleams