Zain Dana Harpernight school / L8

Embeddings. Every token gets coordinates.

Each piece of text gets a list of numbers, and training moves those lists until words that keep the same company sit close. Tallow hangs the words as cards in her lamp room and lets them drift.

The film

About 3:38, hosted by Tallow. It asks you one question and waits for your answer before it shows you. The narrated cut runs 2:53, voiced by Tallow in a synthesized voice made from the author's own voice; the author approved these cuts for publishing. Captions are on by default. The live version under it draws the same film in your browser, waits for your answer at each question, and runs a little longer; the full words are also below.

Nothing loads until you press play.

The lab: the lamp room

Train your own skip-gram on the guides' sentences: choose the seed, the numbers per word, the window and the noise words, then step through its snapshots and pick a word to see its neighbours. The film's run ends with 65% of words beside a word of the same kind, against about 23% shuffled.

Everything is computed on your computer, in this page. Nothing is sent anywhere.

Everything the film says

Embeddings

Embeddings. Every word gets coordinates.

Pylon showed you that a word in a model is a list of numbers, a place. Tonight, where those places come from.

Before anything is learned

At the start, every word gets a list of 32 small random numbers. The places mean nothing yet.

Check the neighbours: only 26 percent of words sit next to a word of the same kind, about what a shuffle gives.

You are the company you keep

The trick is a guessing game. Take a word in a sentence, and the words around it.

Each word gets two lists: one for when it's the word in the middle, one for when it's a neighbour. Nudge the lists so that the middle word's list and each real neighbour's neighbour-list get a bigger dot product, the measure from the vectors lesson.

And for every real neighbour, pick 5 words at random, common words more often than rare ones, and push those the other way. Tomas Mikolov and his colleagues called it negative sampling, in 2013.

The cards drift

Run the game over the guides' sentences, 5 times through, and watch the places move.

Will the neighbours keep getting tidier all the way through training? (the film pauses here)

Very early, by 5 percent of the way, the neighbours look their tidiest of any checkpoint: 72 percent of words sit next to a word of the same kind. By the end, in this run, it has slipped back to 65, three words fewer out of 46, while the guessing game keeps getting better on sentences it never trained on.

Better at the game is not always tidier on the chart. The game is the goal; the neat neighbours are a side effect.

Another roll of the dice

Start from different random numbers, four more times, and you get different coordinates, but much the same neighbours: against the first run, 75 to 80 percent of each word's three nearest neighbours agree.

Two ways to the same chart

The language model from the attention lesson learned its word lists a different way: as a side effect of guessing the next word, through two layers of attention.

Its lists put 80 percent of words next to a word of the same kind. And between the two tables, about 33 percent of each word's three nearest neighbours agree. By chance it would be about 7 percent.

So the two methods agree on far more than chance, and far less than two runs of the same method agree with each other. Neither one is the true map. Each is a map of what its own game needed.

Goodnight

Nobody draws the chart. A guessing game moves the cards, and words used alike end up close.

Next in the lighthouse: guessing the next word, and keeping score. Goodnight.

Sources

Every claim in the film, with where it comes from and what that source does not prove. The numbers about the model are computed from its weights, which you can load and check: facts.json.

What this lesson leaves out

Forty-six words from a made-up corpus are enough to see the effect and far too few to show what large tables learn; the categories used to score neighbours are ours.

The chart shows two directions out of many, so two cards can look close and be far apart; neighbours are measured in all the dimensions.

Before this: Tokens (L7). Next: Next-word prediction (L9).