← All projects

Project — Interactive Learning

Vectorization & Embeddings

How do you measure the distance between two ideas? This page builds the answer from the ground up — turning words into numbers you can add, subtract, and compare — with live experiments at every step. No math background needed.

Embeddings word2vec Vector Space Cosine Similarity NLP
Contents
The problem
A computer can tell you that 3 is closer to 4 than to 90.
But is king closer to queen, or to carrot?
Numbers come with distance built in. Words don't. To let a machine reason about meaning — to search, recommend, translate, or answer questions — we first have to turn language into something with a geometry: a space where "close" means "similar in meaning." That translation is called vectorization, and the numbers it produces are embeddings.

Here is the whole puzzle in one question. Suppose I ask you how far apart the words coffee and tea are. You have an instant, confident intuition — they're close. Coffee and gravity? Far. You did that without any numbers. But how? What were you actually measuring?

You were comparing qualities: both are hot drinks, both contain caffeine, both are things you order in a café. The more qualities two words share, the closer they feel. That's the key that unlocks everything on this page: if we can write down a word's qualities as numbers — a score for "is it a drink," a score for "is it hot," a score for a thousand subtler things — then meaning becomes a point in space, and distance between meanings becomes ordinary geometry.

The move in one sentence: represent every word as a long list of numbers — that list is all the word "vector" means, no physics required — arranged so that words used in similar ways land near each other. Once meaning lives in a coordinate space, "find similar" becomes "find nearby," and "reason by analogy" becomes "do arithmetic on the number-lists." Everything below is a way of making that list of numbers better.

Two honest questions fall out of this, and the rest of the page answers them by letting you try it, not just read about it:

1. Where do the numbers come from? Nobody hand-scores a dictionary. We'll see how machines learn the qualities on their own, purely from watching which words keep company with which. 2. How do we measure distance once we have them? Not with a ruler — with the angle between two vectors, a trick called cosine similarity.

Why the angle and not plain straight-line distance? Because a vector has two things going on: its direction (which way it points) and its length. Direction turns out to carry the meaning; length mostly reflects boring stuff like how often a word appears. Measuring the angle compares pure direction and ignores length — so "big" and "enormous" count as close even if one word is far more common than the other.

Build the intuition

Meaning, one number at a time

Before any machine learning, let's do the thing by hand — because once you've felt a word become coordinates, the rest is just automation. Below, three sliders each measure one quality of a word. Drag them to describe a concept, and watch a vector appear. The panel tells you which real word your coordinates land nearest to.

Widget — Hand-build a word vector
These three axes — royalty, gender, and age — are ones we chose, so you can read them. Try to place the word "queen": high royalty, feminine, adult. Then try "boy," or invent something. The takeaway: a word is just a position, and similar words sit in similar places.
Your vector
[ 0.00, 0.00, 0.00 ]
Nearest real word: —

Real embedding models do exactly this — but with hundreds of axes instead of three, and nobody labels them. The model invents whatever qualities best explain how words are used. That's the leap the next section tells the story of.

About to see "300 dimensions"? Don't panic. A "dimension" is just a slider like the three above. This toy has 3; a real model like the one in the Playground has 300. You cannot picture 300 axes in your head — and you never need to. Nothing changes except the length of the list: instead of [0.95, 0.85, 0.55] it's 300 numbers long. Every idea on this page — compare, subtract, find-nearest — is the exact same arithmetic whether the list has 3 numbers or 300.
How we got here

A short history in three leaps

The idea of "words as numbers" is older than deep learning. It arrives in three acts — each one fixing the thing the last one couldn't do.

1970s – 1980s · Counting
Bag-of-words & TF-IDF

The first vectors were simple: count the words. Represent a document as a long list of word counts — one slot per word in the vocabulary. TF-IDF (term frequency × inverse document frequency) refined this by down-weighting words that appear everywhere ("the," "of") and up-weighting words that are rare and therefore distinctive. It's brilliant, fast, and still powers search engines today.

But it has a fatal blind spot for meaning: every word is its own isolated slot. To TF-IDF, "cat" and "kitten" are as unrelated as "cat" and "helicopter" — they share no letters of overlap in the vector, so their distance is maximal. It can tell you which words a text contains, never what those words mean.

