What is an embedding?
An embedding is a way of turning content into numbers that capture what it means. A sentence, a product description, an image or a whole document is converted into a vector: a list of hundreds or thousands of numbers. Content with similar meaning ends up with similar numbers.
That gives software something it otherwise lacks, a sense of closeness in meaning. "How do I cancel my plan?" and "steps to end a subscription" share almost no words, but their embeddings sit close together.
How do embeddings work?
- An embedding model reads the content. This is a neural network trained so that related content produces nearby vectors.
- It outputs a vector. Every input gets a list of the same length.
- Vectors are compared. A similarity measure, commonly cosine similarity, scores how close two vectors are.
- The closest matches are returned.
Think of it as placing every piece of content on a map with a very large number of dimensions. Things about the same topic cluster together, and distance on the map stands in for difference in meaning.
What are embeddings used for?
| Use | How embeddings help |
|---|---|
| Semantic search | Finds results by meaning, not exact keywords |
| Retrieval-augmented generation | Finds the passages to hand to a language model before it answers |
| Recommendations | Suggests items similar to those a person liked |
| Clustering | Groups similar tickets, reviews or keywords |
| Deduplication | Spots near-identical records worded differently |
| Classification | Assigns a label by closeness to known examples |
Embeddings vs tokens
Tokens are the pieces a model splits text into. Embeddings are the numeric meaning assigned to text. A language model uses both: it breaks text into tokens, then works with embeddings of them internally. The embeddings used for search are usually one vector for a whole passage.
What should you know before using them?
- Vectors from different embedding models cannot be compared. Change the model and everything must be embedded again.
- Quality depends on how documents are split. A passage that is too long blurs several topics into one vector.
- Similar does not mean correct. The nearest passage can be on the right topic and still not answer the question.