How AI works

What are embeddings in AI? A simple explanation

An embedding turns a word, sentence or image into a list of numbers that captures its meaning, so AI can measure how similar things are. How embeddings work and where they're used: search, RAG and recommendations.

3 min read

Short answer

An embedding is a list of numbers, called a vector, that represents the meaning of something: a word, a sentence, a document, an image or a product. Things with similar meanings get vectors that are close together, so a computer can find related items by measuring distance. Embeddings power semantic search, , recommendations and clustering.

Meaning as coordinates

Imagine placing every word on a map so that similar words sit near each other: "cat" next to "kitten", both near "dog", all far from "spreadsheet". An embedding is a word's coordinates on that map.

A real embedding map doesn't have two dimensions but hundreds or thousands, so each embedding is a list of that many numbers. No single number means anything obvious on its own; meaning comes from where the whole point sits relative to others.

The embeddings lesson has an interactive map you can explore.

same direction:“+ female”dogpuppycatkittenpizzapastabreadkingqueenmanwoman
Embeddings place similar meanings close together, so a computer can measure meaning as distance.

How similarity is measured

To compare two embeddings, systems usually use cosine similarity: how closely the two vectors point in the same direction. A score near 1 means very similar, near 0 means unrelated.

This is what lets you search by meaning. A search for "how do I get my money back" can find a page titled "Refund policy" even though they share no words, because their embeddings land close together.

Famously, the 2013 word2vec work showed directions in the space can capture relationships: the vector for "king" minus "man" plus "woman" lands near "queen". Modern embeddings are messier, but the idea of meaning as geometry stuck.

Where embeddings come from

Embeddings are learned. A neural network is trained on a huge amount of data with a task that forces it to understand meaning, such as predicting nearby words or matching questions with their answers. Along the way it learns to place similar things close together.

Inside a large language model, the very first step turns each token into an embedding, and every layer after that refines those vectors using attention. Separate embedding models are trained just to produce one good vector per sentence or document for search.

What embeddings are used for

  • Semantic search: find documents by meaning, not exact words.
  • RAG chatbots: find the passages an AI should read before it answers. See what is RAG.
  • Recommendations: embed users and items, and suggest items close to what you liked. See the recommender systems lesson.
  • Clustering: group similar support tickets, reviews or articles automatically (clustering).
  • Duplicates and anomalies: spot near-identical items or ones that don't fit.
  • Images and multimodal: models like CLIP put pictures and captions in the same space, so you can search photos with words. See multimodal.

Vector databases

Comparing a question against millions of embeddings one by one would be slow. A vector database or vector index stores embeddings and uses clever shortcuts (approximate nearest-neighbour search) to find the closest ones in milliseconds. Open-source options include FAISS, and many ordinary databases now support vectors too.

Key takeaways

  • An embedding is a point in a space with hundreds or thousands of dimensions.
  • Close together means similar in meaning; far apart means unrelated.
  • They're learned by a neural network, not written by hand.
  • Uses: search by meaning, RAG, recommendations, duplicates, clustering.

Learn it properly, free

Terms in this post

Questions

What is an embedding in simple terms?

It's a list of numbers that represents the meaning of a piece of data, like a word or sentence. Similar meanings get similar numbers, so a computer can tell which things are related.

What is the difference between a token and an embedding?

A token is a piece of text, such as a word or part of a word, with an ID number. An embedding is the list of numbers a model uses to represent that token's, or a whole text's, meaning.

What are embeddings used for?

Semantic search, finding passages for RAG chatbots, recommendations, clustering similar items, spotting duplicates, and searching images with text.

What is a vector embedding?

The same thing as an embedding: the word vector just stresses that it's a list of numbers that can be treated as a point or direction in a high-dimensional space.

Sources and further reading

Read next

Spotted a mistake? Suggest an edit