intermediate embedding-geometry 38 min read

Normalization, the Hypersphere, and von Mises–Fisher Geometry

Why retrieval lives on the unit sphere, and the distribution that models a topical cluster on it

Overview & motivation

The previous topic left us with a paradox and its resolution: in Rd\mathbb{R}^d with dd in the hundreds or thousands, distances concentrate and random directions are nearly orthogonal, yet retrieval works because real embeddings live near a low-dimensional surface. This topic looks closely at the surface they actually live on. Almost every production embedding model ends its forward pass with an L2 normalization, and almost every vector index scores by cosine similarity, so the space we truly search is not all of Rd\mathbb{R}^d — it is the unit hypersphere Sd1={xRd:x=1}S^{d-1} = \{x \in \mathbb{R}^d : \lVert x\rVert = 1\}, where x=(i=1dxi2)1/2\lVert x \rVert = \bigl(\sum_{i=1}^d x_i^2\bigr)^{1/2} is the Euclidean norm. On that surface, cosine similarity is the geometry, and the question “how similar are two documents?” becomes a question about angles.

We will establish three things. First, that ranking by cosine similarity and ranking by Euclidean distance are, on the sphere, the same ranking — so a model can train against one and a retriever search by the other with no inconsistency. Second, that the uniform distribution on the sphere, the natural picture of “no information,” concentrates all of its mass near the equator of every axis, with a coordinate that has variance exactly 1/d1/d — the same 1/d1/d that made two random vectors nearly orthogonal one topic ago, now read as a probability law. Third, and at the center of the topic, that a topical cluster of embeddings — vectors that mean similar things and therefore point in similar directions — is modeled by the von Mises–Fisher distribution, the spherical cousin of the Gaussian, whose single concentration parameter κ\kappa turns out to be a measurable statement about how tight a cluster is.

Before the algebra, drag the sliders and watch the geometry. The dimension slider drives the uniform law; the concentration slider drives the von Mises–Fisher law:

−10+1
Projection t = ⟨u, v⟩ of a uniform random unit vector onto a fixed axis (faint curve: d = 2, the spread-out arcsine law). As d grows it spikes at the equator t = 0, with variance 1/d.
Var(t) at d = 100
0.00991
theory: 1/d
0.01000
mass within 0.1 of the equator
68.0%

Switch between the panels: the equatorial band shows the uniform coordinate piling up at zero as dd grows; the von Mises–Fisher panel shows the density’s peak sweeping out from the equator toward the mean direction as κ\kappa grows; the cosine-versus-distance panel shows the monotone line that makes the two rankings identical; and the last panel is the finance view — two topical clusters at d=1536d = 1536, one tight and one loose.

What we cover

  1. Normalization and the cosine–distance identity: why retrieval lives on the sphere.
  2. The uniform distribution on the sphere, the equatorial band, and the return of 1/d1/d.
  3. The von Mises–Fisher distribution and its Bessel-function normalizing constant.
  4. Why von Mises–Fisher is the maximum-entropy law on the sphere.
  5. Estimating a cluster: the maximum-likelihood mean direction and concentration.
  6. What κ\kappa buys retrieval, a finance case study, the honest caveats, and the tested code.

Why normalize: cosine similarity is the geometry of the sphere

A retriever receives raw encoder outputs, vectors of no particular length, and must turn them into comparable scores. The standard move is to divide each vector by its norm. We write the L2 normalization of a nonzero vector xx as x^=x/x\hat{x} = x / \lVert x\rVert, a point on Sd1S^{d-1}, and define the cosine similarity of two nonzero vectors as

cos(x,y)=x,yxy=x^,y^,\cos(x, y) = \frac{\langle x, y\rangle}{\lVert x\rVert\,\lVert y\rVert} = \langle \hat{x}, \hat{y}\rangle,

where x,y=i=1dxiyi\langle x, y\rangle = \sum_{i=1}^d x_i y_i is the inner product. Cosine similarity is therefore nothing but the inner product after projecting both vectors onto the sphere; normalization is that projection. The reason this is the right scoring geometry, rather than one convention among many, is a one-line identity.

Proposition 1 (Cosine similarity and distance induce the same ranking).

