How does an AI system know that:
“King” and “Queen” are related?
How does a search engine understand that:
“How do I reset my password?”
and
“I forgot my login credentials”
are talking about a similar problem?
And how can an AI application search through thousands of documents and find information based on meaning, rather than simply matching exact keywords?
The answer involves one of the most important concepts in modern AI:
Embeddings allow computers to represent complex information as numerical vectors.
Instead of treating:
"apple"
as merely a sequence of characters, an AI system can represent it as something like:
[0.21, -0.73, 0.44, 0.91, ...]
The actual vector may contain hundreds or thousands of dimensions.
Those numbers aren't individually meaningful to humans.
But together, they can encode useful relationships learned from data.
This gives us a powerful idea:
Human Information
↓
Numerical Representation
↓
Vector
↓
Mathematical Operations
↓
Similarity / Retrieval / Prediction
Embeddings are foundational to many modern AI applications, including:
Let's understand them from the ground up.
An embedding is a numerical representation of an object or piece of information in a vector space, designed so that useful relationships between objects can be captured geometrically.
The object could be:
For example:
"Python programming"
↓
Embedding Model
↓
[0.12, -0.44, 0.81, 0.03, ...]
The result is a vector.
Computers fundamentally operate on numerical representations.
Suppose we have:
Dog
Cat
Car
Apple
Programming
A computer cannot directly perform standard mathematical operations on these concepts as words.
We need representations.
Embeddings provide a way to map them into a numerical space:
Dog → Vector A
Cat → Vector B
Car → Vector C
Programming → Vector D
Now mathematical techniques can compare those vectors.
A vector is simply an ordered collection of numbers.
For example:
[2, 5]
is a two-dimensional vector.
Another example:
[0.2, -0.7, 0.4]
is a three-dimensional vector.
An embedding might have hundreds or thousands of dimensions:
[
0.124,
-0.582,
0.731,
...
]
Humans cannot easily visualize such high-dimensional spaces.
Mathematics can still operate on them.
Imagine a very simple two-dimensional embedding space.
Suppose we represent concepts using:
Dog = [2, 3]
Cat = [2, 4]
Car = [8, 1]
Visually:
Cat ●
|
Dog ●
Car ●
Dog and Cat are relatively close.
Car is farther away.
A well-trained embedding space can organize representations so that useful relationships are reflected in distances or directions.
This is a common misconception.
Suppose an embedding is:
[0.2, 0.7, -0.3]
It would be wrong to automatically say:
0.2 = intelligence
0.7 = animal
-0.3 = emotion
Usually, individual dimensions don't have such simple human-interpretable meanings.
The information is often distributed across many dimensions.
Let's say we want to represent:
"coffee"
An embedding model transforms it into a vector:
coffee
↓
Embedding Model
↓
[0.18, -0.42, 0.73, 0.11, ...]
Now consider:
tea
It may produce another vector:
tea
↓
[0.21, -0.39, 0.70, 0.08, ...]
If the embedding model has learned useful semantic relationships, these vectors may be relatively close.
This is where embeddings become powerful.
Consider:
"I love programming."
and:
"Software development is my passion."
They use different words.
Keyword matching may not consider them identical.
But their meanings are related.
A semantic embedding model can map both into nearby regions of vector space.
Conceptually:
"I love programming."
●
●
"Software development is my passion."
The vectors can be similar even when the exact words differ.
Imagine every piece of information becomes a point in a huge mathematical space.
Programming ●
● Code
● Software
● Apple
● Banana
● Car
In reality, the space may have hundreds or thousands of dimensions.
The visualization above is only an intuition.
A useful embedding space may organize concepts approximately like:
Dog ─── Cat ─── Puppy
Car ─── Truck ─── Bus
Python ─── JavaScript ─── Rust
The exact geometry depends on the embedding model and task.
The important concept is:
Vector geometry can encode useful relationships.
Once information has been converted into vectors, we need a way to compare them.
Common approaches include:
Cosine similarity measures the angle between two vectors.
The formula is:
cos(θ) = (A · B) / (||A|| ||B||)
Conceptually:
Similar direction
↓
Higher cosine similarity
and:
Different direction
↓
Lower cosine similarity
For many embedding-search applications, cosine similarity is a useful measure of semantic closeness.
Suppose:
A = [1, 2]
B = [2, 4]
These vectors point in the same direction.
So their cosine similarity is:
1
They have identical direction even though their magnitudes differ.
Another approach is Euclidean distance.
For two vectors:
A = [x₁, y₁]
B = [x₂, y₂]
the distance is:
d = √((x₂-x₁)² + (y₂-y₁)²)
Smaller distance means the points are closer geometrically.
They answer related but different geometric questions.
How similar are the directions?
How far apart are the points?
Which metric works best depends on the embedding model, normalization, and retrieval setup.
One of the earliest major applications of embeddings was representing words as vectors.
Traditional methods treated words more independently.
Embedding methods attempted to represent words based on their relationships in language.
Examples of historically important approaches include:
These approaches helped demonstrate how vector representations could capture useful linguistic relationships.
Word2Vec helped popularize the idea that semantic relationships can emerge from training a model on word contexts.
A famous conceptual example is:
King - Man + Woman ≈ Queen
This does not mean the model literally stores a dictionary equation like this.
Rather, certain relationships can emerge approximately in the learned vector geometry.
This was a landmark result in representation learning.
Words aren't always enough.
Consider:
"I went to the bank."
The meaning could depend on context.
We may want to represent an entire sentence.
A sentence embedding model converts:
Sentence
↓
Embedding Model
↓
Vector
For example:
"How can I reset my password?"
becomes:
[0.13, -0.82, 0.34, ...]
The same idea can be applied to longer documents.
Imagine a company has:
10,000 PDF documents
Each document can be converted into an embedding.
Document 1 → Vector 1
Document 2 → Vector 2
Document 3 → Vector 3
...
Document 10,000 → Vector 10,000
Now we can build semantic search over the collection.
Embeddings aren't limited to text.
An image can also be transformed into a vector.
Image
↓
Vision Model
↓
Embedding
↓
Vector
Now two visually or semantically related images can potentially have similar representations.
This enables:
Modern AI can work with multiple modalities:
Text
Image
Audio
Video
Code
A multimodal embedding system can represent different types of information in compatible or related vector spaces.
For example:
Image of a dog
↓
Embedding
↑
↓
"golden retriever"
↓
Embedding
If the system is trained appropriately, the representations can be related.
This makes cross-modal search possible.
This is the most important question.
An embedding isn't simply manually designed.
It is generally learned from data.
A neural network processes examples.
A training objective encourages representations that are useful for the task.
Over many training steps:
Data
↓
Neural Network
↓
Representation
↓
Loss
↓
Backpropagation
↓
Parameter Update
↓
Better Representation
Eventually, the model can produce useful embeddings.
Remember our previous article?
A neural network transforms information layer by layer.
Conceptually:
Input
↓
Layer 1
↓
Layer 2
↓
Layer 3
↓
Representation
That internal representation can sometimes be used as an embedding.
In modern systems, the exact embedding-generation mechanism depends on the architecture and model design.
Large Language Models work with numerical representations throughout their computation.
At a high level:
Text
↓
Tokens
↓
Token Representations
↓
Transformer
↓
Contextual Representations
↓
Output
There is an important distinction here:
The internal representations used inside an LLM are not automatically the same thing as a dedicated embedding model's output.
Embedding models are often specifically trained or designed to produce vectors useful for retrieval, similarity, clustering, or other downstream tasks.
These concepts are often confused.
A token is a unit used by a language model's tokenizer.
For example:
"programming"
might be represented as one or more tokens depending on the tokenizer.
An embedding is a numerical vector representing a token, sentence, document, image, or other object.
So:
Text
↓
Tokens
↓
Vectors / Representations
Tokens and embeddings are related, but they aren't the same thing.
Before dense embeddings, one-hot encoding was commonly used for categorical representations.
Suppose our vocabulary is:
Cat
Dog
Car
One-hot encoding could represent them as:
Cat = [1, 0, 0]
Dog = [0, 1, 0]
Car = [0, 0, 1]
Notice something important:
The vectors don't inherently express that:
Cat
is more semantically related to:
Dog
than to:
Car
Dense learned embeddings can capture such relationships.
Now we reach one of the most important applications.
Suppose you have:
1,000,000 documents
You generate an embedding for every document.
Then store those vectors in a vector database or vector-search system.
Examples of technologies used for vector search include:
The system can then search for vectors that are close to a query vector.
Traditional keyword search might work like:
Query
↓
Find exact / related keywords
↓
Results
Semantic search can work like:
Query
↓
Embedding Model
↓
Query Vector
↓
Vector Search
↓
Similar Documents
This means the system can retrieve content based on semantic relationships rather than requiring exact keyword matches.
Suppose your knowledge base contains:
"To change your password, open Account Settings."
"Your profile settings allow you to update personal information."
"Contact support for billing problems."
User asks:
"I forgot my login password. What should I do?"
Even though the document might not contain the exact phrase:
"forgot my login password"
the embedding can capture the relationship to:
"change your password"
and retrieve the relevant document.
This brings us to one of the hottest applications in modern AI:
or:
A simplified RAG system works like:
User Question
↓
Create Query Embedding
↓
Vector Search
↓
Retrieve Relevant Documents
↓
Send Context to LLM
↓
Generate Answer
Embeddings provide the retrieval mechanism.
The LLM provides the generation mechanism.
Let's imagine a company has internal documentation.
PDFs
Web Pages
Docs
FAQs
Databases
Large documents are divided into smaller chunks.
Document
↓
Chunk 1
Chunk 2
Chunk 3
...
Chunk 1 → Vector 1
Chunk 2 → Vector 2
Chunk 3 → Vector 3
Vector Database
"What is the refund policy?"
Question
↓
Query Embedding
Query Vector
↓
Similarity Search
↓
Top Relevant Chunks
Question + Retrieved Context
↓
LLM
↓
Answer
Without embeddings, semantic retrieval becomes much harder.
Consider:
Question:
"Can I get my money back?"
Document:
"Customers may request a refund within 30 days."
Keyword overlap might be limited.
Semantic embeddings can help recognize that these statements are related.
Imagine you're building an AI assistant for a university.
Your database contains:
Admission Rules
Fee Structure
Exam Schedule
Attendance Policy
Hostel Rules
Scholarship Guidelines
Faculty Information
A student asks:
"How many classes can I miss before there is an attendance issue?"
The system:
Question
↓
Embedding
↓
Vector Search
↓
Attendance Policy
↓
LLM
↓
Answer
The AI doesn't need to put the entire university database into every prompt.
It retrieves relevant information first.
Embeddings can also power recommendation systems.
Suppose users interact with products.
You can create representations for:
User
Product
Then compare them.
Conceptually:
User Vector
↓
Similarity Search
↓
Similar Product Vectors
↓
Recommendations
This idea is used in many forms across modern recommendation systems.
Suppose your database contains:
"How do I reset my password?"
"Where can I change my login password?"
"Password reset instructions"
Their embeddings may be close.
You can use similarity thresholds to flag potentially duplicate or highly related content.
You can also group vectors.
For example:
Vectors
↓
Clustering Algorithm
↓
Groups
Your support tickets might automatically cluster into:
Cluster 1 → Login Issues
Cluster 2 → Billing
Cluster 3 → Technical Errors
Cluster 4 → Account Management
This can help organizations understand large datasets.
An embedding could have:
128 dimensions
or:
384
or:
768
or:
1536
or many other sizes.
But bigger isn't automatically better.
A useful embedding depends on:
A good embedding should capture relationships relevant to the task.
For semantic search:
Similar meaning
↓
Similar vectors
For image retrieval:
Similar visual / semantic content
↓
Similar representations
For recommendations:
Similar user preferences
↓
Useful proximity in representation space
The definition of "good" depends heavily on the downstream task.
A common mistake is thinking:
More dimensions = Better AI
Not necessarily.
A 1536-dimensional embedding isn't automatically better than a 768-dimensional embedding.
You should evaluate:
Retrieval Quality
+
Latency
+
Storage
+
Cost
+
Task Performance
Imagine:
10,000 vectors
A simple comparison against every vector may be manageable.
But imagine:
1 billion vectors
Comparing the query against every single vector becomes expensive.
This is why vector-search systems use specialized techniques such as:
The goal is to find highly relevant vectors without exhaustively comparing against every stored vector.
Compare the query against every vector.
Query
↓
All vectors
↓
Calculate similarities
↓
Top results
Potentially expensive at large scale.
Use an index to search efficiently.
Query
↓
Vector Index
↓
Likely nearest neighbors
↓
Top results
You trade some exactness for much better scalability.
A poor embedding model can produce poor retrieval results.
For example, if the model doesn't understand your domain well:
Query
↓
Poor representation
↓
Wrong nearest neighbors
↓
Bad RAG context
↓
Bad answer
This is why evaluating embedding quality is essential.
They're numerical vectors, but learned embeddings are produced by models trained to capture useful patterns.
Usually, individual dimensions don't map cleanly to human concepts.
Tokens are discrete units.
Embeddings are numerical vector representations.
Vector dimension alone doesn't determine quality.
Even an excellent embedding model can retrieve poorly if documents are split into inappropriate chunks.
Two vectors can be highly similar while the underlying information is still incorrect, outdated, or irrelevant.
Similarity is a retrieval signal—not a guarantee of truth.
An embedding is a numerical vector representation of information that allows useful relationships to be modeled mathematically.
They allow systems to compare, search, cluster, recommend, and retrieve information using vector relationships.
No. Tokens are units produced by tokenization. Embeddings are numerical representations.
A vector database or vector-search system stores and retrieves vector representations efficiently, often using similarity search.
Semantic search retrieves information based on meaning and learned representations rather than relying solely on exact keyword matching.
Cosine similarity measures the cosine of the angle between two vectors and is commonly used to compare embedding vectors.
Embeddings convert document chunks and user queries into vectors so that relevant context can be retrieved through similarity search.
Yes. Vision models can produce vector representations of images.
Yes. Audio and speech models can produce embeddings representing audio content.
Yes. Code can be represented as vectors for tasks such as semantic code search, clustering, and retrieval.
Modern neural language models use learned numerical representations throughout their computation. Dedicated embedding models are also commonly used for search and retrieval applications.
One of the biggest challenges in AI is converting the messy world of human information into something a computer can mathematically process.
Embeddings provide an elegant solution.
They transform:
Words
Sentences
Documents
Images
Audio
Code
Products
into:
Vectors
And once information becomes vectors, we can perform operations such as:
Compare
Search
Rank
Cluster
Recommend
Retrieve
This creates a bridge between human information and mathematical computation.
The progression looks like this:
Human Information
↓
Neural Network
↓
Embedding
↓
Vector Space
↓
Similarity Search
↓
Relevant Information
↓
AI Application
And this is precisely why embeddings became so important to modern AI.
They are one of the technologies connecting Machine Learning models to real-world knowledge systems.
But embeddings alone don't explain how modern AI understands context.
For that, we need to go deeper.
Pixels to Perfection Design that Impresses