1. What Is an Embedding Vector?
An embedding is a list of numbers that stands for the meaning of a piece of text. It is also called a vector.
It is made by an embedding model. This is a ready-made program: you give it a chunk of text, and it gives you back one list of numbers. The same text always gives the same list, and texts with a similar meaning give similar lists.
We make these lists for all our chunks, store them, and later use them to find the chunks that match a question.
- Same size every time. A short line and a long chunk both give a list of the same length, for example 1,024. The length depends on the model.
- Each number holds a little meaning. More numbers means more room for detail.
- Similar meaning gives a similar list. Texts about different things give lists that are far apart.
- Reality check. The meaning is spread across all the numbers together. You cannot point at one number and say "this is adventure".
2. Example: Movies as Vectors
Let us see what "every number holds some meaning" looks like. Take three movie plots and give each a vector.
| Movie plot | action | romance | comedy | sci-fi |
|---|---|---|---|---|
| A superhero team fights an alien army | 0.90 | 0.10 | 0.30 | 0.80 |
| Astronauts fly through a wormhole to save humanity | 0.50 | 0.20 | 0.00 | 0.95 |
| Two strangers fall in love in Paris | 0.00 | 0.95 | 0.30 | 0.00 |
- Each number says a little about the plot. The first movie scores high on action and sci-fi. The third scores high on romance. That is why an embedding is also called a meaning vector.
- Similar plots get similar vectors. The superhero movie and the wormhole movie are both sci-fi action, so their lists are close (closeness 0.90). The Paris love story is far from them (closeness 0.15).
- More numbers means more detail. With 4 numbers we can only say "action, romance, comedy, sci-fi". With 1,024 numbers a model can also capture mood, setting, themes and more.
- Reality check. I named the 4 columns only so you can see the idea. In a real embedding the numbers have no names, and the meaning is spread across all of them together.
3. Why Do We Need It?
In RAG we have many chunks, and for every question we must find the chunk that answers it. The first idea is to match words. But people say the same thing in different words, so matching words picks the wrong chunk. An embedding lets the computer compare meaning instead.
| Chunk in the PDF | Words in common with the question | Close in meaning? |
|---|---|---|
| "The total income was 4.2 lakh." | none | yes, it answers the question |
| "The money transfer was done on Monday." | “money” | no, a different topic |
| "Paris is the capital of France." | none | no |
- Matching words picks the wrong chunk. The best answer shares no word with the question. The wrong chunk shares the word "money".
- Matching meaning picks the right chunk. "earn" and "income" are about the same thing, even though the letters are different.
- An embedding makes this possible. Every chunk and the question become lists of numbers, and the lists with a similar meaning are close to each other. The computer can measure that.
4. Who Makes It?
You do not make embeddings yourself. Companies and open-source projects build embedding models, and you use one of them.
| Embedding model | Made by | How you use it | Size of its vector (fixed for the model) |
|---|---|---|---|
all-MiniLM-L6-v2 | open source | on your computer | 384 |
mistral-embed | Mistral AI | API | 1,024 |
text-embedding-3-small | OpenAI | API | 1,536 |
text-embedding-3-large | OpenAI | API | 3,072 |
- Every model has its own embedding table, with its own fixed size. That size is the number of columns in the table, and the usual length of the vectors the model gives. You cannot change the table.
- You choose a model and use its default size. Some models let you ask for a shorter vector at the end. That saves space and search time but keeps less detail.
- Use the same embedding model for the chunks and for the question. Numbers from two different models do not match. This is only for retrieving. After we get the chunk text back, the LLM that writes the answer can be a different model, because it reads text, not vectors.