For unit vectors x,ySd1x, y \in S^{d-1} with angle θ\theta between them,

xy2=22x,y=2(1cosθ).\lVert x - y\rVert^2 = 2 - 2\langle x, y\rangle = 2\,(1 - \cos\theta).

Consequently, for a fixed query q^\hat{q} and any set of candidates, ordering them by decreasing cosine similarity q^,y^\langle \hat{q}, \hat{y}\rangle is identical to ordering them by increasing Euclidean distance q^y^\lVert \hat{q} - \hat{y}\rVert:

argmaxy q^,y^=argminy q^y^.\arg\max_{y}\ \langle \hat{q}, \hat{y}\rangle = \arg\min_{y}\ \lVert \hat{q} - \hat{y}\rVert.
Proof.

Expand the squared distance with the bilinearity of the inner product: xy2=xy,xy=x22x,y+y2\lVert x - y\rVert^2 = \langle x - y, x - y\rangle = \lVert x\rVert^2 - 2\langle x, y\rangle + \lVert y\rVert^2. For unit vectors x=y=1\lVert x\rVert = \lVert y\rVert = 1, so this is 22x,y2 - 2\langle x, y\rangle, and since x,y=cosθ\langle x, y\rangle = \cos\theta for unit vectors, it equals 2(1cosθ)2(1 - \cos\theta). The map t22tt \mapsto 2 - 2t is strictly decreasing, so it reverses order without changing it: the candidate with the largest cosine similarity is exactly the one with the smallest squared distance, and squaring preserves the order of nonnegative distances. \blacksquare

This is why a dense retriever may be trained with a cosine objective and then searched with a Euclidean index, or the reverse, with no contradiction: on the sphere the two scores are affine images of each other. It is also the reason the rest of the topic studies distributions of the inner product u,v\langle u, v\rangle rather than of distance — they carry the same information, and the inner product is the more convenient coordinate.


The uniform distribution on the sphere and the equatorial band

To understand what structure on the sphere looks like, we first need a picture of its absence. The natural model of “no preferred direction” is the uniform distribution on Sd1S^{d-1} — the rotationally invariant probability measure, which we can sample by drawing a standard Gaussian vector and normalizing it. Pick any axis uu and ask how a uniform random point projects onto it. The answer is the law that governs the entire sphere’s geometry.

Theorem 1 (The equatorial coordinate marginal).

Let vv be uniform on Sd1S^{d-1} with d2d \ge 2, and fix a unit vector uu. The projection t=u,vt = \langle u, v\rangle has probability density

p(t)=Γ ⁣(d2)πΓ ⁣(d12)(1t2)(d3)/2,t[1,1],p(t) = \frac{\Gamma\!\left(\tfrac{d}{2}\right)}{\sqrt{\pi}\,\Gamma\!\left(\tfrac{d-1}{2}\right)}\,\bigl(1 - t^2\bigr)^{(d-3)/2}, \qquad t \in [-1, 1],

with

E[t]=0,Var(t)=1d,E[t4]=3d(d+2).\mathbb{E}[t] = 0, \qquad \operatorname{Var}(t) = \frac{1}{d}, \qquad \mathbb{E}[t^4] = \frac{3}{d(d+2)}.

As dd grows, the mass concentrates at t=0t = 0: almost all of the sphere’s surface lies in a thin equatorial band around any great subsphere.

Proof.

The mean is zero because the uniform measure is symmetric under vvv \mapsto -v, which sends ttt \mapsto -t. For the variance, use the defining constraint of the sphere: every point satisfies i=1dvi2=1\sum_{i=1}^d v_i^2 = 1. Taking expectations, i=1dE[vi2]=1\sum_{i=1}^d \mathbb{E}[v_i^2] = 1, and by rotational symmetry every coordinate has the same second moment, so E[vi2]=1/d\mathbb{E}[v_i^2] = 1/d for each ii. Choosing u=e1u = e_1 (which we may, by rotating) gives t=v1t = v_1 and Var(t)=E[v12]=1/d\operatorname{Var}(t) = \mathbb{E}[v_1^2] = 1/d. The density itself comes from slicing the sphere at height tt: the set {v:u,v=t}\{v : \langle u, v\rangle = t\} is a sphere of one lower dimension and radius 1t2\sqrt{1 - t^2}, whose surface area scales as (1t2)(d2)/2(1 - t^2)^{(d-2)/2}, and the spherical change of variables contributes a further factor of (1t2)1/2(1 - t^2)^{-1/2} from the arc-length element, leaving (1t2)(d3)/2(1 - t^2)^{(d-3)/2}; the Gamma-function prefactor is the constant that integrates this to one, which we cite to the standard computation (Blum, Hopcroft, and Kannan, 2020). The fourth moment follows because t2Beta(12,d12)t^2 \sim \mathrm{Beta}(\tfrac12, \tfrac{d-1}{2}), whose moments give E[t4]=3/(d(d+2))\mathbb{E}[t^4] = 3/(d(d+2)); the companion code matches both moments to the grid. \blacksquare

