What Are Embeddings? Turning Meaning Into Numbers

Discover how AI converts words into numbers, why that lets machines understand meaning, and why this is the quiet engine behind search, recommendations, and RAG.

The Moment I Stopped Skipping This Topic

For a long time, every time I read an article about AI and hit the word "embeddings," I quietly moved on. It sounded like graduate-level math, and I figured it wasn't something I needed to actually understand to use AI tools. I was wrong about that. Once I finally sat with the concept for an afternoon, I realized embeddings are the quiet engine running underneath almost everything interesting in AI — search, recommendations, RAG pipelines, semantic similarity. Once you get it, you see it everywhere.

The good news: you don't need any math to understand what embeddings are or why they matter. You just need a decent mental model. That's what this article is.

What Is an Embedding, Actually?

An embedding is a list of numbers that represents the meaning of a piece of text. That's really it. When you feed a sentence into an embedding model, it spits out something like a long list of decimal numbers — maybe 384 of them, maybe 1536, depending on the model. That list is called a vector.

Here's a tiny made-up example to make it concrete. Imagine we had a super simple embedding model that represented every word using just three numbers:

concept
# Imaginary 3-number embeddings
"dog" → [0.9, 0.1, 0.4]
"puppy" → [0.87, 0.12, 0.41]
"cat" → [0.85, 0.15, 0.38]
"cloud" → [0.1, 0.9, 0.05]

Notice that "dog" and "puppy" have very similar numbers. "cat" is close too — it's also an animal. "cloud" is completely different. The numbers don't describe the word's spelling or sound — they describe its meaning as the model understands it from having read enormous amounts of text.

Real embeddings use hundreds or thousands of numbers instead of three, which lets them capture much more nuance. But the idea is identical.

Why "Close Together" Means "Similar Meaning"

Here's where the geometry comes in, and it's actually kind of beautiful. Because each embedding is a list of numbers, you can think of it as a point in space. If you have three numbers, it's a point in 3D space. With 1536 numbers, it's a point in 1536-dimensional space — which you can't visualize, but the math works exactly the same way.

The key insight is this: words and sentences that mean similar things end up as points that are close together in that space. "Happy" and "joyful" are neighbors. "Paris" and "France" are close. "Software bug" and "code error" end up in roughly the same neighborhood. This isn't hand-coded — it emerges naturally from training on huge amounts of text where these words appear in similar contexts.

To measure how close two embeddings are, AI systems usually use something called cosine similarity — basically the angle between two vectors. An angle of zero means they're pointing in the exact same direction (identical meaning). A large angle means they're far apart conceptually. You don't need to do this math yourself; libraries handle it. But knowing it's just "how close are these two points?" is enough.

The Classic Example

The most famous demonstration of embedding geometry is this: the vector for "king" minus the vector for "man" plus the vector for "woman" lands very close to the vector for "queen." Meaning has actual arithmetic structure in this space. That blew my mind the first time I saw it.

What This Actually Unlocks

OK so why does any of this matter? Because once you can represent meaning as numbers, a whole category of problems becomes solvable that wasn't before. Let me walk through the big ones.

Semantic search. Regular keyword search looks for exact word matches. If you search for "broken login" but the document says "authentication failure," a keyword search misses it. Semantic search converts both your query and the document into embeddings, then finds documents whose embeddings are close to your query's embedding. Same meaning, different words — found. This is also why I wrote a whole separate article on semantic search if you want to go deeper there.

RAG (Retrieval-Augmented Generation). This is probably where most people encounter embeddings without realizing it. When you build a RAG pipeline — where an AI can search through your own documents — embeddings are how the retrieval part works. Your documents get converted to embeddings and stored in a vector database. When you ask a question, your question becomes an embedding, the system finds the closest document chunks, and passes them to the language model as context. No embeddings, no RAG.

Recommendations. "Users who liked this also liked..." is often embeddings at work. Items get embedded, users get embedded based on their behavior, and the system recommends items that are close in embedding space to things you've already engaged with.

Clustering and classification. If you have a thousand customer support tickets and want to group them by topic automatically, you embed each ticket and then cluster the points in vector space. Similar complaints land close together and form natural groups.

How to Actually Generate an Embedding

This part is more approachable than you'd think. Let me show you what calling an embedding API looks like. Here's a Python example using OpenAI's embedding model:

python
# pip install openai
from openai import OpenAI

client = OpenAI()

# Generate an embedding for a piece of text
response = client.embeddings.create(
model="text-embedding-3-small",
input="The dog ran across the park"
)

vector = response.data[0].embedding
# vector is now a list of 1536 numbers
print(f"Dimensions: {len(vector)}")
# → Dimensions: 1536

That's it. You hand in text, you get back a list of numbers. The model has done all the hard work of converting meaning into geometry. Now you can store that vector, compare it to other vectors, search with it, whatever you need.

To compare two embeddings for similarity, you'd typically do something like this:

python
import numpy as np

def cosine_similarity(a, b):
a = np.array(a)
b = np.array(b)
return np.dot(a, b) / (np.linalg.norm(a) * np.linalg.norm(b))

# 1.0 = identical meaning, 0.0 = unrelated
score = cosine_similarity(vector_a, vector_b)
print(f"Similarity: {score:.3f}")

What Embeddings Don't Capture

Worth being honest about the limits. Embeddings are powerful but not magic. A few things to keep in mind:

Context matters a lot. The word "bank" in "river bank" versus "savings bank" might embed differently depending on the model, but older or simpler models sometimes struggle with this. Modern models are much better at context-sensitive embeddings.

They lose the original text. An embedding is a compressed representation. You can compare embeddings and find similar ones, but you can't reconstruct the original text from a vector alone. They're a one-way transformation.

Different models produce incompatible embeddings. Vectors from OpenAI's model and vectors from a different model aren't comparable. If you switch embedding models, you need to re-embed everything. This is worth knowing before you build something at scale.

Choosing an Embedding Model

If you're just experimenting, text-embedding-3-small from OpenAI is a great starting point — cheap, fast, and plenty capable. When you're ready to think more carefully about dimensions, cost, and quality tradeoffs, check out the article on choosing an embedding model.

The Mental Model to Carry Forward

Here's the image I keep in my head. Imagine a huge, dark library where every book, every sentence, every phrase exists as a point of light floating in space. Books about cooking glow close together in one corner. Legal documents cluster in another. Technical documentation fills a different region. When you search for something, your query becomes its own point of light, and the system finds the nearest glowing dots — the content closest in meaning.

That's embeddings. Text turned into coordinates. Meaning turned into geometry. And the reason this matters for you as someone learning AI tools: almost every interesting AI application — RAG, semantic search, memory systems, recommendation — runs on this foundation. You don't need to build embedding systems from scratch right now, but understanding that they exist and what they do will make every other AI concept you encounter click faster.

When I finally got this, it felt like someone had turned on a light in a room I didn't know was dark. I hope it does the same for you.

Keep going

More tutorials in this category, or explore the full field guide.

More Getting Started Guides Official Docs ↗