Embedding

An embedding is a fixed-length list of numbers that represents a piece of text, image, or other input, produced by a model trained so that inputs with similar meanings end up near one another in the resulting space.

The list is called a vector, and its length is the model’s dimensionality — commonly a few hundred to a few thousand numbers, depending on the model. Every input passed through a given embedding model produces a vector of exactly the same length, whether the input was one word or a thousand.

The numbers individually mean nothing. No single position corresponds to a readable property like “is about finance” or “is a question.” Meaning is distributed across all of them, which is why an embedding cannot be inspected or edited by hand, and why the only useful operation on a pair of embeddings is comparing them.

What makes them useful is that the geometry is meaningful. Two texts phrased differently but saying similar things — “the delivery hasn’t arrived” and “my package is late” — produce vectors close together, despite sharing almost no words. That property is what lets a retrieval system match a user’s phrasing against a document’s phrasing without either having to guess the other’s vocabulary.

The word is also used for the process: to embed a document is to produce its embedding.

In practice

A retrieval pipeline embeds text twice, in two different phases.

At indexing time, every chunk of the corpus is passed through the embedding model and the resulting vectors are stored in a vector index alongside references to the original text. For a large corpus this is a batch job, and it must be repeated whenever the corpus changes or the embedding model is swapped.

At query time, the user’s question is passed through the same model, producing one vector, which is compared against the stored ones to find the nearest.

The word “same” is load-bearing. Vectors from different embedding models are not comparable — not merely less accurate but meaningless together, because each model organises its space independently. Changing embedding models therefore requires re-embedding the entire corpus, which is why the choice is treated as semi-permanent.

Embeddings are cheap to produce relative to text generation, commonly by one to two orders of magnitude per token, and typically fast enough that query embedding is a minor part of a request’s latency.

Commonly confused with

Vector. A vector is any list of numbers. An embedding is a vector produced by a model to represent something. All embeddings are vectors; most vectors are not embeddings. In casual usage the words are swapped freely, and in a RAG context the swap is usually harmless.

Encoding. Broader and more general — any transformation of data into another representation, including lossless ones like UTF-8 or base64. Embedding specifically means a learned, dense, lossy representation in a continuous space. An embedding cannot be reversed to recover the original text.

Token. A token is a unit of text as the model chunks it for processing — a word or word-fragment. Tokens are inputs to the model; an embedding is the output. A 500-token passage produces one embedding vector, not 500. (Internally the model does compute per-token representations, which it pools into the single output vector — a detail that occasionally leaks into documentation and causes confusion.)

Semantic search. The application, not the artefact. Semantic search is the technique of searching by meaning; embeddings are the mechanism that usually implements it.

Usage notes

“Embedding” also has a broader machine-learning meaning — any learned dense representation of discrete items, including word embeddings, user embeddings in a recommender, or node embeddings in a graph. In RAG contexts it almost always means a text embedding from a sentence- or passage-level model, but the general sense turns up in adjacent literature.

Dimensionality is not a quality ranking. A 3,072-dimension model is not necessarily better than a 768-dimension one; higher dimensionality costs more storage and slightly more search time. Some models support truncation to a shorter prefix of the vector at reduced accuracy, which makes the dimension count a tunable rather than a fixed property.

Model versions matter as much as model families. Two versions of the same named model can produce incompatible spaces. Recording which exact model and version produced an index is ordinary hygiene and frequently skipped.

Distance and similarity are separate choices. An embedding does not come with a comparison method attached; cosine similarity, dot product, and Euclidean distance are all used, and the appropriate one depends on whether the model normalises its output.

See also

Chunk · Vector index · Reranking