DEEP DIVE · EMBEDDINGS

Meaning as Geometry

Embeddings turn text into vectors — points in space — so that similar ideas sit close together. It's how a model knows "goods not received" and "item never arrived" mean nearly the same thing, and it's the engine behind semantic search and RAG.

📍 Vectors🧭 Interactive map🔍 Semantic search

📍 Text as Points in Space

An embedding is a list of numbers — a vector — that captures the meaning of a piece of text. Words and phrases with similar meaning get similar vectors, so they land near each other in space. That geometry is what lets a computer compare meaning, not just match keywords.

🧭The key intuition: closeness = similarity of meaning. "Chargeback" sits near "representment"; "PayNow" sits near "MDR" — and far from both.
🔢

Meaning becomes numbers

An embeddings model maps text to a vector of hundreds of numbers — coordinates in a high-dimensional space.

📐

Distance = similarity

Vectors close together mean similar things; far apart means different. Different words, same meaning still land close.

🔍

Beyond keywords

Search by meaning, not exact words — "item never arrived" finds a "goods not received" clause.

🧱

The base for RAG

RAG embeds your documents and the query, then retrieves the chunks whose vectors are nearest.

On the next tab you can explore a (simplified) 2-D map of payments concepts. In reality vectors have hundreds of dimensions — but the idea is the same: related terms cluster together.

🎮 Explore the Embedding Space in 3D

This is a 3-D projection of a high-dimensional embedding space, grounded in payments vocabulary. Terms that appear in similar contexts cluster together. Drag to rotate, scroll to zoom, and click any word to light up its nearest neighbours — exactly what a semantic search (and RAG) would retrieve.

The layout is illustrative — positions are hand-placed so the clustering is easy to see. Real embeddings live in hundreds of dimensions; here we project to three.

🧠 3D Embedding Space Explorer

Drag to rotate · scroll to zoom · click a word
🎓
Pick a vocabulary set below, then drag to rotate the space. Click any word to highlight its five nearest neighbours in 3D.
← operational · · · conceptual → ← concrete · · · abstract → depth: specificity →
🖱 drag to rotate
⚲ scroll to zoom
👆 click a word
Why click a word? This is how RAG retrieval works. When a merchant asks a question, the assistant embeds it, finds the nearest document-chunk embeddings, and uses those as grounded context. Click "chargeback" — the connected words are what a RAG system would pull. Notice "banana" never shows up as a neighbour.
Disputes
Risk / Fraud
Fees / Settlement
Onboarding / KYC
Off-domain

🔍 Cosine similarity calculator

Pick two words to compute their cosine similarity — the standard measure of how "close" two embeddings are. The pair is also drawn as a line in the 3D space above.

Select two words above
0.8 – 1.0Very similar
0.3 – 0.7Somewhat related
0.0 – 0.2Unrelated
Illustrative: scores are derived from the hand-placed 3D positions, not a live embeddings model — but the behaviour (same-cluster pairs score high, cross-cluster pairs score low) is exactly how real cosine similarity works.

📐 Measuring Similarity

Once text is a vector, "how similar are these two meanings?" becomes a geometry question. The usual measure is cosine similarity — the angle between two vectors, scored from -1 (opposite) through 0 (unrelated) to 1 (identical meaning).

📏

Cosine similarity

Compares the direction of two vectors. Same direction = same meaning (≈1); perpendicular = unrelated (≈0).

🎯

Nearest neighbours

To find relevant text, score the query vector against all stored vectors and take the highest.

Fast at scale

A vector database indexes millions of vectors so nearest-neighbour search stays fast.

Cosine vs. other distance measures

MetricWhat it measuresRangeBest for
Cosine similarityAngle between two vectors (direction)-1 to 1Comparing meaning regardless of vector length
Euclidean distanceStraight-line distance between points0 to ∞When absolute magnitude matters
Dot productDirection and magnitude combined-∞ to ∞Fast approximate similarity at scale
Why cosine? It's scale-invariant — two vectors pointing the same way score 1 even if one is much "longer". For meaning, direction matters more than magnitude, which is why cosine similarity is the default for embeddings and RAG retrieval.

