OSS4AI AI Stack · Season1 · #10
by Yujian Tang

An illustrated introduction to Embeddings. Treat the headline as a topic introduction, not a universal performance or capability claim. Open full-size image
What an embedding represents
An embedding turns an item into a numerical vector: a list of numbers that a model has learned to produce. The item might be a token, sentence or document passage. Some embedding systems also work with images and other inputs, but the representation depends on the model and training objective.
For text retrieval, the useful idea is that relevant or semantically similar items should receive vectors that compare well. This is often drawn as a map of meaning. A two-dimensional map is an illustration, though: real vectors commonly contain hundreds of coordinates, and individual coordinates need not have a simple human-readable label.
Token embeddings and text embeddings are different jobs
Inside a language model, a token ID selects a learned vector. That vector is an input to later layers, which combine it with surrounding context. A token embedding is not automatically a useful representation of an entire document.
A text embedding model instead produces a representation for a sentence or passage that you can compare with other representations. The all-MiniLM-L6-v2 model card describes mapping sentences and paragraphs into a 384-dimensional dense vector space.
A vector database stores and searches these passage-level representations. An embedding model is not a small chatbot in this role: its output is a vector for comparison, not a written answer. Generation and embedding are different operations even when they belong in the same application.

A low-dimensional drawing illustrates related meanings appearing near one another in an embedding space. Open full-size image
Compare directions with cosine similarity
Cosine similarity compares the directions of two nonzero vectors. A value of 1 means the same direction; 0 means orthogonal directions. The mathematical range is -1 to 1. A score of 0 is not a universal semantic definition of "unrelated," and a high score is not a probability that two passages say the same thing.
Consider these invented teaching vectors:
cat =
[0.9, 0.8, 0.1]dog =
[0.8, 0.9, 0.2]car =
[0.1, 0.2, 0.95]
The cat-dog cosine is about 0.99; cat-car is about 0.29. These values were chosen to demonstrate the calculation. They are not outputs from an embedding model, and they do not establish a general similarity threshold.
The practical lesson is comparative: a search system ranks candidates according to a metric. Whether the first candidate answers the question is a separate test.
From word vectors to retrieval
The word2vec work by Mikolov and colleagues helped popularize learned word representations. Vector arithmetic can be used to investigate relationships in a learned space, but the result depends on the model and data. It is not a guarantee that arbitrary vector operations produce reliable factual reasoning.
Sentence and passage embeddings extend the representation idea to useful retrieval units. In a RAG pipeline, you embed document chunks, embed the query using a compatible method, and search for candidates. The retrieved text then becomes evidence for a generating model.
The retrieved vector is not itself the evidence. The actual passage, its origin and its applicability to the question still matter.

Invented cat/dog/car vectors give cosines about0.99 and0.29 to illustrate ranking. Open full-size image
Choose before building the index
Choose an embedding model against the language, document types and questions your application will encounter. Prepare representative queries and identify passages that should answer them. Inspect whether those passages appear near the top of the retrieved results.
Keep the document and query representations compatible. Vectors from unrelated embedding models do not necessarily occupy the same space, even if they have the same number of dimensions. Changing models generally requires re-embedding the collection and rebuilding or updating the index.
This makes model selection an early infrastructure decision, not merely a setting you can swap without migration work.
Similarity has limits
Semantically close passages can disagree, omit key details or be out of date. Names, exact identifiers and specialized terminology may require additional retrieval methods. A relevant-looking result can still be unsuitable evidence.
Evaluate retrieval and answer quality separately. Embeddings help find material worth considering; they do not decide what is true. A reliable application retains the text and source metadata alongside the vectors, then checks whether the retrieved material supports the final response.

Token lookup vectors and single-vector text-retrieval embeddings serve different roles. Open full-size image
Sources and scope
Research date: November 9, 2026. Historical results refer to the dates and conditions of the cited studies; product details describe the cited source snapshot, not a promise of current availability or pricing.
