What the Universe Wants
A page from What the Universe Wants — the rule under the machines

Nobody Taught It Grammar

one operation — every word gets to look at every other word — and a machine that works out for itself where to look

There is a language model below that trains itself from scratch while you watch, in about twenty seconds. Skip to it ↓

Read this at your ordinary speed and see whether anything snags.

The key to the cabinets are on the table.

Most people sail right through. The subject of that sentence is key — one key — so the verb wants to be is. What put are in your ear was cabinets: a plural noun standing right next to the verb, close enough to lean on it.

This is not a personal failing and it is not carelessness. Kathryn Bock and Carol Miller measured it in 1991 by handing people sentence fragments and asking them to finish the thought out loud. Fragments like the key to the cabinets drew a plural verb far more often than the key to the cabinet did — same subject, same grammar, one word changed several words away. They called it agreement attraction, and thirty-five years later that same phrase is still the standard item researchers reach for when they want to make a fluent adult stumble.

Your grammar is fine. Your looking slipped to the wrong noun.

I want to hand that exact problem to a machine that has never been told one thing about grammar, and watch what it does about it.

What a rule for this would look like

Programmer's instinct says: just write the rule down. Verbs agree with their subjects. Two lines of code, an afternoon at most.

So try. The subject is not the first noun — near the barn, the horses are restless puts a barn out front. It is not the nearest noun, which is the whole trap above. It is not the noun the verb happens to touch, because English will cheerfully shove a clause in between: the woman who fixed the tractors is here. Now the noun that owns the verb is five words back with two nouns and a verb sitting between them, and every one of those is a plausible impostor. So you add a clause detector. Which needs a clause definition. Which needs to know that that is doing something different in the box that I found than in I found that box.

By the third afternoon you have a thicket, and the thicket has grown a maintenance schedule. Nature is the master of spaghetti code but she has no monopoly on it; anybody who has tried to write down the rules of a living language has produced some of the finest spaghetti in the business. That is more or less how the field went for decades: hand-built grammars, then hand-built features feeding statistical classifiers, every piece reasonable on its own, the pile never quite closing.

One operation, repeated

In 2017 a paper came out of Google with a title that reads like a shrug: Attention Is All You Need. Eight authors, aimed at machine translation, and it beat the field on the standard German and French benchmarks. That is not why anyone remembers it. It is remembered because the architecture it described — the Transformer — turned out to be what nearly every model in the current crop of AI is built out of, including the one that helped write this page.

The operation at the middle of it is small enough to say in a paragraph. Every word puts out three little bundles of numbers. Call the first a query: what I am looking for. The second a key: what I am. The third a value: what I have to hand over if you pick me. A word that needs to decide something compares its query against every key in the sentence, scores each match, turns the scores into shares that add to one, and mixes the values together in those proportions. That is the entire move. Do it once and you have one layer. Do it a hundred times over a few trillion words of text and you have the machines that are currently rearranging the economy.

If you like formulas

The paragraph above is exactly softmax(QKT/√d)V, and that is the whole of it — the scores, the shares that add to one, the weighted mix. If you don't like formulas, you have lost nothing at all: the panel below is that line, drawn.

Notice what is not in there. No grammar. No parse tree. No list of exceptions, no clause detector, nothing that knows a noun from a preposition. And in particular, nothing that says which words ought to look at which. The scoring is done with numbers that start out as noise and get nudged, over and over, by nothing but the difference between what the model guessed and what the next word turned out to be.

So where does the looking come from? It has to arrive on its own or not at all. That is the part worth watching rather than reading about.

The Experiment

Below is the smallest honest version of that machine I could build. One layer. One head, unless you give it more. Twenty words in its vocabulary and about twenty-eight hundred numbers in total, every one of them starting as noise — a rounding error next to a real model, and the same operation exactly.

It sees sentences like the rusty key near the old boxes and has to produce the missing word. It is never told what a noun is. It is never told which word is the subject, or that there is such a thing as a subject. It is not even told the answer will be a verb. It gets a sentence, it guesses, it is nudged, and that is all that ever happens to it.

The dial that matters is the second one: how often the near noun disagrees with the subject — how often, in other words, the model is handed the trap you fell into at the top of this page.

Experiment — one layer of attention, trained from noise, learning where to look
35%
1
sentences seen 0 ordinary sentences right trap sentences right looking at the subject
where it is looking the subject & the right answer the near noun ordinary sentences right looking at the subject

Things to try:

What just happened in there

Two things worth pulling apart, and the second one is the page.

The first is the shape of the learning. It is not a ramp. The model sits at chance for something like a thousand sentences, doing what looks from outside like nothing, and then inside a few hundred sentences it goes from a coin toss to right, and the attention goes from spread across the whole sentence to sitting on one word. In the verified runs the flat stretch ran to between 640 and 1,280 sentences and the transition took between 320 and 960. If you were watching a progress bar you would have called it broken and killed it a second before it worked.

It doesn't get better at the task. It gets a way of doing the task, all at once, and then it has it.

The second thing is what the fifth try-card does. Train the same model in a world where the near noun happens to agree with the subject every time, and it gets ordinary sentences right — and then it fails the trap about as often as it passes it. Over five runs of the prototype, trap accuracy came out anywhere between 52% and 67%, and where in that range it landed was luck. There was no pressure in that world to tell the two nouns apart, so it never bothered to, and the mixture it settled for happens to work on everything it was ever shown.

