Hyperbolic Embeddings
Hierarchies explode exponentially: ten branches per level means a thousand leaves by level three. Hyperbolic space grows exponentially too, so trees fit in few dimensions where flat space crams them.
Why Does This Exist?
Flat embeddings fight hierarchies. A visual taxonomy — animal to dog to husky — branches multiplicatively, but Euclidean volume grows only polynomially with radius. Cramming an exponentially growing tree into flat space forces distant cousins together and stretches siblings apart; the distortion shows up as confused fine-grained classes. Adding dimensions postpones the problem without fixing its shape.
Hyperbolic space matches the shape. Its volume grows exponentially with radius, the same rate trees grow, so a hierarchy embeds with little distortion in two dimensions where flat space needs dozens. Vision taxonomies (species, products, scenes) are the natural tenants. The flat-space neighbor is metric learning; the curved-surface sibling is manifold learning.
The one idea you need first. The Poincaré ball pictures hyperbolic space as the inside of a disk where distances blow up toward the edge: walking near the boundary covers enormous ground per step. Place the hierarchy's root at the center and leaves near the rim. Siblings under one parent sit near each other along the rim, while different branches separate by vast boundary distances — exactly the tree metric, drawn to scale.
Think of It Like This
Escher's Circle Limit
Look at Escher's Circle Limit woodcuts: angels and devils tile a disk, large at the center, shrinking toward the rim, yet every tile is the same size in the print's own geometry. Infinitely many fit because the rim is infinitely far away on the inside.
Hyperbolic embeddings hang image categories on that tiling. Coarse concepts (animal) sit center stage; fine ones (Siberian husky) live near the rim with room for thousands of siblings. The disk looks small from outside and is enormous from inside, which is precisely why a whole taxonomy fits in two dimensions.
The analogy stops at the artwork: no angels are harmed, and the embedding is learned by gradient descent, not carved by a master.
How It Actually Works
Embed each image or label as a point in the Poincaré ball. Distance follows the hyperbolic formula, which behaves Euclidean near the center and explodes toward the boundary. Training uses contrastive or entailment losses rewritten with that distance: pull same-branch items together, push different branches apart along the rim. Classification reads off the nearest prototype; hierarchy depth reads off the radius (deeper means further out).
The Poincaré distance between points and is:
The denominator shrinks as either point nears the boundary (), inflating the distance — that inflation is the exponential room.
Worked example
Take and in the unit disk. Squared norms: . Difference: . Plug in:
Then . Since and , this is .
Euclidean distance says ; hyperbolic distance says . Two points halfway to opposite rims are already far apart — the boundary pushes everything away from everything, which is the room hierarchies rent.
Code
The point of this snippet is the distance law: a few lines reproduce the worked example and show the boundary inflation directly.
import math
def poincare_distance(u: list, v: list) -> float: norm_u = sum(a * a for a in u) # squared norms toward the boundary norm_v = sum(b * b for b in v) diff = sum((a - b) ** 2 for a, b in zip(u, v)) arg = 1.0 + 2.0 * diff / ((1.0 - norm_u) * (1.0 - norm_v)) return math.log(arg + math.sqrt(arg * arg - 1.0)) # arcosh via log
print(round(poincare_distance([0.5, 0.0], [-0.5, 0.0]), 3)) # -> 2.197print(round(poincare_distance([0.1, 0.0], [-0.1, 0.0]), 3)) # -> 0.403Near the center ( apart Euclidean) the distance is , close to flat. Near the rim the same Euclidean gap inflates to : position, not just separation, sets the scale.
Watch Out For
Optimization blows up at the boundary
Gradients of the hyperbolic distance grow steep near the rim, exactly where the leaves live. Naive Euclidean optimizers overshoot, fling points out of the ball, and produce NaNs that look like a data bug rather than a geometry bug.
Use Riemannian optimizers (or clip norms safely below and warm up with small learning rates). If training destabilizes late — when points drift outward — suspect the boundary before suspecting the data.
Not every hierarchy is a tree
Hyperbolic space fits trees beautifully and DAGs poorly: categories with two parents (a husky is a dog and a working animal) have no single clean address. Forcing tangled ontologies into a tree metric distorts the cross-links the task may need most.
Check the hierarchy's shape first. Mostly-tree taxonomies (species, product catalogs) gain; multiply-inherited label graphs often do better with flat or box embeddings that admit overlap.
The Quick Version
- Hyperbolic space grows exponentially with radius, matching how hierarchies branch.
- The Poincaré ball puts coarse concepts at the center and fine leaves near the rim.
- The worked fixture gives hyperbolic distance for a Euclidean gap of near the rim.
- Train with hyperbolic contrastive or entailment losses; read depth off the radius.
- Optimize on the manifold, not with naive Euclidean steps, or boundary gradients explode.
- Tangled multi-parent ontologies fit poorly; mostly-tree taxonomies gain most.