The variance 1/d1/d is not a coincidence and not a new fact. It is exactly the variance of u,v\langle u, v\rangle we computed for two random directions in high-dimensional geometry — there read as a statement about a random pair, here read as the density of a single coordinate. The two statements are the same near-orthogonality, and they have the same consequence: as dd \to \infty the projection onto any axis collapses to zero, so a uniformly random embedding is nearly perpendicular to every fixed direction, and the surface area piles up in the equatorial band {tε}\{|t| \le \varepsilon\}. The laboratory’s first panel shows the band filling in: by d=100d = 100 roughly two-thirds of the sphere lies within 0.10.1 of the equator, and by d=1536d = 1536 essentially all of it does. This is the backdrop against which a concentrated distribution — one that resists the pull to the equator and clusters around a direction — will stand out.


The von Mises–Fisher distribution

Document embeddings are not uniform. Passages about interest-rate risk point in similar directions; passages about supply-chain disruption point in a different cluster of directions. The distribution that models a cluster on the sphere — a “bump” of probability concentrated around a mean direction — is the von Mises–Fisher (vMF) distribution, the spherical analog of an isotropic Gaussian.

Definition 1 (The von Mises–Fisher distribution).

For a mean direction μSd1\mu \in S^{d-1} and a concentration κ0\kappa \ge 0, the von Mises–Fisher density on Sd1S^{d-1}, with respect to the uniform surface measure, is

f(x;μ,κ)=Cd(κ)exp ⁣(κμx),xSd1,f(x;\, \mu, \kappa) = C_d(\kappa)\,\exp\!\bigl(\kappa\,\mu^{\top} x\bigr), \qquad x \in S^{d-1},

where the normalizing constant is

Cd(κ)=κd/21(2π)d/2Id/21(κ),C_d(\kappa) = \frac{\kappa^{\,d/2 - 1}}{(2\pi)^{d/2}\, I_{d/2 - 1}(\kappa)},

and IνI_\nu is the modified Bessel function of the first kind of order ν\nu. At κ=0\kappa = 0 the density is constant — the uniform distribution — and as κ\kappa \to \infty it collapses to a point mass at μ\mu.

The exponent κμx=κcosθ\kappa\,\mu^{\top}x = \kappa\cos\theta rewards alignment with μ\mu: points near the mean direction are exponentially more likely than points near the equator μx=0\mu^{\top}x = 0. The only thing standing between this clean form and a usable distribution is the constant Cd(κ)C_d(\kappa), and where it comes from is the heart of the topic.

Theorem 2 (The normalizing constant is a Bessel function).

The constant Cd(κ)C_d(\kappa) of Definition 1 is the unique value making ff integrate to one over Sd1S^{d-1}, and it is a modified Bessel function because the normalizing integral reduces to the equatorial slice of Theorem 1:

Sd1exp ⁣(κμx)dS(x)=Sd1 ⁣11eκtp(t)dt    11eκt(1t2)(d3)/2dt,\int_{S^{d-1}} \exp\!\bigl(\kappa\,\mu^{\top}x\bigr)\,dS(x) = S_{d-1}\!\int_{-1}^{1} e^{\kappa t}\,p(t)\,dt \;\propto\; \int_{-1}^{1} e^{\kappa t}\,\bigl(1 - t^2\bigr)^{(d-3)/2}\,dt,

