The Core Idea
An embedding is a list of numbers (a vector) that represents the meaning of a piece of text. Texts with similar meanings get similar vectors. "How do I return a product?" and "What is the refund process?" would have vectors that are close together, even though they share few words.
Why RAG Needs Embeddings
Traditional keyword search fails when users use different words than the documents. Embeddings enable semantic search — finding text by meaning, not exact word matches. This is the foundation of the entire retrieval step in RAG.
# What an embedding looks like
text = "How do I return a product?"
vector = embed(text)
# → [0.023, -0.041, 0.087, ..., -0.012]
# ^--- 1536 numbers (for text-embedding-3-small)
# ^--- 3072 numbers (for text-embedding-3-large)
# Similar texts → similar vectors
"refund process" → cosine_sim = 0.92
"weather today" → cosine_sim = 0.11
Embeddings are the bridge between text and math. They let you use mathematical operations (distance, similarity) on natural language. Without embeddings, there is no semantic search, and without semantic search, RAG falls back to keyword matching.