Illustrative scores

PairCosine similarityMeaning
"goods not received" vs "item never arrived"~0.93Nearly the same — different words, same intent
"chargeback" vs "representment"~0.88Closely related in the disputes domain
"MDR" vs "PayNow fee"~0.82Same topic (fees)
"chargeback" vs "MDR"~0.35Both payments, but different topics
"card testing" vs "settlement timing"~0.20Largely unrelated
This is exactly what RAG uses: embed the question, score it against every chunk's vector, and return the closest few. High cosine similarity is why a question phrased differently from the policy still finds the right clause.

🔗 Where Embeddings Fit

Embeddings are the bridge between raw text and everything a model does with meaning. Here's where they sit in a grounded (RAG) payments assistant — and everything else they quietly power.

📝Text ✂️Tokenize 🔢Embed 🗂️Vector store Retrieve + generate

Both your documents (once, ahead of time) and the user's question (at query time) are embedded into the same space — retrieval finds the document chunks whose vectors are nearest the question. That's RAG.

Everything embeddings power

On AWS

PieceServiceRole
Embeddings modelAmazon Bedrock (Titan Text Embeddings)Turns text into vectors
Vector storeAmazon OpenSearch / Aurora pgvector (or managed by Knowledge Bases)Stores and searches vectors at scale
Managed RAGAmazon Bedrock Knowledge BasesHandles embedding, storage, and retrieval for you
The through-line: tokens let a model read text; embeddings let it compare meaning. Together they make grounded, semantic assistants possible — see the RAG deep dive to watch them combine.

🔢 The First Idea — One-Hot Encoding

Before dense embeddings, the simplest way to turn words into numbers was one-hot encoding: give every word in the vocabulary its own slot, and represent a word as a giant vector that's all zeros except a single 1 in that word's slot.

What it looks like

WordOne-hot vector (illustrative, tiny vocab)
chargeback[1, 0, 0, 0, 0, …]
dispute[0, 1, 0, 0, 0, …]
settlement[0, 0, 1, 0, 0, …]
PayNow[0, 0, 0, 1, 0, …]

Why it falls short

📏

Huge & sparse

One slot per word means vectors as long as the whole vocabulary — tens of thousands of dimensions, almost all zeros. Wasteful and slow.

🧊

No sense of meaning

Every word is equally far from every other. "chargeback" and "dispute" are exactly as distant as "chargeback" and "PayNow" — the encoding knows nothing about meaning.

🚫

Can't generalise

A new word (or a typo, or an internal code) has no slot at all — there's nowhere to put it.

The core problem: one-hot encoding turns words into numbers, but the numbers carry no meaning — so you can't measure that "goods not received" is close to "item never arrived". That's exactly the gap dense embeddings fill.

🧠 Dense Embeddings — Meaning in a Few Hundred Numbers

A dense embedding represents each token as a much shorter vector — typically a few hundred numbers — where the values are learned so that similar meanings end up with similar vectors. Instead of one slot per word, meaning is spread across all the dimensions.

One-hot vs dense

PropertyOne-hotDense embedding ⭐
Size= vocabulary (tens of thousands)A few hundred dimensions
ValuesAll 0 except one 1Learned decimals, e.g. [0.42, -0.11, 0.78, …]
Captures meaning?No — every word equidistantYes — similar words sit close together
Handles new phrasing?NoYes — "item never arrived" lands near "goods not received"

How the vectors are learned

📚

Learned from context

An embeddings model is trained on huge amounts of text; words that appear in similar contexts are nudged to similar vectors.

🧭

Meaning = direction

Each dimension captures some latent aspect of meaning. Related concepts point in similar directions in the space.

Compact & fast

A few hundred numbers per token is cheap to store and quick to compare at scale — millions of chunks stay searchable.

On AWS: Amazon Bedrock's Titan Text Embeddings is the model that produces these dense vectors — the engine behind semantic search and RAG. Explore the geometry it creates in the Embedding Space tab.