A Hubble Sky Full of Stars

Meaning as Geometry: What Embeddings Actually Are

This is part 1 of a series on building AI-powered systems in PHP — from first principles to a fully local, PHP-native stack.

Type “feeling overwhelmed by life” into a traditional search box and you’ll get documents containing the words feeling, overwhelmed, and life. You will not get the document about peace. Or stillness. Or rest. Even though those are exactly what you were looking for.

That’s the fundamental limitation of keyword search: it matches strings rather than meaning. For twenty years we’ve papered over this limitation with stemming, synonyms, fuzzy matching, and increasingly elaborate query DSLs. Embeddings make the whole pile of workarounds unnecessary.

Text becomes coordinates

An embedding model is a neural network that reads a piece of text and converts it to a list of numbers — typically somewhere between 384 and 4,096 of them. That list is a vector: a single point in a high-dimensional space.

The remarkable property is that the model is trained so that texts with similar meanings land near each other in that higher-dimensional space. “Overwhelmed by life” lands near “finding rest,” near “peace in the storm,” near “be still.” They don’t share words but meaning, and the model has learned to encode meaning as position.

Think of it as a map. On a map of the United States, Portland and Seattle are close together because they’re geographically similar. In embedding space, two sentences are close together because they’re semantically similar. The model is thus a cartographer for meaning.

Distance is similarity

Once text is a point in space, “how similar are these two texts?” becomes “how close together are these two points?” — a question we can answer with arithmetic. The standard measure is cosine similarity: the cosine of the angle between two vectors. Identical direction scores 1.0; unrelated content drifts toward 0.

That single move — reducing semantics to geometry — unlocks considerable functionality downstream:

  • Semantic search is “embed the query, find the nearest documents.”
  • Recommendations are “find documents near the ones the user already liked.”
  • Clustering and classification are “group points that are physically near each other.”
  • RAG (retrieval-augmented generation) is “find the nearest documents, then provide them to an LLM as context.”

None of these require the computer to understand anything at query time. The understanding is instead baked into the geometry when the embedding model is trained. At runtime, it’s just distance math — fast, deterministic, and remarkably cheap.

What the dimensions mean (and don’t)

A natural question: if a vector has 1,024 dimensions, what does dimension 417 represent? The honest answer is: nothing you can name. Individual dimensions aren’t “formality” or “sentiment” or “topic.” Meaning is smeared across all of them at once. What’s interpretable is the relationships between points. Closeness is the signal; coordinates themselves are an implementation detail.

This matters practically: vectors from different models live in different, fundamentally incompatible spaces. You cannot compare an embedding from one model against an embedding from another any more than you can use a map of Seattle to navigate Cleveland. Pick a model, then embed everything — documents and queries alike — with that model consistently.

You can run this on your own hardware

A few years ago, generating embeddings meant calling a cloud API. Today, open-weight embedding models like Qwen3-Embedding-0.6B produce excellent results and run comfortably on commodity hardware — including, as we’ll see later in this series, inside your PHP process:

<?php
use Displace\Infer\Model;

$model = Model::load('models/Qwen3-Embedding-0.6B-Q8_0.gguf');

$a = $model->embed('feeling overwhelmed by life');
$b = $model->embed('finding rest and peace');

echo $a->cosineSimilarity($b); // high

This isn’t Python or even PHP calling out to a Python sidecar. There’s no API for a cloud service. No text leaves your machine.

Where this series goes

Over the next several weeks we’ll build from these foundations to a complete, local, PHP-native AI stack: semantic search in Laravel, visualizing embedding spaces, three new PHP extensions for inference, vector search, and audio transcription, and finally a production case study where the embeddings revealed structure in a content archive that nobody told them to find.