Category · Data and retrieval-augmented generation
What is an embedding?
An embedding is a text turned into a list of numbers that sums up its meaning. Two sentences that mean the same thing get close lists, even with different words. That is what makes searching by meaning possible.
By Laurent Poupet, Claude trainer and artificial intelligence architect · Updated
How it works
- The model turns a text into a list of a few hundred to a few thousand numbers, and the closeness between two lists measures how similar their meanings are.
- This closeness is most often measured with cosine similarity, which compares the direction of the vectors rather than their length.
- An embedding captures exact identifiers poorly, such as a contract number or an error code, hence the value of combining it with full-text search.
The trap to avoid
The trap is mixing models; vectors produced by two different models cannot be compared, except within a family designed for it, such as voyage-4, and changing models usually means re-indexing everything.
A concrete example
The question “how do I request time off?” and the passage “absence request procedure” share almost no words. Their embeddings, however, are close, because they are about the same thing: searching by meaning finds the right passage where a keyword search would fail. Conversely, for an exact contract number, keyword search remains better.
What is the difference with full-text search?
| Criterion | Embedding | full-text search |
|---|---|---|
| What is compared | The meaning of sentences | The exact words |
| Strong for | Rephrasing, synonyms | Identifiers, codes, names |
| Together | Hybrid search combines both | Hybrid search combines both |
Related terms
- Cosine similarityData and retrieval-augmented generation
- RAG (retrieval-augmented generation)Data and retrieval-augmented generation
- Semantic chunkingData and retrieval-augmented generation
Where this is taught
This idea comes up throughout the lessons; we work on it with your own examples during a lesson.
Lesson content (step-by-step instructions, exercises with solutions, quizzes) is for students only, with an access code received after the first lesson.