โ† Back to Workshop Hub MODULE 1 ยท EMBEDDINGS

From Tokens to Meaning

How AI turns words into numbers that capture meaning โ€” so "vendor proposal" and "supplier quote" understand each other. Interactive 3D explorer with healthcare terms.

๐Ÿ“– ~10 min read ๐ŸŽฎ Interactive 3D ๐Ÿฅ Healthcare Context L100 Foundational

๐Ÿค” The Problem: Numbers Don't Have Meaning

After tokenisation, your text is just a list of token IDs โ€” random numbers from a vocabulary table. Token 42 might mean "vendor", token 9001 might mean "supplier". These numbers are identifiers, not meaning.

For an LLM to understand that a "vendor" and a "supplier" are similar concepts, those words need to be represented in a way where similar things have similar numbers. That's what embeddings do.

๐Ÿฅ Healthcare Analogy
A token ID is like a hospital's file number โ€” Patient #4827, Vendor #1138. Useful for filing, useless for anything else. Two patients with consecutive file numbers might have nothing in common. We need a representation where Patient #4827 sits near other diabetic patients, not next to whoever happened to register before them.
๐Ÿ”ข

Token IDs = Identifiers

"vendor" โ†’ 42, "supplier" โ†’ 9001. The numbers themselves are arbitrary lookup positions. No meaning embedded.

๐Ÿ“Š

Embeddings = Coordinates

A list of 1,536 numbers per word. Similar words land at nearby coordinates in this high-dimensional space.

๐Ÿ“

Distance = Similarity

"vendor" and "supplier" might be 0.08 apart. "vendor" and "scalpel" might be 0.94 apart. Distance reveals semantic closeness.

๐Ÿง 

Learned, Not Hand-Coded

The model figures out positions automatically by reading billions of sentences. Words used in similar contexts end up close together.

๐Ÿ’ก
Why this is huge for healthcare: When a staff member asks AgentSea about "leave entitlement", embeddings let the system find your policy on "annual leave allowance" even though the words are different. Without embeddings, AI would only match exact words โ€” useless for real-world queries.

๐ŸŽฏ What Embeddings Make Possible

Every "smart" feature you've seen in AgentSea or any modern AI relies on embeddings underneath:

๐Ÿ”ข The Naive Approach: One-Hot Encoding

Before embeddings, you'd represent each word as a giant list of zeros with a single 1 at the word's position. If your vocabulary has 50,000 words, every word is a 50,000-long vector with 49,999 zeros and one 1.

"vendor"
0001000000 โ€ฆ 49,990 more zeros
"supplier"
0000001000 โ€ฆ 49,990 more zeros
"scalpel"
0100000000 โ€ฆ 49,990 more zeros

Why one-hot is bad

๐Ÿ“ฆ

Massively Wasteful

Storing 50,000 numbers per word, almost all zeros. Multiply that by every word in a 30-page document.

๐Ÿšซ

Zero Similarity Info

"vendor" and "supplier" look as different from each other as "vendor" and "scalpel". The math says they're equally unrelated.

๐Ÿ†•

Can't Handle New Words

What about "AgentSea"? "MOH circular"? Adding a word means resizing every vector โ€” impractical at scale.

๐Ÿ“Š The Better Way: Dense Embeddings

Instead of 50,000 mostly-zero numbers, use a few hundred (typically 768 or 1,536) decimal numbers โ€” and let the model learn what each dimension means.

"vendor"
0.42-0.130.880.07-0.550.210.93-0.34 โ€ฆ 1,528 more
"supplier"
0.39-0.180.850.11-0.520.240.91-0.31 โ€ฆ 1,528 more
"scalpel"
-0.710.62-0.04-0.880.45-0.770.120.66 โ€ฆ 1,528 more

Notice: The "vendor" and "supplier" rows are nearly identical across all 1,536 dimensions. The "scalpel" row is wildly different. The numbers themselves don't mean anything to humans โ€” but the model has arranged them so that similar concepts have similar coordinates.

๐Ÿ’ก
Where do these numbers come from? The model trained on billions of sentences. It noticed: when "vendor" appears, words like "proposal", "contract", "SLA", "pricing" tend to nearby. Same context for "supplier". So it learned to place them at similar coordinates. This is called distributional semantics โ€” "you shall know a word by the company it keeps."

๐ŸŽฎ 3D Embedding Space Explorer

Real embeddings live in 768 or 1,536 dimensions. This 3D projection shows healthcare terms โ€” drag to rotate, scroll to zoom, click any word. Notice how related concepts cluster, while unrelated words sit far away.

๐ŸŽฎ 3D Embedding Space Explorer
Drag to rotate ยท Scroll to zoom ยท Click a word
๐ŸŽ“
Procurement words cluster tightly (purple). Finance is nearby (cyan). Clinical sits far away (pink). Unrelated words (grey) are pushed even further. This is how AgentSea understands "vendor proposal" relates to "supplier quote" โ€” but not to "scalpel".
๐Ÿ–ฑ๏ธ drag to rotate
โ†• scroll to zoom
๐Ÿ‘† click word
๐Ÿ’ก
This is a 3D simplification. Real embeddings live in 1,536+ dimensions. We use techniques like t-SNE or UMAP to project down to 3D so humans can see them. The relative positions stay roughly the same โ€” what's near each other in high-D is near each other in 3D.

๐Ÿ“ Similarity = Distance Between Vectors

The whole point of embeddings is that distance reveals meaning. There are 3 common ways to measure how close two embeddings are:

MetricHow it worksWhen to use
Cosine similarity โญAngle between vectors. Range: โˆ’1 (opposite) to 1 (identical).Default for text embeddings. Used by AgentSea.
Euclidean distanceStraight-line distance. 0 = identical.When magnitude matters (rare for text).
Dot productMultiply & sum. Higher = more similar.Faster compute when vectors are normalised.

Healthcare similarity examples

Cosine similarity scores between healthcare terms (range 0โ€“1, higher = more similar):

vendor โ†” supplier
0.92
budget โ†” expenditure
0.88
leave entitlement โ†” annual leave allowance
0.84
vendor โ†” contract
0.71
PDPA โ†” data protection
0.79
vendor โ†” patient
0.18
vendor โ†” scalpel
0.08
๐Ÿ’ก
For semantic search: AgentSea computes the embedding of your question, then finds the document chunks with the highest cosine similarity. That's how it answers "what's our work-from-home policy?" by retrieving the chunk titled "Telecommuting guidelines" โ€” same meaning, different words.

๐Ÿ”— Where Embeddings Live in AgentSea

You don't see embeddings directly when using AgentSea โ€” but they're working behind the scenes for several features. Here's where:

๐Ÿ”

Document Search

When you upload a vendor proposal and ask questions, AgentSea embeds your question and finds matching chunks via cosine similarity.

๐Ÿ“š

Knowledge Spaces (Phase 1B)

August 2026: SharePoint integration will let you embed your entire policy library, then query it semantically.

๐Ÿค–

Skill Selection

When AgentSea picks which skill to use (Doc Analysis vs Doc Gen vs Outlook), it's matching your intent embedding against skill descriptions.

๐Ÿ”

RAG (next explainer)

Retrieval-Augmented Generation is the dominant pattern for grounding AI answers in your documents โ€” entirely powered by embeddings.

What you should remember

โญ๏ธ Up Next: The Transformer

Now that the model has tokens (with embeddings), how does it actually think about them and produce a response? That's the transformer architecture โ€” covered in the next explainer.

๐Ÿง  Continue to The Transformer โ†’