What are embeddings? How AI turns meaning into numbers

Search "cheap phone" and find "budget mobile", even though the words don't match. Embeddings make that possible. Here is what they are, how similarity works, and where they power the apps you use.

A map of meaning drawn on grid paper. A cluster of sticky notes in the top left reads cheap phone, budget mobile and affordable smartphone. A search query, low-cost handset, lands right next to them. Far away in the bottom right is a cluster for banana bread and apple pie, and in between sits laptop deals. Arrows show the query's nearest neighbours.
Fig. 1 — An embedding gives every piece of text a position on a map of meaning. Texts that mean similar things land close together.

Type “cheap phone” into an old-style search box and it looks for pages containing the words “cheap” and “phone”. A page titled “Best budget mobiles under ₹10,000” might never show up, because it doesn’t use either word.

Modern search can find that page anyway. It looks for meaning, not matching words. The trick behind that is the embedding: a way of turning text (or images, or audio) into a list of numbers so that similar meanings get similar numbers.

This guide explains embeddings in plain English: what they are, how a computer measures “similar”, and where they are used. If you want to see how an LLM turns each token into an embedding inside the model, read our deeper guide to tokens and embeddings. This one is about what embeddings are for.

What is an embedding?

An embedding is a list of numbers that represents the meaning of a piece of data, such as a word, a sentence, a document or an image, so that things with similar meanings get similar lists of numbers.

A list of numbers like this is also called a vector. For example:

"cheap phone" → [0.12, −0.48, 0.91, 0.03, …]

These particular numbers are made up for illustration. A real embedding usually has hundreds or thousands of numbers. OpenAI’s text-embedding-3-small model, for instance, produces 1,536 numbers by default, and text-embedding-3-large produces 3,072.

An everyday picture: a map of meaning

Think of a map. Any place can be described by just two numbers: its latitude and longitude. Two places with similar numbers are close together on the map.

An embedding does the same for meaning. It gives each piece of text an address on a map of meaning. “Cheap phone”, “budget mobile” and “affordable smartphone” get addresses close to each other. “Banana bread” lands far away. The main difference from a real map is the number of directions: two for a map of the world, hundreds or thousands for a map of meaning.

No single number has a neat label like “is about phones” or “is about food”. The meaning is spread across the pattern of all the numbers together.

How does a computer measure “similar”?

Once two pieces of text are vectors, a computer can measure how close they are with simple arithmetic. The most common measure is cosine similarity, which compares the direction the two vectors point in.

  • The higher the score, the more similar the meaning. The top possible score is 1.
  • What counts as “unrelated” depends on the model. With some models, even unrelated texts score well above 0, so it’s the ranking that matters, not one magic number.

Here is an illustrative example with made-up scores:

Compared with “cheap phone” Similarity (illustrative)
“budget mobile” 0.89
“affordable smartphone” 0.86
“laptop deals” 0.52
“banana bread recipe” 0.08

Real scores depend on the embedding model, but the ranking is the point: the closest meanings come out on top, even with no words in common.

Where do the numbers come from?

Nobody types them in. Embeddings are produced by an embedding model: a neural network trained on huge amounts of data so that texts used in similar ways end up with similar vectors.

A famous early example is word2vec, published by Tomas Mikolov and colleagues at Google in 2013. It learned a vector for each word, and showed something striking: if you take the vector for king, subtract man and add woman, the closest word vector (other than the words you started with) is queen. The model had picked up relationships like male and female, or country and capital, purely from how words are used.

Today’s embedding models go further. They create one vector for a whole sentence, paragraph or page, and take the surrounding words into account, so “bank” in “river bank” and in “bank account” mean different things. Some models even put images and text on the same map, so a photo of a dog lands near the words “a dog playing in the park”. That’s how you can search a photo gallery by typing a description.

What are embeddings used for?

Embeddings are quietly behind many features you use every day.

Two rows. Top row, done once in advance: documents go into an embedding model, which turns each into a vector, and the vectors are stored. Bottom row, at search time: the question how do I get my money back goes into the same embedding model, becomes a vector, the closest stored vectors are found, and the top match is the refunds and returns policy page.
Semantic search in two steps. Embed your documents once; then embed each question and find the closest matches.
  • Semantic search. Search by meaning. A support site can match “how do I get my money back?” to its “Refunds and returns” page.
  • Recommendations. “You might also like” for products, songs or articles: find items whose embeddings sit near the ones you enjoyed.
  • Finding duplicates. Spot two support tickets or forum questions that ask the same thing in different words.
  • Grouping and sorting. Automatically cluster thousands of customer reviews into topics, or sort messages into categories.
  • RAG (retrieval-augmented generation). Before an AI chatbot answers a question about your documents, it uses embeddings to find the most relevant passages and passes them to the model. That gets its own letter, R, later in this series.

Because these apps compare a question against millions of stored vectors, the vectors are often kept in a special store built for fast similarity search, called a vector database (letter V).

Things to know before you use embeddings

  • Use the same model for everything you compare. Vectors from two different embedding models live on two different maps. Comparing them is meaningless.
  • Similar isn’t the same as correct. Embeddings find text that is about the same thing. A passage can be very similar to your question and still not contain the answer.
  • Negation is tricky. “I love this phone” and “I don’t love this phone” can end up surprisingly close, because they are about the same topic.
  • They can carry bias. Embeddings learn from human-written data, so they can pick up stereotypes. Researchers found this in word embeddings years ago, for example linking some jobs more with men and others with women. See AI bias.

Common misconceptions

“An embedding is just a meaningless list of numbers, so it’s safe to share.” An embedding is built to capture meaning, not to store the exact words. But researchers have shown that the original text can sometimes be partly or even largely recovered from an embedding, so treat embeddings of private text as private too.

“Each number stands for one feature, like ‘is about food’.” Usually not. The meaning is spread across all the numbers together.

“Embeddings are only for words.” They work for sentences, documents, images, audio, products, and even users.

“Bigger embeddings are always better.” More numbers can capture more detail, but cost more to store and search. Many apps work well with smaller ones.

Key takeaways

  • An embedding is a list of numbers (a vector) that captures the meaning of data.
  • Similar meanings get similar vectors, like nearby places on a map.
  • Cosine similarity measures how close two embeddings are.
  • Embeddings are created by trained embedding models, such as word2vec in 2013 and today’s sentence embedding models.
  • They power semantic search, recommendations, duplicate detection, clustering and RAG.

Frequently asked questions

What are embeddings in simple words?

Embeddings are numbers that describe what something means. Texts with similar meanings get similar numbers, so a computer can find related content even when the words differ.

What is the difference between embeddings and tokens?

A token is a small piece of text, like a word or part of a word. An embedding is a list of numbers that represents meaning. Inside an LLM, each token is turned into an embedding. Separately, embedding models can turn a whole sentence or document into one embedding. Our guide to tokens and embeddings covers this in detail.

What is a vector embedding?

It’s the same thing. “Vector” is the maths name for a list of numbers, so “vector embedding” and “embedding” mean the same.

How many dimensions does an embedding have?

It depends on the model. Common sizes range from a few hundred to a few thousand. OpenAI’s text-embedding-3-small uses 1,536 by default and text-embedding-3-large uses 3,072.

Are embeddings the same as a model’s weights?

No. Weights are the numbers a model learns during training and uses to do its job. An embedding is the output the model produces for a particular piece of data. (Inside an LLM, the starting embedding for each token is stored in a table that is part of its weights, which is why the two get confused. See weights vs embeddings.)

Comments

LEAVE A COMMENT
No sign-up. Comments appear after a quick review.