Embedding
A list of numbers (a vector) that represents a word, image or document, arranged so that similar things get similar vectors.
Also word embedding · vector embedding · representation
Mikolov et al. (word2vec), 2013
Give every word a spot on a giant map. Words with similar meanings live in the same neighborhood: 'cat' near 'kitten', far from 'carburetor'.
Where it fits
Not shown: 6 more that build on it. See the full list below.
+All relationships as a list
Is a kind of / part of
Kinds and parts
Siblings
- AI Agents and Tool Use
- BERT
- Direct Preference Optimization
- Fine-Tuning
- Google Translate
- GPT
- Hallucination
- In-Context Learning
- Keyboard Autocomplete
- Large Language Model
- LLM Evaluation and Benchmarks
- Perplexity
- Pretraining
- Prompting
- Retrieval-Augmented Generation
- RLHF
- Sampling and Temperature
- Scaling Laws
- Tokenization
- Vector Database
- word2vec
Techniques that apply here
How it works
Computers cannot measure how similar “cat” and “kitten” are from their letters. An embedding gives each item a vector, typically hundreds of numbers, so that similarity becomes distance.
Where do the vectors come from? They are learned. word2vec (2013) trained a small network to predict a word from its neighbors in sentences. Words used in similar contexts ended up with similar vectors, so “Paris” landed near “Berlin”, and directions in the space even captured relationships: the vector from “man” to “woman” is roughly the vector from “king” to “queen”.
In a Transformer, every token starts as a learned embedding, and each layer refines it using context. The output vectors are contextual: “bank” in “river bank” and “bank account” gets different vectors.
Embeddings also exist for images, audio, users and products, and you can compare any of them with cosine similarity. Nearest-neighbor search over embeddings (see k-nearest neighbors) is the retrieval engine inside RAG.
The math
Cosine similarity between vectors and :
1 means same direction, 0 unrelated, −1 opposite.
Everyday use cases
- Case 01
Semantic search
Find documents that mean the same thing as your query, even with different words.
- Case 02
Photo search
Typing "dog on a beach" finds matching photos by comparing text and image embeddings.
- Case 03
Recommendations
Songs or products with nearby embeddings are suggested together.
Strengths, weaknesses and when to use it
Strengths
- Turns fuzzy notions like "meaning" into geometry you can compute with.
- One embedding model serves search, clustering, classification and recommendation.
Weaknesses
- Absorbs biases present in the training data.
- Individual dimensions are usually not interpretable.
When to use itWhenever you need to measure similarity between texts, images or items.
Compare with
Check yourself
- Q01
If two words have embeddings that are close together, what does that suggest?
Show answer
B: They are used in similar contexts and likely have related meanings
- Q02
What is the famous word2vec example of vector arithmetic?
Show answer
A: king − man + woman ≈ queen