What is an embedding?

In short
An embedding is a list of numbers that represents an item, such as a word, image or product, in a form a machine learning model can process. Items with similar meaning or behavior get similar lists, so their numbers sit close together. Models learn these values during training.
How it works
A neural network works with numbers, not with words or pictures. So before a model can use a word, a product or a user, that item must be turned into a list of numbers. An embedding is that list. Each item is mapped to a point in a space with many dimensions, and the position of the point carries meaning.
The key idea is similarity. Items that behave alike in the data end up close together. Two words that appear in similar sentences, for example, get vectors that point in similar directions. The distance between two vectors then becomes a rough measure of how related the two items are.
Embeddings are usually learned. You start with random numbers for each item. During training, the model adjusts those numbers so its predictions improve. Over many steps, the vectors settle into a layout that reflects patterns in the data.
Why it matters
Embeddings turn messy inputs into a compact, fixed-size form. A sentence of any length can be converted into the same number of values, which is much easier for a model to handle. They also let a model share knowledge. A vector learned for one task can often be reused for another.
Common uses include search by meaning rather than exact words, recommendations based on similar items, and grouping related documents. Embeddings are also the first layer in many large language models, where each token is converted into a vector before the rest of the network runs.
A simple example
Imagine three words: cat, dog and car. A model might give each one a vector of four numbers. Cat and dog, both animals, would get vectors that sit close to each other. Car would sit farther away. If you ask which word is closest to "cat", the answer is "dog", because the distance between their vectors is smallest.
Real embeddings have far more dimensions and are learned from large amounts of data, but the idea is the same. Nobody writes the numbers by hand. The training process finds them.
A typical workflow looks like this:
- Choose an embedding size, meaning how many values each item gets.
- Create a lookup table with one row per item.
- Train the model so the rows improve its predictions.
- Save the table and reuse it, or compare rows with a distance measure such as cosine similarity.
Common mistakes
One mistake is expecting the numbers to be human-readable. A single dimension rarely means something clear on its own. What matters is how the vectors relate to each other.
Another mistake is comparing embeddings from different models. Each model learns its own layout, so vectors from one model cannot be meaningfully compared with vectors from another.
A third mistake is ignoring data quality. If the training data is biased or narrow, the embeddings will reflect that. Similar items may be grouped for the wrong reasons.
Finally, beginners sometimes expect embeddings to solve everything. They help a model find patterns, but you still need a clear task, enough data and a way to measure results.
Alternatives and related ideas
Before learned embeddings, many systems used simple methods such as one-hot encoding. There, each item gets a long vector with a single 1 and the rest zeros. These vectors are easy to build, but they do not capture similarity, and they grow large when there are many items.
Pretrained embeddings are another option. Instead of training from scratch, you can use vectors learned on a large dataset as a starting point. This saves time when your own data is small.
If you want to check related terms, such as activation function or accuracy, the Google Machine Learning Glossary is a good place to start. It explains many of the building blocks that work alongside embeddings.
FAQ
Is an embedding the same as a vector?
Not exactly. An embedding is a vector that a model has learned to represent an item. Every embedding is a vector, but not every vector is an embedding, such as a simple one-hot encoding.
Do I need to train my own embeddings?
Not always. For small projects, pretrained embeddings are often enough. Training your own makes sense when your data is specialized and a general model does not capture its patterns well.
How do I know if two embeddings are similar?
A common approach is cosine similarity, which measures the angle between two vectors. Values closer to 1 usually mean the items are more alike, though the exact meaning depends on the model.
Can embeddings be used for images?
Yes. Models can turn images into vectors as well, so that visually similar pictures end up close together. The same ideas apply, although the model that creates the vectors is different.
Sources
This page is based on the official documentation below. Read it for full detail.
Embedding — official documentation ↗