where Sd1S_{d-1} is the surface area of the sphere. The right-hand integral is, up to the Gamma-function prefactors, the integral representation of Id/21(κ)I_{d/2 - 1}(\kappa).

Proof.

The integrand exp(κμx)\exp(\kappa\,\mu^{\top}x) depends on xx only through the single coordinate t=μxt = \mu^{\top}x. Integrating any such function over the sphere is exactly an expectation of eκte^{\kappa t} under the uniform measure, scaled by the total surface area Sd1S_{d-1}: this is the surface integral sliced along μ\mu, with the slice density p(t)(1t2)(d3)/2p(t) \propto (1 - t^2)^{(d-3)/2} supplied by Theorem 1. So the normalizing integral is a constant times 11eκt(1t2)(d3)/2dt\int_{-1}^{1} e^{\kappa t}(1 - t^2)^{(d-3)/2}\,dt. We now cite the standard integral representation of the modified Bessel function,

Iν(κ)=(κ/2)νπΓ ⁣(ν+12)11eκt(1t2)ν1/2dt,I_\nu(\kappa) = \frac{(\kappa/2)^\nu}{\sqrt{\pi}\,\Gamma\!\left(\nu + \tfrac12\right)} \int_{-1}^{1} e^{\kappa t}\,\bigl(1 - t^2\bigr)^{\nu - 1/2}\,dt,

valid for ν=d/21\nu = d/2 - 1, where ν12=(d3)/2\nu - \tfrac12 = (d-3)/2 matches our exponent exactly (Mardia and Jupp, 2000). Substituting the surface area Sd1=2πd/2/Γ(d/2)S_{d-1} = 2\pi^{d/2}/\Gamma(d/2) and the slice prefactor and solving for the reciprocal of the integral yields Cd(κ)=κd/21/((2π)d/2Id/21(κ))C_d(\kappa) = \kappa^{d/2-1} / \bigl((2\pi)^{d/2} I_{d/2-1}(\kappa)\bigr), as claimed. The companion code verifies, by direct numerical quadrature of the one-dimensional integral, that this Cd(κ)C_d(\kappa) integrates the density to one across a range of dd and κ\kappa. \blacksquare

The lesson is worth stating plainly: the von Mises–Fisher normalizer is a Bessel function not by analytical accident but because the sphere concentrates on its equator. The same (1t2)(d3)/2(1 - t^2)^{(d-3)/2} slice that emptied the uniform distribution onto the equator is the kernel of the Bessel integral. Concentration of measure and the special function are two faces of one computation. From the normalizer we read off the most useful summary of a cluster.

Proposition 2 (Mean resultant length).

If xvMF(μ,κ)x \sim \mathrm{vMF}(\mu, \kappa), then its expectation points along the mean direction with magnitude

E[x]=Ad(κ)μ,Ad(κ)=Id/2(κ)Id/21(κ)[0,1).\mathbb{E}[x] = A_d(\kappa)\,\mu, \qquad A_d(\kappa) = \frac{I_{d/2}(\kappa)}{I_{d/2 - 1}(\kappa)} \in [0, 1).

The scalar ρ=Ad(κ)=E[x]\rho = A_d(\kappa) = \lVert \mathbb{E}[x]\rVert is the mean resultant length. It is strictly increasing in κ\kappa, with Ad(0)=0A_d(0) = 0 (uniform, no preferred direction) and Ad(κ)1A_d(\kappa) \to 1 as κ\kappa \to \infty (a point mass).

Proof.

