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.
One-hot encoding vs embeddings
| One-hot | Embedding | |
|---|---|---|
| Length | As long as the whole vocabulary (e.g. 50,000) | A few hundred to a few thousand numbers |
| Contents | All zeros except a single 1 | Every number carries information |
| Meaning | Every word is equally different from every other | Similar meaning = close together |
| How it's made | Fixed by hand | Learned from data |
Measuring similarity
| Measure | What it checks | Typical use |
|---|---|---|
| Cosine similarity | The angle between two vectors, ignoring their length | The usual choice for text |
| Euclidean distance | Straight-line distance; smaller means more similar | Clustering |
| Dot product | Direction and length together; very fast | Large-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.
Tip: use the same embedding model for your documents and your questions, otherwise their maps won't line up.
Try it yourself
About 10 minDraw a meaning map
- Write 12 words: 4 animals, 4 fruits, 4 jobs.
- Place them on paper so similar words sit close together.
- 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.