Concepts / Embedding Models in Practice

Embedding Models in Practice

A model works with numbers, so its input must be converted into a numerical representation before it can be processed.

  • Programming

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.

Sentence submittedthe cat sits on a matConverted to numbersnumerical representationEmbedding vectorordered list of numbersModel computesworks on the numbersencodedbecomespassed to
What happens to the sentence 'the cat sits on a mat' between submission and the point where the model receives numbers it can work with?

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

Definition

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.

Element at position 00.11Element at position 10.02Element at position 20.54
What does each position in the vector stand for, and what value sits in each slot?
Worked example

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?

  1. 1
    Identify the separators

    The list has three values separated by commas, so the vector is written with three slots.

  2. 2
    Count the elements

    Each slot is one element. There are three elements: 0.11, 0.02, and 0.54.

  3. 3
    Locate 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.

  4. 4
    Compare 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.

Result

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?

  • Yes, the same numbers means the same vector

  • No, a different order gives a different vector

Reveal answer
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

Definition

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.

AspectOriginal dataEmbedding
Who it is built forPeople reading textA model that needs numbers to compute with
FormLetters and spacesAn ordered list of numbers (a vector)
Underlying contentThe original meaningAn encoding that aims to capture that meaning
Typical sizeNot measured as a vectorTypically 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 like

    Assuming a real embedding has only three numbers because the illustration used [0.11, 0.02, 0.54].

    Why it fails

    The example illustrates structure. The typical embedding size is between 100 and 10,000.

    Do this instead

    Use 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 fails

    Embedding size varies across models, and some models list different sizes for variants or for image and text inputs.

    Do this instead

    Look 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.

Embedding modelsa family of modelsOpen-source modelsBERTProprietary modelsprovided as APIsCLIPContrastive Language-ImagePre-trainingSentence TransformersOpenAI Embeddings APIaccessed through an APIincludesincludesexampleexampleexampleexample
How are the named embedding models grouped by who builds them and how they are accessed?

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

EASY

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.
MEDIUM

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.

More concepts starting with E