By symmetry E[x]\mathbb{E}[x] can only point along μ\mu, so E[x]=(E[μx])μ\mathbb{E}[x] = (\mathbb{E}[\mu^{\top}x])\,\mu. The vMF density is an exponential family with natural parameter η=κμ\eta = \kappa\mu and sufficient statistic xx, whose log-normalizer is logCd(κ)-\log C_d(\kappa); the standard identity that the mean of the sufficient statistic equals the gradient of the log-normalizer gives E[μx]=ddκ(logCd(κ))\mathbb{E}[\mu^{\top}x] = \tfrac{d}{d\kappa}\bigl(-\log C_d(\kappa)\bigr). Differentiating logCd(κ)-\log C_d(\kappa) and using the Bessel recurrence Iν(κ)=Iν1(κ)(ν/κ)Iν(κ)I_\nu'(\kappa) = I_{\nu-1}(\kappa) - (\nu/\kappa) I_\nu(\kappa) collapses the derivative to the ratio Id/2(κ)/Id/21(κ)=Ad(κ)I_{d/2}(\kappa)/I_{d/2-1}(\kappa) = A_d(\kappa). That this ratio increases from 00 to 11 is a standard monotonicity of Bessel-function ratios; the companion code computes it for arbitrary dd by the continued fraction Ad(κ)=1/(2(d/2)/κ+1/(2(d/2+1)/κ+))A_d(\kappa) = 1/\bigl(2(d/2)/\kappa + 1/(2(d/2+1)/\kappa + \cdots)\bigr), which is stable even at d=1536d = 1536 where Iν(κ)I_\nu(\kappa) itself overflows. \blacksquare

The mean resultant length is the bridge between the parameter κ\kappa, which we cannot observe, and the data, which we can: ρ\rho is just the length of the average of the unit vectors in a cluster. A loose cluster has vectors pointing every which way, their average is short, and ρ\rho is near 00; a tight cluster has nearly-aligned vectors whose average is almost a unit vector, and ρ\rho is near 11. The vMF panel of the laboratory marks ρ\rho as the location the density’s peak sweeps toward as you raise κ\kappa.


von Mises–Fisher is the maximum-entropy law on the sphere

We have called vMF “the natural” distribution on the sphere, but naturalness should be earned, not asserted. The justification is a maximum-entropy characterization: among all distributions with a given mean direction, vMF is the one that assumes the least beyond it.

Theorem 3 (Maximum entropy on the sphere).

Fix a target mean m=Ad(κ)μm = A_d(\kappa)\mu with m<1\lVert m\rVert < 1. Among all probability densities pp on Sd1S^{d-1} with Ep[x]=m\mathbb{E}_p[x] = m, the differential entropy H(p)=Sd1plogpdSH(p) = -\int_{S^{d-1}} p \log p\, dS is maximized uniquely by the von Mises–Fisher density q=vMF(μ,κ)q = \mathrm{vMF}(\mu, \kappa) whose mean is mm.

Proof.

Let q=vMF(μ,κ)q = \mathrm{vMF}(\mu, \kappa), so logq(x)=logCd(κ)+κμx\log q(x) = \log C_d(\kappa) + \kappa\,\mu^{\top}x, and let pp be any density on the sphere with the same mean Ep[x]=m=Eq[x]\mathbb{E}_p[x] = m = \mathbb{E}_q[x]. The relative entropy is nonnegative:

0KL(pq)=plogpplogq=H(p)p(logCd(κ)+κμx)dS.0 \le \mathrm{KL}(p \,\Vert\, q) = \int p \log p - \int p \log q = -H(p) - \int p\,\bigl(\log C_d(\kappa) + \kappa\,\mu^{\top}x\bigr)\,dS.

The integral on the right is logCd(κ)+κμEp[x]=logCd(κ)+κμm\log C_d(\kappa) + \kappa\,\mu^{\top}\mathbb{E}_p[x] = \log C_d(\kappa) + \kappa\,\mu^{\top}m, which depends on pp only through its mean — and the mean is fixed to mm. The identical computation for qq in place of pp gives qlogq=logCd(κ)+κμm=H(q)\int q \log q = \log C_d(\kappa) + \kappa\,\mu^{\top}m = -H(q), because qq has the same mean. Substituting, 0KL(pq)=H(p)+H(q)0 \le \mathrm{KL}(p\,\Vert\,q) = -H(p) + H(q), that is H(p)H(q)H(p) \le H(q), with equality if and only if p=qp = q almost everywhere. So qq is the unique entropy maximizer. The existence of a concentration κ\kappa realizing any achievable mean mm — that Ad(κ)A_d(\kappa) ranges over all of [0,1)[0,1) — follows from the monotonicity of Proposition 2; we cite the convexity of the log-normalizer for the general guarantee that the matching multiplier is unique (the exponential-family correspondence between mean and natural parameter). \blacksquare

