Embeddings up close: similarity search and sentence embeddings

An embedding is a list of numbers (often a few hundred to a few thousand of them) that places a word, sentence or image on a map of meaning. Things with similar meaning land close together, so a computer can find related items simply by measuring distance.

Everyday analogy

A city map. Restaurants cluster on the food street and schools sit near the homes. If you know where you are standing, you can find the nearest places without knowing their names.

Example

"kitten" lands near "cat" and "puppy" and far from "apple". A support bot uses this to match "I can't log in" with the help article "Resetting your password", even though no words match.

catdogpuppykingqueenprinceappleorangebanana“kitten” (your search)Similar meaning = close together
Embeddings place words on a map of meaning; a search simply finds the nearest points.

One-hot encoding vs embeddings

One-hotEmbedding
LengthAs long as the whole vocabulary (e.g. 50,000)A few hundred to a few thousand numbers
ContentsAll zeros except a single 1Every number carries information
MeaningEvery word is equally different from every otherSimilar meaning = close together
How it's madeFixed by handLearned from data

Measuring similarity

MeasureWhat it checksTypical use
Cosine similarityThe angle between two vectors, ignoring their lengthThe usual choice for text
Euclidean distanceStraight-line distance; smaller means more similarClustering
Dot productDirection and length together; very fastLarge-scale search (same as cosine when vectors are normalised)

Sentence embeddings

Whole sentences or documents can be turned into a single vector, using models such as Sentence-BERT or the embedding models from OpenAI, Cohere, Google and Voyage. They power semantic search, RAG, duplicate detection and recommendations.

TextA document or question
→
Embedding modelTurns it into numbers
→
VectorIts spot on the map
→
Similarity searchFind the nearest stored vectors
→
ResultsThe most related content

Tip: use the same embedding model for your documents and your questions, otherwise their maps won't line up.

Try it yourself

About 10 min

Draw a meaning map

  1. Write 12 words: 4 animals, 4 fruits, 4 jobs.
  2. Place them on paper so similar words sit close together.
  3. Ask an AI chatbot to group the same words by meaning and compare.

What you should see: Your map and the AI's groups look alike: that's the idea behind embeddings.

Use any free AI chatbot (ChatGPT, Claude, Gemini or Copilot). Never paste private or confidential information.

Build it for real · guided projectBuild a document Q&A assistant (RAG, no code)About 60 min · No coding needed · step by step
Test what you learned

Take a quick quiz, or look up any word in the glossary.