Module 2 · How a language model thinks · Lesson 7 of 32
Embeddings: meaning as a map
10 minFree GenAI course · BeginnerLesson 2.3By Saket Bhatnagar
Researched and drafted with AI, reviewed and edited by Saket Bhatnagar.
In short
- An embedding is a list of numbers that gives a word or sentence a spot on a map of meaning.
- Things that mean similar things get nearby spots, so close numbers mean close meanings.
- Embeddings power search by meaning, recommendations and RAG, and every LLM starts with them.
Video lesson · coming soon
What are embeddings? Meaning as a map, in 3 minutes
Lala, your AI mentor, will walk you through this lesson in a short animated video. Until then, everything is here to read and try.
- 01 Finding curd in a new supermarket
- 02 An ID is only a name tag
- 03 Scoring dishes with four numbers
- 04 Explore the meaning map
- 05 “Money back” finds “Refund policy”
- 06 Play with the map
Asha has moved from Chennai to Delhi, and on her first Sunday she walks into a huge supermarket looking for curd. She has no idea which aisle it is in. Then she spots paneer, and right beside it: curd, butter and milk.
She did not need the exact shelf number. She only needed something close in kind, because the shop keeps similar things near each other. Hold on to that shop layout. It is exactly what an embedding is.
Why token IDs are not enough
In the lesson on tokens, every piece of text became an ID number. But an ID is only a label. Think of roll numbers in a class register. Roll 41 and roll 42 sit next to each other, yet that tells you nothing about whether those two students are alike.
Token IDs work the same way. “cat” might be number 9,203 and “kitten” number 74,118. The numbers are far apart, even though the meanings are close. The model needs numbers where closeness actually means something.
A map of meaning you can explore
Now imagine each word got only two numbers instead of hundreds. Two numbers are a point on a flat map: one for left and right, one for up and down. Put every word on that map, and something lovely happens. Fruits gather in one corner, vehicles in another, cricket words in a third.
The demo below is such a map, with about thirty words in groups: fruits, vehicles, animals, cricket, feelings and royalty. Tap any two words and a line joins them, with a percentage for how close in meaning they are.
- Tap two fruits. Then tap a fruit and a vehicle. Compare the two scores.
- Tap two words from the cricket group. They sit close because they appear in the same kind of sentences.
- Tap “bat” and “cricket bat”. Same spelling, different meanings, different spots: one “bat” is the animal that flies at night.
- Tap “king” and “queen”, then “king” and “prince”. All royalty, but each pair differs in its own way.
- Tap the “king − man + woman” button. Two arrows appear, man to woman and king to queen, and they point the same way.
Where do the numbers come from?
Nobody types these numbers in. The model learns them from how words are used. A linguist, J. R. Firth, put the idea neatly in 1957: “You shall know a word by the company it keeps.”
Think of the sentence “I drank a cup of hot ___”. Chai, coffee and milk all fit that gap. Words that keep filling the same gaps get pushed closer together during training, through the same guess, check and nudge loop you met in module 1. Over billions of sentences, a map of meaning takes shape.
Directions on the map can carry meaning too. In a famous result from 2013 research on word embeddings, taking the spot for “king”, subtracting “man” and adding “woman” landed near “queen”. One direction had roughly learned “female”, another “royal”. It works roughly, not perfectly, so treat it as a lovely illustration rather than a law.
Search by meaning, not by spelling
Rohan’s order from a shopping app arrives broken. On the help page he types “money back”. An old keyword search finds nothing, because the help article is titled “Refund policy” and shares none of his words.
Search with embeddings works differently. Every help article was turned into a vector ahead of time. Rohan’s question becomes a vector too, and the app looks for the stored vectors nearest to it. “Refund policy” comes out on top, because its meaning sits right next to “money back”.
How search by meaning works
Drag to exploreThe question is turned into a vector and compared with vectors stored for every article; the nearest ones are the best matches.
Diagram connections:
- Your question to Embedding model (send)
- Embedding model to Question vector (numbers)
- Question vector to Find nearest (compare)
- Stored vectors to Find nearest (compare)
- Find nearest to Best match (closest)
- Your question: Rohan types “money back”.
- Embedding model: Turns any text into a list of numbers that captures its mea…
- Question vector: A list of, say, 768 numbers.
- Stored vectors: Each help article was turned into a vector earlier and save…
- Find nearest: Scores how close the question is to every stored vector.
- Best match: “Refund policy” comes top, with no shared words.
| Keyword search | Search by meaning | |
|---|---|---|
| Matches on | The exact words you typed | Similar meaning, even with different words |
| Does “money back” find “Refund policy”? | No | Yes |
| Typos and other languages | Often fails | Often still works, depending on the model |
| Best at | Order IDs, codes and exact names | Questions in everyday words |
Many real apps use both at once, which is called hybrid search. Here are some places you meet embeddings without noticing:
- Help pages and document search that understand what you meant, not only what you typed.
- Recommendations: songs or videos whose vectors sit near the ones you liked.
- Grouping thousands of customer complaints into a handful of themes.
- Spotting duplicate questions on a forum, even when they are worded differently.
- RAG, where an AI looks up your documents before answering. You’ll build that idea in module 4.
Embeddings also live inside every language model. The very first thing an LLM does with each token ID is look up its embedding. At that point “bank” has the same vector in “river bank” and “bank loan”. The next lesson shows how attention lets the neighbouring words reshape it.
Check yourself
Check yourself
Why can’t a model use token IDs directly as a sign of meaning?
Pick an answer to see why it is right or wrong.
Check yourself
Meera types “money back” and the help page finds “Refund policy”. What made that possible?
Pick an answer to see why it is right or wrong.
Check yourself
Two pieces of text have a similarity score close to 1. What does that tell you?
Pick an answer to see why it is right or wrong.
Remember these three
- An embedding is a list of numbers that places text on a map where nearby means similar.
- The numbers are learned from how words are used, not typed in by people.
- Embeddings let apps search and group by meaning, and they are the first step inside every LLM.
Questions people ask
- What are embeddings in simple words?
- An embedding is a list of numbers that describes what a piece of text means. Texts with similar meanings get similar lists, so a computer can measure how close two meanings are. It works like a map where related things sit near each other.
- What is the difference between tokens and embeddings?
- A token is a small piece of text, and its ID number is only a label. An embedding is a vector of many numbers that captures meaning. Language models first turn each token ID into an embedding before doing anything else.
- How many numbers are in an embedding?
- Commonly a few hundred to a few thousand, depending on the model; sizes like 384, 768 or 1,536 are typical. More dimensions can capture finer shades of meaning but take more storage and compute.
- What are vector embeddings used for?
- They power search by meaning, recommendations, grouping similar texts, finding duplicates and RAG systems that look up documents for an AI. They are stored in vector databases that can quickly find the nearest matches.