Concepts / Embedding Size and Model Choice

Embedding Size and Model Choice

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

  • Programming

Why a Model Needs Numbers

Imagine a system that must answer questions about a simple sentence such as 'the cat sits on a mat'. The sentence is made of letters and spaces, but the machine doing the work is built to handle numbers. Before any reasoning can happen, something has to bridge that gap. The idea that does this bridging is called an embedding, and it is one of the central ideas behind modern language and image models.

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. Every input, whether it is a sentence or an image, must first be turned into a numerical form that the model can compute with. The practical question is what kind of numbers are useful for this job.

What an Embedding Captures

Definition

An embedding is a numerical representation that aims to capture the meaning of the original data. It is a vector, which means it is an ordered list of numbers.

The word 'aims' matters. An embedding is an attempt to encode meaning in numbers, not a guaranteed copy of that meaning. The numbers are useful precisely because they carry the encoded meaning forward into later computation. The original sentence is meant for people reading text, while the embedding is meant for a model that needs numbers to compute with. The two forms carry the same underlying content but are built for different consumers.

Reading an Embedding as an Ordered List

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, and the position of an element in the list matters. Changing the order of the numbers produces a different vector, even when the same numbers appear.

Position 00.11Position 10.02Position 20.54
What does each position in the vector hold, and why does the order of the list matter?

Read the diagram from left to right. Each box is one slot, and the number inside it is that slot's element. The three slots together form one vector. The source does not say what any single slot means on its own, so do not read a single position as a named feature. What it does say is that the vector as a whole, with its numbers in their particular order, is the representation.

What do you think happens?

If the same three numbers are reordered from [0.11, 0.02, 0.54] to [0.54, 0.02, 0.11], is this still the same embedding?

  • Yes, the same numbers appear in both

  • No, the order of the elements is part of the vector

Reveal answer
Answer:

No, the order of the elements is part of the vector

The source states that the position of an element in the list matters, and that changing the order produces a different vector even when the same numbers appear.

From Raw Input to Vector

The conversion happens before any reasoning. The raw input, such as a sentence or an image, is handed to a model that produces a numerical representation. That representation is the embedding, and it becomes the material the rest of the computation works on. The order of these steps is fixed: conversion first, then processing.

Raw inputthe cat sits on a matEmbedding modelproduces numericalrepresentationEmbedding vectorordered list of numbersModel computationarithmetic on numbersconvertedoutputscarried forward
In what order does raw input become a numerical representation that the model can process?

Trace the sentence through the pipeline. It starts as text, which a person can read but a model cannot compute with directly. An embedding model converts it into an embedding vector. Only then does the model's computation begin, and that computation works on the numbers in the vector.

How Large Embeddings Get

Definition

The embedding size is the number of elements in the vector. The source states that this size is typically between 100 and 10,000.

Three-element vector[0.11, 0.02, 0.54]Lower end100 elementsUpper end10,000 elements
How does the three-element example compare with the typical range of embedding sizes?

The three-element vector used earlier is far below the typical range. It should be read as an illustration of structure, showing how a vector is an ordered list, rather than as an illustration of scale. A real embedding usually has many more elements than three.

Choosing Between Open-Source and Proprietary Models

An embedding is produced by a model, and some models are trained especially to produce embeddings. Embedding models form a family rather than a single model. The choice of model determines the embedding size and other properties of the vectors it outputs, so model choice and embedding size are linked.

GroupExamples named in the sourceHow it is provided
Open-source embedding modelsBERT, CLIP (Contrastive Language-Image Pre-training), Sentence TransformersOpen-source models built for producing embeddings
Proprietary embedding modelsOpenAI Embeddings APIProvided as APIs

Embedding model examples grouped by how they are provided

Worked Example: Checking a Vector Against the Typical Range

Worked example

Is this embedding a plausible size?

A model returns an embedding with 384 elements. Is this size inside the range the source gives as typical?

  1. 1
    Identify the embedding size

    The embedding size is the number of elements in the vector, so this embedding has size 384.

  2. 2
    Recall the typical range

    The source states that embedding size is typically between 100 and 10,000.

  3. 3
    Compare the size to the range

    384 is greater than 100 and less than 10,000, so it falls inside the typical range.

Result

The size of 384 is inside the typical range. Being inside the range does not prove the embedding is good, because the range only describes typical sizes.

Notice what this check can and cannot tell you. It can tell you whether a size is typical. It cannot tell you whether the vector captures meaning well, because the source describes an embedding as an attempt to encode meaning rather than a guaranteed result.

Mistakes With Embedding Size

  • Common mistake

    Treating the three-element example as a real embedding size

    What it looks like

    Assuming every embedding has three numbers because [0.11, 0.02, 0.54] was used to illustrate the idea

    Why it fails

    The source says the typical size is between 100 and 10,000, and the three-element example is far below that range.

    Do this instead

    Read the example as an illustration of structure, then use the typical range when thinking about scale.

  • Common mistake

    Assuming all models produce the same embedding size

    Why it fails

    The source states that embedding size varies across models and that the model choice determines it.

    Do this instead

    Look up the size for the specific model in use, including its variant or input type.

  • Common mistake

    Reordering the elements of a vector and expecting the same result

    Why it fails

    The source states that the position of an element matters and that changing the order produces a different vector.

    Do this instead

    Keep the elements in their original order, because the order is part of the representation.

  • Common mistake

    Confusing the original data with its embedding, when the embedding is a numerical stand-in built for a model

Practice: Reasoning About Embedding Size

EASY

A colleague says, 'The embedding for our sentence is [0.54, 0.11], so it is the same as the embedding [0.11, 0.54] because both use the same two numbers.' Explain whether this reasoning is correct, using what the source says about element order in a vector.

Hints
  • Recall that an embedding is a vector, which is an ordered list.
  • The source states that changing the order of the numbers produces a different vector.
  • Ask whether two vectors with the same numbers in a different order can still be the same vector.
MEDIUM

A model's documentation lists its embedding size as 50. Using the typical range given in the source, decide whether this size is typical, and explain what you would still need to check before judging the model's embeddings.

Hints
  • The source gives the typical range as 100 to 10,000.
  • Compare 50 against the lower end of that range.
  • Think about whether a typical size tells you whether the model captures meaning well.

Key Takeaways

  • A model works with numbers, so raw input such as text or an image must be converted into a numerical representation before the model can process it.
  • An embedding is a vector, an ordered list of numbers, that aims to capture the meaning of the original data, and the order of its elements is part of the representation.
  • The embedding size is the number of elements in the vector and is typically between 100 and 10,000, and it varies across models.
  • Open-source embedding models include BERT, CLIP, and Sentence Transformers, while proprietary embedding models such as the OpenAI Embeddings API are provided as APIs.

Related concepts

More concepts starting with E