word →catkittendogfinance
Doc A0.90.00.40.0
Doc B0.00.80.00.0
"cat" and "kitten" never overlap — the model has no idea they're related.
Sparse Interpretable No semantics
2013 · The breakthrough
word2vec — meaning becomes arithmetic

In 2013, a team at Google led by Tomáš Mikolov published word2vec, and it changed the field overnight. The insight is deceptively simple, and it's an old one from linguistics — "you shall know a word by the company it keeps." A word's meaning is defined by the words that surround it. "Coffee" and "tea" are similar not because anyone said so, but because they appear in nearly identical contexts: "a cup of ___," "I drink ___ in the morning."

word2vec turned that into a learning game. Slide a window across billions of sentences and play one guessing game over and over: given these neighbours, what word sits in the middle? Each guess, the model nudges its numbers to do a little better next time — millions of tiny corrections. ("Training a neural network" is just this loop, run at scale.) To win the game, the model is forced to give words that share contexts similar vectors. Nobody labels a single axis — the qualities emerge on their own, packed into a few hundred dense numbers per word.

And then someone noticed something astonishing. The learned space had structure you could do algebra on. Directions in the space carried meaning — one direction was gender, another was royalty — so you could literally add and subtract concepts:

king − man + woman ≈ queen

You can't subtract words, of course — but remember, each word is now just a list of numbers. So this is ordinary arithmetic: line up the lists and subtract them slot by slot, then add. Take "king," subtract "man" (which cancels out the maleness), add "woman" — and the resulting list of numbers lands almost exactly on the one for "queen." Meaning had become geometry you could compute with. You can run this yourself, on real word2vec vectors, in the Playground below.

Dense Learned Analogies Self-supervised
2018 → today · Context
Contextual embeddings

word2vec has one limitation: each word gets one vector, forever. But "bank" by a river and "bank" that holds your money are different meanings sharing one spelling. The modern era — BERT, and the Transformer models that followed — fixed this by making a word's vector depend on the whole sentence around it. The same word gets a different embedding every time, tuned to how it's actually being used.

This is the direct ancestor of today's embedding models that power semantic search and Retrieval-Augmented Generation. The full list of what's current lives in the "Today" section at the bottom.

Contextual Transformer Sentence-level
Your turn — real vectors, live

The Playground

Everything below runs on real pretrained word2vec vectors (Google News, 300 dimensions) for a curated vocabulary of 167 words — the actual numbers, computed right in your browser. Nothing is faked or hard-coded. Poke at it. Meaning is more manipulable than it looks.

Loading real word vectors…
The state of the art

Where embeddings are today

word2vec was 2013. The line of descent since has been about context, scale, and embedding whole sentences and documents rather than lone words. A working shortlist of what powers modern systems:

BERT / Sentence-BERT2018–2019
The Transformer that made embeddings context-aware. Sentence-BERT adapted it to embed whole sentences for fast semantic search.
OpenAI text-embedding-32024
A widely-used API embedding model; strong general-purpose retrieval quality with adjustable dimensions to trade size for accuracy.
Cohere Embed v32023–2024
Built for retrieval at scale, with a focus on ranking quality and support for many languages and compressed vectors.
Amazon Titan Embed v22024
The model behind the RAG demo on this site — 1,024-dim vectors via Amazon Bedrock.
BGE / E5 (open source)2023–2024
Top open-weight embedding families you can self-host — competitive with closed APIs and free to run.
Multimodal (CLIP & kin)2021 →
Embeds images and text into one shared space, so you can search photos with words. The vector idea, generalized beyond language.
Last word
We taught machines to hold a thought as a place
and meaning turned out to have a shape.

Every search that understands you, every recommendation that feels uncanny, every AI that answers from your documents — underneath, it is doing the one small thing you did by hand at the top of this page: turning words into points, and measuring what is near. The whole cathedral of modern AI is built on that single, strange, beautiful idea.

What to explore next
Project
RAG Pipeline — embeddings in action
Concept
Cosine Similarity
Concept
word2vec & the Distributional Hypothesis
Concept
Contextual Embeddings & BERT
Concept
Vector Space & Dimensionality
Deep dive
BM25 — when exact words beat meaning