The argument is the spherical instance of a pattern that recurs across the series: fix the moments you are willing to commit to — here, a mean direction — and the maximum-entropy distribution with those moments is the exponential family whose sufficient statistic is exactly those moments. On the line with a fixed mean and variance it is the Gaussian; on the sphere with a fixed mean direction it is von Mises–Fisher. Calling vMF “natural” means precisely this: it is the least-committed model of a cluster that has a center.


Estimating the cluster: maximum likelihood for the mean direction and concentration

A model earns its place only if we can fit it to data. Given embeddings x1,,xnx_1, \dots, x_n believed to form a topical cluster, the maximum-likelihood estimates of μ\mu and κ\kappa are clean for the direction and implicit for the concentration.

Theorem 4 (Maximum-likelihood estimates).

Let x1,,xnx_1, \dots, x_n be i.i.d. vMF(μ,κ)\mathrm{vMF}(\mu, \kappa) samples, write the resultant vector R=i=1nxiR = \sum_{i=1}^n x_i, and let rˉ=R/n\bar{r} = \lVert R\rVert / n be the mean resultant length of the sample. The maximum-likelihood estimates are

μ^=RR,Ad(κ^)=rˉ.\hat{\mu} = \frac{R}{\lVert R\rVert}, \qquad A_d(\hat{\kappa}) = \bar{r}.

The concentration estimate solves an implicit Bessel-ratio equation; the Banerjee, Dhillon, Ghosh, and Sra (2005) closed form approximates it as

κ^rˉ(drˉ2)1rˉ2.\hat{\kappa} \approx \frac{\bar{r}\,(d - \bar{r}^2)}{1 - \bar{r}^2}.
Proof.

The log-likelihood is (μ,κ)=nlogCd(κ)+κμR\ell(\mu, \kappa) = n \log C_d(\kappa) + \kappa\,\mu^{\top}R, subject to μ=1\lVert\mu\rVert = 1. For fixed κ>0\kappa > 0, only the term κμR\kappa\,\mu^{\top}R depends on μ\mu, and by the Cauchy–Schwarz inequality μRμR=R\mu^{\top}R \le \lVert\mu\rVert\,\lVert R\rVert = \lVert R\rVert with equality exactly when μ\mu aligns with RR, so μ^=R/R\hat{\mu} = R/\lVert R\rVert. Substituting μ^\hat\mu gives μR=R\mu^{\top}R = \lVert R\rVert, so \ell as a function of κ\kappa is nlogCd(κ)+κRn\log C_d(\kappa) + \kappa\lVert R\rVert. Differentiating and using ddκlogCd(κ)=Ad(κ)\tfrac{d}{d\kappa}\log C_d(\kappa) = -A_d(\kappa) from Proposition 2,

κ=nAd(κ)+R=0    Ad(κ^)=Rn=rˉ.\frac{\partial \ell}{\partial \kappa} = -n\,A_d(\kappa) + \lVert R\rVert = 0 \;\Longrightarrow\; A_d(\hat\kappa) = \frac{\lVert R\rVert}{n} = \bar{r}.

This is the maximum-likelihood moment-matching equation: the model’s mean resultant must equal the sample’s. It has no elementary closed-form solution because AdA_d is a ratio of Bessel functions; the Banerjee et al. (2005) formula is an approximation to its root, obtained by a Taylor analysis of AdA_d, and we present it as such. The companion code solves the equation exactly by a one-dimensional root-find and reports the approximation’s relative error against that exact root — under 1.6%1.6\% across the grid of κ\kappa values the laboratory displays. \blacksquare

The estimator closes the loop. The mean resultant length rˉ\bar{r} is a number we compute directly from a cluster of embeddings — average them, take the length — and κ^\hat{\kappa} turns that number into the concentration parameter, a single scalar that says how tight the cluster is. The next section is about what that scalar buys.


What concentration buys retrieval

Three consequences make this geometry more than a formal exercise. The first is that cluster tightness becomes measurable. A corpus subtopic — every passage your encoder maps about one theme — is, to a first approximation, a vMF cluster, and its κ^\hat{\kappa} (equivalently rˉ\bar{r}) quantifies how confidently a retriever can separate that theme from its neighbors. A high-κ\kappa cluster is a crisp query target; a low-κ\kappa cluster is a diffuse one whose members are easily confused with the background, a diagnosable property rather than a vague intuition.