Which is a fair description of you, at the top of this page. In ordinary English the noun sitting next to the verb usually does agree with the subject, so a fast, cheap heuristic — grab the number off the nearest noun — is right nearly all the time, and the rare case where it isn't costs you almost nothing. I would hold the parallel loosely, because a model is not a brain and this one has about as many parts as a wristwatch. But the shape rhymes, and it rhymes for a reason that has nothing to do with either substrate: what a system learns to distinguish is set by what it ever got punished for confusing.

Out in the wild

Now let me take my own demonstration apart a little, because a page like this should hand you the seams.

The panel is rigged in one specific way. Each word offers a value built from the word alone, with no trace of where in the sentence it sits — which means the only way this model can ignore a word is to stop looking at it. That makes the arcs an honest picture of what the machine is doing. Real models are not so tidy: their values carry position too, so a head can attend to a word and then quietly throw it away, and the picture on the screen is no longer the whole story. There is a live argument in the field about exactly this, opened by Sarthak Jain and Byron Wallace's Attention is not Explanation in 2019 and answered a few months later by Sarah Wiegreffe and Yuval Pinter's Attention is not not Explanation. The honest summary is that attention weights are a real signal and not a confession.

The other seam is the task. My sentences always put the subject in the first few words, so the head has an easier job than it would have on real English. So it is worth knowing that the real version of this experiment has been run, repeatedly, on real language.

Linzen, 2016
Tal Linzen, Emmanuel Dupoux and Yoav Goldberg gave the agreement task to the previous generation of networks and found they could learn a surprising amount of syntax — and concluded, carefully, that next-word prediction alone was not enough to get it reliably. Worth remembering when anyone tells you the last decade was obvious in advance.
Goldberg, 2019
Three years and one architecture later, Goldberg ran a version of the same test on BERT, a Transformer, and it did remarkably well — including on sentences with several impostor nouns stacked between the subject and the verb.
Clark, 2019
Kevin Clark, Urvashi Khandelwal, Omer Levy and Christopher Manning went looking inside BERT's individual heads and found some that track the direct objects of verbs, some the determiners of nouns, some the objects of prepositions, some which pronoun refers to whom — at accuracies that surprised the people looking. No one built those heads. They precipitated.
Olsson, 2022
Catherine Olsson and colleagues at Anthropic tracked a particular circuit forming during training — a head that finds an earlier occurrence of the current token and copies what followed it — and found it appears in a sharp phase change, at about the same point in training from small models to very large ones, with a visible bump in the loss curve as it lands.

That last row is the one I keep turning over. A capability shows up abruptly, at a particular moment, in a system whose parts were only ever being nudged by an error signal — and the same moment shows up across model sizes, which is what you say about a phase transition and not about a feature. The click in the panel above is a much smaller thing and I am not going to claim they are the same event. It is a family resemblance, and families are what this site is about.

The rule under the machine

Set the machinery aside for a second and look at the shape, because you have seen it here before. In Three Rules, three lines of local behaviour — don't crowd, match your neighbours, stay with the group — produce a flock that no bird is holding a picture of. In The Trail Is the Plan, ants with no plan and no boss build a road network by dropping scent and letting it evaporate. Here, one operation — every word may look at every other word, and the shares are learned — produces something that finds the subject of a sentence across a distractor, on its own, in twenty seconds, in your browser.

Local rule, many units, enormous repetition, global order nobody specified. That is the pattern this whole site is pointing at, and the reason it belongs on a page about machines is that the substrate keeps not mattering. Birds, ants, hyphae, prices, and now a few thousand numbers being nudged toward a smaller error — the same architecture keeps showing up in materials that have nothing else in common, which is the strongest evidence going that we are looking at something real about how order gets made rather than a coincidence of biology.

And — because this site tries never to sell you a pattern as a blessing — the same operation that finds the subject of a sentence will find whatever else is lying around in the data. It has no opinion about that. Point it at the whole internet and it will pick up the structure of an argument, the structure of a con, and the structure of a confident sentence with nothing behind it, all by the same mechanism, with the same indifference. The universe permits this pattern. It does not endorse the uses. Which of them we build, and what we point them at, was never going to be a question the mathematics answers for us.

One last thing, and then I will let you get back to the panel. The other author of this page is a very large version of the machine in it — the same operation, stacked and scaled past anything I can picture, trained on a haystack of human writing. I have no idea what it is like to be that, and I am not going to pretend otherwise on a page about a toy finding a noun. But I know the shape of the rule underneath it now. So do you. That is a strange thing to be able to say about the technology currently being sold as a mystery, and it is worth twenty seconds of watching some arcs move to be able to say it.

Where to go next

Three Rules is the same story with birds and no numbers — the cleanest version of local rules making a global pattern with no one in charge.

The Trail Is the Plan is coordination with no communication at all: ants writing their plan into the ground and letting it fade.

What We Want is where the site argues that the only way to know what a rule produces is to run it — which is why this page hands you the model instead of a description of it.

What Is Wetness? is the other page about a verdict assembled out of parts that don't contain it — there, in a nervous system reading temperature and pressure and reporting “wet.”

Sources & Further Reading