Latent Space

A latent space is a space where position encodes meaning: an encoder turns content into a vector, similar things land near each other, and the graphics math you already have does the rest — similarity is a normalized dot product, and travel between meanings is interpolation.

Core Idea

The map above is a latent space in miniature: a space where position encodes meaning. Words that belong together sit together; the probe finds neighbors by nearness; traveling between two words passes through the meanings between. The map is a hand-placed toy — two dimensions, twenty-six words — but real systems do exactly this at scale: an embedding model turns a sentence, an image, or a document into a vector of hundreds or thousands of numbers, placed so that semantically similar content lands nearby. Everything you then do with those vectors is math this knowledge base already covers: relatedness is a dot product, travel is interpolation.

A Point That Means Something

An encoder (embedding model) maps content into the space. Feed it "the sea was calm tonight" and it returns a point — say 1,536 numbers. It is not generative; it creates nothing new. It measures: where, in the model’s learned geometry of meaning, does this input sit? The space is called latent — hidden — because nobody designed its axes. They emerge from training, and no single dimension means anything readable on its own. What is dependable is the geometry: distance and direction between points track similarity and relationship of meaning.

Two different jobs, two different machines:

Similarity Is a Dot Product

Relatedness between two embeddings is cosine similarity — the dot product, normalized so that length cancels and only direction counts:

cos θ = (a · b) / (|a| |b|)

Embedding vectors are usually stored pre-normalized to unit length, so in practice similarity is a plain dot product — one multiply-add per dimension, the same operation a fragment shader runs for Lambert lighting, just in 1,536 dimensions instead of 3. Because it’s this cheap, the standard pattern is to precompute the neighborhood: for every item, dot it against every other item once, keep the top matches with their scores, and ship that list (related: [{id, score}, …]) as plain data. At runtime, “what is this like?” becomes an array lookup.

Travel Is Interpolation

Since meanings are points, the path between two meanings is interpolation: lerp(a, b, t) sweeps through the blend region where a point is partly one thing, partly the other. In generative systems this is the classic morph — decode the midpoint between two face embeddings and get a plausible in-between face. In interactive work it means navigation is semantic: moving through the space is moving through meaning, and whatever sits near the path is genuinely related to it. (One honest footnote: on unit vectors the technically correct blend is spherical — slerp — since lerp cuts a chord through the sphere; for nearby points the difference is cosmetic.)

Layout Trick or Live Engine

Interactive projects use latent spaces at two very different depths — worth naming, because they look identical in a screenshot:

  1. Layout only. Embeddings position the content once, at build time — clusters emerge, related items sit together — and then the numbers are thrown away. At runtime it’s static geometry and a camera. The latent space was a layout algorithm that evaporated after export.
  2. Live association engine. The relationships stay in the build and are queried at runtime: where the visitor is (or dwells) surfaces the most-related content — connections light up that were never hand-authored, including between items that sit visually far apart, because meaning and screen distance aren’t the same thing. The space keeps doing work after load.

The live version can go one step further: embed the visitor’s input in the browser. A small embedding model running on WebGPU (via Transformers.js and similar runtimes) turns a typed phrase into a point in the same space at runtime — search becomes “fly to the nearest meaning” with no server round-trip.

A scale caveat belongs here: with a few dozen items, nearest-neighbor lists are trivial and could be hand-authored to identical effect. Embeddings earn their keep as the collection grows — hundreds or thousands of items — and by being derived from the content rather than curated by hand.

Connections

Embeddings are ordinary vectors — long ones — and every operation on them is graphics math promoted to more dimensions: cosine similarity is the normalized dot product that lights every Lambert surface; moving between meanings is the same interpolation that blends every animation; running an encoder client-side rides the compute story of WebGPU; and the decoder that turns a latent coordinate back into something visible can be a neural network — or just a well-written shader.