The second is the link to how these embeddings are trained. Contrastive objectives such as InfoNCE operate on L2-normalized vectors and pull positive pairs together while pushing negatives apart on the sphere; the temperature parameter that scales their similarity logits plays the role of an inverse concentration, τ1/κ\tau \sim 1/\kappa, so lowering the temperature trains tighter clusters in exactly the sense Proposition 2 makes precise. Wang and Isola (2020) analyze contrastive learning directly as a competition between alignment (positives concentrated, high κ\kappa) and uniformity (the whole embedding set spread toward the uniform sphere of Theorem 1). The same geometry surfaces downstream: late-interaction retrieval scores normalized token embeddings by cosine, and score-aware quantization later in the curriculum exploits that the error which matters is the component along the query direction on the sphere — the μ\mu-aligned geometry vMF makes explicit.

The third consequence is a warning, and it is the subject of the caveats. The whole clean picture assumes a cluster is isotropic around its mean direction — equally spread in every tangent direction. Real embeddings are not. Contextual representations are anisotropic and occupy a narrow cone rather than spreading over the sphere (Ethayarajh, 2019), and multimodal encoders place text and images in two displaced cones — the modality gap (Liang et al., 2022). On such data the vMF fit is misspecified and κ^\hat{\kappa} is biased; the geometry is exact, but its fit to learned embeddings is an empirical question.


Finance case study

A candid note on the companion code, in the spirit of the rest of the series: the clusters are synthetic vMF draws, sampled by Wood’s (1994) algorithm so the notebook is deterministic, CPU-only, and reproducible to the decimal with no model download. They are not the output of a trained encoder, and as the caveats spell out, a real encoder’s clusters are anisotropic in ways a single κ\kappa cannot capture. The mathematics being illustrated — that a cluster’s tightness is a measurable mean resultant length, and that distinct subtopics occupy separable cones on the sphere — does not depend on how the clusters are produced.


Honest caveats


Implementation

The companion notebook (notebookPath) is self-contained, CPU-only, and runs in about a second on numpy and scipy. It samples the uniform sphere and the von Mises–Fisher distribution (the latter by Wood’s 1994 rejection sampler), computes the coordinate marginal and its moments, the normalizing constant by numerical quadrature, the mean resultant length by a continued fraction stable at embedding dimensions, and the maximum-likelihood estimators, and prints the grid table that the HypersphereLaboratory mirrors to the decimal. Its verification harness makes each claim of the topic executable: the cosine–distance identity holds to machine precision and the two rankings coincide (Proposition 1); the coordinate variance matches 1/d1/d and the fourth moment matches 3/(d(d+2))3/(d(d+2)), with the equatorial band filling to 99.99%99.99\% at d=1536d = 1536 (Theorem 1); the sampler produces unit vectors whose mean direction is μ\mu and the closed-form Cd(κ)C_d(\kappa) integrates the density to one (Theorem 2); the mean resultant length matches E[x]\lVert\mathbb{E}[x]\rVert across a κ\kappa-grid and stays finite at d=1536d = 1536 (Proposition 2); the von Mises law beats same-mean competitors in entropy on the circle (Theorem 3); the mean-direction estimator recovers μ\mu, the exact root inverts Ad(κ^)=rˉA_d(\hat\kappa) = \bar{r}, and the Banerjee approximation stays within 1.6%1.6\% of it (Theorem 4); and the tight finance cluster shows a higher mean resultant, a higher recovered κ^\hat\kappa, and cleaner separation than the loose one (the finance case). The three pillars — the proofs above, the laboratory, and the tested code — agree by construction.

Connections

  • the retrieval score is a similarity functional on embedding vectors; once we normalize, that functional is cosine similarity, and this topic establishes exactly what cosine measures and why ranking by it is ranking by distance on the sphere the-retrieval-problem
  • ColBERT's MaxSim sums cosine similarities of L2-normalized token embeddings, so late interaction scores live in this same spherical geometry, and the concentration of a token's vMF cluster bounds what MaxSim can resolve late-interaction-learned-sparse

References & Further Reading