Learn AI · Foundations
Embeddings Explained
Embeddings turn text into numbers that capture meaning. They power search, RAG, recommendations, and clustering — here's how.
Key takeaways
- 1Embeddings are vectors — typically 384, 768, 1024, 1536, or 3072 numbers.
- 2Cosine similarity is the standard 'how close are these two?' metric.
- 3Don't mix embedding models — vectors from different models aren't compatible.
- 4Embeddings don't capture recency, negation, or numerical precision well.
- 5For most apps in 2026, text-embedding-3-small or voyage-3 is a great starting point.
The idea in one image
An embedding is a list of numbers — typically 384, 768, 1536, or 3072 of them — that represents a piece of text as a point in high-dimensional space. Texts with similar meaning end up close together; unrelated texts end up far apart.
"How do I reset my password?" → [0.12, -0.43, 0.88, ...]
"I forgot my login credentials" → [0.14, -0.41, 0.85, ...] ← very close
"What's a good pasta recipe?" → [-0.61, 0.22, 0.04, ...] ← far away
Computing how close two embeddings are (cosine similarity) is the primitive that drives semantic search.
Where they come from
You feed text into an embedding model — text-embedding-3-small (OpenAI), voyage-3 (Voyage), embed-english-v3 (Cohere), or a local sentence-transformers model — and out comes the vector.
What they're used for
- Semantic search — find documents by meaning, not keyword match.
- RAG — retrieve relevant context for an LLM.
- Clustering — group similar tickets, products, posts.
- Classification — train a tiny model on top of embeddings instead of fine-tuning the LLM.
- Recommendations — "items similar to this one."
- Deduplication — find near-duplicate content.
Picking a model
Three things matter:
- Quality on retrieval benchmarks (MTEB is the standard leaderboard).
- Dimension — bigger isn't always better; 1024-dim often beats 3072-dim per dollar.
- Cost — embedding millions of documents adds up fast.
For most apps in 2026: text-embedding-3-small or voyage-3-lite is a great starting point. Local options like bge-small-en-v1.5 are free and surprisingly strong.
Cosine similarity in one line
The standard metric is the cosine of the angle between two vectors:
similarity = (a · b) / (|a| * |b|)
Most embedding APIs return normalized vectors (|v| = 1), so cosine similarity reduces to the dot product.
Gotchas
- Don't mix models. Embeddings from model A and model B aren't comparable. If you switch, re-embed everything.
- Embeddings don't know recency. "Latest news" and "news from 2010" can look identical in vector space.
- Long documents lose signal. Embed chunks, not whole books.
- Negation breaks them. "I love coffee" and "I don't love coffee" are dangerously close.
- Numbers and dates get embedded as text — exact arithmetic is unreliable. Filter on metadata instead.
Embeddings are simple, fast, and shockingly useful. They're the single best return-on-investment primitive in applied AI.
Common misconceptions
The wrong-but-common takes worth correcting.
Myth
Bigger embeddings are always more accurate.
Reality
1024-dim often beats 3072-dim at half the cost. Pick by retrieval benchmark (MTEB), not by dimension count.
Myth
Embeddings understand negation.
Reality
'I love coffee' and 'I don't love coffee' end up dangerously close in vector space. If negation matters, you need additional logic.
Myth
Embeddings are domain-agnostic.
Reality
Models trained on general web text underperform on highly technical corpora (medicine, law, niche code). Specialized models or fine-tuning may be needed.
Real-world use cases
Semantic search
Find documents by meaning instead of by keyword match.
RAG
Retrieve the right chunks of context to give an LLM at query time.
Open
Clustering
Group similar tickets, posts, products by their embedding — useful for tagging, deduplication, and topic discovery.
Classification
Train a tiny model on top of embeddings to classify text into your custom categories — cheaper than fine-tuning an LLM.
Frequently asked questions
Related on AIKnowHub
Concept
RAG Explained
Retrieval-Augmented Generation is how you give LLMs access to your own data without retraining them. Here's how it actually works.
Concept
Vector Databases Explained
What vector databases actually do, when you need one, and what the real tradeoffs between Pinecone, Weaviate, Qdrant, and pgvector look like.
Concept
What is an LLM?
Large Language Models, explained from first principles — what they are, how they predict tokens, and where the magic and limits come from.
Workflow
Build an AI Research Assistant
A research agent that takes a question, searches the web, reads sources, and produces a cited briefing.
Comparison
Best Embedding Model
OpenAI vs Voyage vs Cohere vs open-source — which embedding model wins on quality, cost, and ecosystem in 2026?