Embedding Models in Practice
A model works with numbers, so its input must be converted into a numerical representation before it can be processed.
A Sentence a Machine Cannot Read Directly
Imagine a system that must answer questions about a sentence such as 'the cat sits on a mat'. To a person, that sentence is words with meaning. To the machine doing the work, it is a string of letters and spaces. The machine is built to handle numbers, so something has to bridge that gap before any reasoning can happen.
The idea that performs this bridging is called an embedding. Embeddings are one of the central ideas behind modern language and image models. In this article you will follow a single input step by step, see what the numbers look like, and learn which kinds of models produce them.
Why Models Need Numbers
A model cannot act on raw text in the way a person does, because the hardware and the arithmetic inside it operate on numbers. That is the starting constraint. Whatever a model receives, whether text or an image, must first be turned into a form the arithmetic can use.
This raises the central question: what kind of numbers are useful? Arbitrary numbers would not help. The numbers need to carry something about the original data forward into later computation. An embedding is the answer the field uses for this problem.
Tracing a Sentence Into Numbers
Follow the sentence from the moment it is submitted to the moment the model has something numerical to work with. The diagram below shows the sequence. The sentence enters as text, is converted into a numerical representation, takes the form of an embedding vector, and only then is passed to the model's computation.
The conversion is the step that makes the rest of the pipeline possible. Without it, the model would have nothing it could compute with. Notice that the original sentence and its embedding are not two different pieces of content. They carry the same underlying content, built for different consumers.
What an Embedding Captures
An embedding is a numerical representation of data that aims to capture the meaning of the original data. Formally, it is a vector: a fixed ordered collection of numbers.
The word 'aims' matters. An embedding is an attempt to encode meaning in numbers, not a guaranteed or complete copy of meaning. The numbers are useful precisely because they carry that encoded meaning forward into later computation. A model that receives a good embedding can use the numbers to reason about what the input represents, while the raw letters alone give it nothing numerical to combine.
Reading an Embedding as a Vector
Because an embedding is a vector, it can be written as an ordered list. The source illustrates this with the sentence 'the cat sits on a mat', which might be represented by the vector [0.11, 0.02, 0.54]. Each slot in that list is one element. The diagram below labels each position so you can see that the list is an indexed structure.
Reading the Example Embedding
Given the embedding [0.11, 0.02, 0.54] for the sentence 'the cat sits on a mat', how many elements does it have, and what is the value at the last position?
- 1Identify the separators
The list has three values separated by commas, so the vector is written with three slots.
- 2Count the elements
Each slot is one element. There are three elements: 0.11, 0.02, and 0.54.
- 3Locate the last position
The last slot holds 0.54. Position matters, so this value belongs to the final element of the list and not to any other slot.
- 4Compare with a reordering
If the same three numbers were written as [0.54, 0.02, 0.11], the list would be a different vector, even though the same numbers appear.
The embedding has 3 elements, and its last element is 0.54. The three numbers are only meaningful in their specific order.
What do you think happens?
If you rearrange the same three numbers in the vector, does the embedding stay the same?
Reveal answer
No, a different order gives a different vector
The position of an element in the list matters. Changing the order produces a different vector, even when the same numbers appear.
Embedding Size and Its Typical Range
The embedding size is the number of elements in the vector. It is typically between 100 and 10,000.
The three-element example used earlier is far below that range. It should be read as an illustration of structure, meaning what a vector is and how its slots are ordered, rather than as an illustration of scale. Real embeddings are much longer lists.
Embedding size is not one fixed value across the field. Different models produce embeddings of different sizes, and the source lists sizes for several common models, including BERT, CLIP, and the OpenAI Embeddings API. Some models list separate sizes for different variants, and some list separate sizes for image and text inputs. When you pick a model, its embedding size is one of the properties you must check in its documentation, because the choice of model determines the size and other properties of the vectors it outputs.
| Aspect | Original data | Embedding |
|---|---|---|
| Who it is built for | People reading text | A model that needs numbers to compute with |
| Form | Letters and spaces | An ordered list of numbers (a vector) |
| Underlying content | The original meaning | An encoding that aims to capture that meaning |
| Typical size | Not measured as a vector | Typically between 100 and 10,000 elements |
The same content in two forms, each built for a different consumer
Common mistake Judging an embedding model by the three-element example
What it looks likeAssuming a real embedding has only three numbers because the illustration used [0.11, 0.02, 0.54].
Why it failsThe example illustrates structure. The typical embedding size is between 100 and 10,000.
Do this insteadUse the example to understand that a vector is an ordered list, and check the actual size for the model you are using.
Common mistake Assuming all embedding models produce the same size
Why it failsEmbedding size varies across models, and some models list different sizes for variants or for image and text inputs.
Do this insteadLook up the embedding size for the specific model and variant you plan to use.
Common mistake Treating the numbers as unordered, so that reordering them seems harmless
Models That Produce Embeddings
An embedding is produced by a model, and some models are trained specifically to produce embeddings. Embedding models are a family rather than a single model. They fall into two broad groups: open-source models and proprietary models offered as APIs. The diagram below groups the named examples from the source.
The open-source group includes BERT, CLIP, and Sentence Transformers. CLIP stands for Contrastive Language-Image Pre-training, which signals that it works across language and images. The proprietary group is represented in the source by models provided as APIs, with the OpenAI Embeddings API as the named example. The distinction is about how the model is built and accessed, while both groups produce embeddings that the model's later computation can use.
Checking Your Understanding
A system receives the sentence 'the cat sits on a mat' and needs to answer questions about it. Explain, in your own words, what must happen before the model can reason about the sentence, and name one property of the resulting vector that you must check before using a particular model.
Hints
- Think about what the model's arithmetic operates on.
- Consider what an embedding is meant to capture, and what property the source says varies across models.
Two vectors contain the same three numbers, 0.11, 0.02, and 0.54. One is written as [0.11, 0.02, 0.54] and the other as [0.54, 0.02, 0.11]. Decide whether they are the same embedding and justify your answer using the idea that position in the list matters.
Hints
- Compare the position of each element in the two lists.
- The source states that changing the order produces a different vector.
Key Takeaways
- A model works with numbers, so raw input such as text must be converted into a numerical representation before it can be processed.
- An embedding is a vector, an ordered list of numbers, that aims to capture the meaning of the original data. Its elements are position-dependent, so reordering them changes the vector.
- Embedding size, the number of elements in the vector, is typically between 100 and 10,000 and varies across models, so each model's size must be checked.
- Embedding models are a family that includes open-source examples such as BERT, CLIP, and Sentence Transformers, and proprietary models provided as APIs such as the OpenAI Embeddings API.