kyem.netkyem.net
×
An Interactive Explainer

How a word becomes a number

Scroll to follow one word — cat — from letters a model can’t read to the coordinates it actually thinks in. Vectors, matrices, and embeddings, no maths required.

Scroll
01
Scene 01 — The Problem

A computer can’t read words. Only numbers.

cat
the word
?
turn into numbers?
01001 11010 00110 10101 01100 11001 00101 10110 01011
?
the model · does math

Models do math. Words aren’t math. So step one is turning every word into numbers — the right numbers.

02
Scene 02 — A Vector

A vector is a list of numbers — a point in space.

cat
=
[ 0.8 , 0.3 ]
cat0.80.30

A vector is just an ordered list of numbers. Two numbers = a point on a flat map. The arrow is the word’s location.

Real models don’t use 2 numbers. GPT‑2 uses 768. We can’t draw 768 axes — so picture this 2D map as a flattened shadow of a 768‑dimensional space.

03
Scene 03 — A Matrix

Stack the vectors and you get a grid.

rows = words
cat0.80  0.30  0.11  0.94  0.27  0.63  0.08
dog0.76  0.34  0.09  0.88  0.31  0.59  0.12
kitten0.83  0.29  0.14  0.91  0.25  0.66  0.06
helicopter0.12  0.88  0.71  0.05  0.93  0.18  0.77
columns = the 768 numbers →

Stack many vectors and you get a matrix — a grid of numbers. This grid is the embedding table: one row for every word the model knows.

GPT‑2’s embedding table is about 50,257 rows × 768 columns — one row per token it knows.

04
Scene 04 — Lookup, Not Calculation

Finding a word’s vector is a lookup.

cat
tokenizer gives an id
2415
2412truck
2413river
2414window
2415cat
2416paper
2417summer
2418copper
row 2415 → the embedding
0.80  0.30  0.11
0.94  0.27  0.63
0.08  0.55  0.41
768 numbers

The word’s ID is just a row number. Getting its vector isn’t a calculation — it’s a lookup. Go to that row, grab the 768 numbers. That’s the embedding.

05
Scene 05 — Meaning Is Geometry

Similar meanings land near each other.

ANIMALScatkittendogpuppylionhelicopterjetenginebankinvoiceTuesdaygravity

cat and kitten are neighbours; cat and helicopter are across town. Distance = difference in meaning. Hover any word to see its coordinates.

06
Scene 06 — Directions Mean Things

You can do arithmetic on meaning.

man → womanmanwomankingqueen
kingman+womanqueen

Drag the orange arrow onto king →

The step from man to woman is the same step from king to queen. Directions encode relationships.

07
Scene 07 — Nobody Programmed This

These positions are learned, not labelled.

catkittendoglionjetenginetruckTuesdaybankgravity

No human labelled cat as an animal. The clusters emerge automatically as the model reads huge amounts of text and predicts the next word.

08
Scene 08 — The Payoff

The vector is the word’s door into the model.

cat
2415
0.80 0.30 0.11
0.94 0.27
768-dim vector
Attention
Feed‑forward
Attention
× 12 layers
the transformer

Everything the network does next — attention, reasoning, prediction — operates on these number‑coordinates, never on the letters c‑a‑t.

A note for the curious: these per‑token embeddings aren’t the same object as the sentence or document embeddings used for search and RAG — same idea, different scale.

← Back to article