Theseus walked the thread. Arachne never did. She wove the whole row at once

Arachne was a girl from a dyer's family in Lydia who wove better than anybody alive and said so. When Athena came to punish the boasting, the two of them set up looms and worked in silence, and the awful part of the story is that Athena could not find a single fault in the girl's cloth. Weaving is the oldest machine we have that does a whole line in one movement. The shuttle crosses once and every thread in that row is placed at the same instant, each one crossing every thread already standing. You do not walk a tapestry into existence. You build it a row at a time, all at once.

Which is the whole of what follows. Every other piece in this series describes something the machines do — hearing a word, finishing a sentence, carving a picture, copying a voice, crossing a language. Underneath all of them is one machine, invented in 2017, unchanged in its essentials since, and this is the piece about the machine itself. It has been standing behind every chapter you have read here, and nobody has introduced it.

Written for ages 12+, and for anyone who has heard the word transformer a thousand times and never been told what it actually is. Every chapter has a Deeper into the maze box for anyone who wants the harder version, and the real engineering words are all at the bottom.

The loom pass 1 of 8
one row per pass · each square is one thread meeting another · the finished cloth is the sentence, understood

the reveal

You have already met this machine seven times

Here is something this series has not said out loud, and should have. The pieces you have read describe six or seven completely different jobs, done by what look like completely different systems. They are not different systems. They are the same block of machinery, built in 2017 for translating between languages, which then turned out to work on everything anyone pointed it at.

That is a strange fact and worth sitting with. Nobody designed a machine for reading Amharic, and a different one for finding the edges of a cat, and a third for hearing the difference between b and p. Somebody designed one machine for moving a sentence between two languages, and the rest of the field discovered, over about five years, that if you chop your problem into pieces and lay them in a row, this thing will find the pattern. Whatever the pieces are.

texere

Latin, to weave. It gives us textile, and it also gives us text — a thing woven out of threads. The metaphor in this piece is not one I am reaching for. It is sitting inside the word, put there by people who had looms and no idea what was coming.

feed it three different materials. watch the column in the middle refuse to change

Instrument 01 · One block, three materials words
the strip at the top changes · below the first step, the column does not
what goes in
a piece of a word is what one piece is, here
All the intelligence anybody adds per problem is in the first line: how do I cut this into pieces and lay them in a row? Words into tokens, a photograph into a grid of little squares, a second of sound into forty slivers. After that the machine does not know or care what it is holding. It has one skill, and the skill does not mention language.
Deeper into the maze

Each piece arrives as a list of numbers — piece two called it “where a word lives”, and the engineering word is an embedding. Everything downstream operates on lists of numbers of a fixed width, typically 768 in a small model and 4,096 or more in a large one, and that width is all the block knows about its input.

This is why the vision version needed no new mathematics. Cut a 224×224 photograph into 16×16 squares and you have 196 pieces; flatten each square's pixels and multiply by one matrix to get 768 numbers; feed the row in. The paper that did this is called An Image is Worth 16×16 Words, which is the whole joke and the whole result. Same for audio: a 25 ms sliver of spectrogram, flattened, projected, fed in.

a word · a 16×16 patch · a 25 ms sliver → 768 numbers → the identical block

the difference

Walking the thread, and throwing it

To see why this mattered, you have to know what it replaced. Piece one had you walk a Labyrinth: one step, then the next, each one depending on where the last one left you. That is genuinely how machines handled sequences for about thirty years. A word goes in, the machine updates a little bundle of state, the next word goes in, it updates again. Ariadne's thread, followed from the door.

It works. It has one fatal property: step forty cannot begin until step thirty-nine has finished. There is no way around that; it is what "sequence" means in that design. So a sentence of a thousand words is a thousand things that must happen one after another, and buying a thousand times more computers does not help you at all, because they would all be standing around waiting.

The loom does not have that property. When the shuttle crosses, every thread in the row is placed in the same movement, and no thread is waiting on the one to its left. Nothing about this is cleverer — in fact a transformer does far more arithmetic than the walker did, as the next chapter shows. It is just arithmetic that can all happen at the same instant, which means it can be handed to ten thousand chips at once. The transformer did not win by being smarter. It won by being shaped like a thing you can buy more of. Piece eleven is what buying more of it costs.

make the row longer and watch which of the two gets slower to finish

Instrument 02 · The walker and the shuttle a normal row
top: one step at a time, in order · bottom: one pass, all together
10 pieces
10 things the walker must do in order 1 things the loom must do in order 100 comparisons the loom does — all at once
Look at the third number against the first. At any row length the loom does N times more work than the walker — a hundred comparisons against ten steps at the default, five hundred and seventy-six against twenty-four at the far end — and finishes sooner anyway, because its comparisons have no opinion about each other and can be split across as many chips as you own. The walker's steps must be done by one worker, in order, however many workers you hire.
Deeper into the maze

The walker is a recurrent network — an RNN, usually an LSTM. Its trouble is not only speed. Because information from word one reaches word forty by being passed hand to hand through thirty-nine updates, the signal degrades on the way, and the gradient that has to travel back down that chain during training degrades with it. Long-range agreement was the thing these models were worst at.

The transformer's fix is blunt and total: the distance between any two pieces becomes one step. Word one and word forty meet directly, in a single operation, with nothing in between to blur them. What you pay for that is the whole of the next chapter — every pair now has to be looked at, so the work grows as the square instead of the length.

walker: 40 sequential steps, signal crosses 39 hops · loom: 1 step, every hop is length 1

the cloth

Every thread meets every other thread

Now the machine itself, and it is smaller than its reputation. Lay the pieces of your sentence in a row. Take the first piece and ask it, of every piece in the row including itself: how much do you matter to me? That gives you a row of numbers. Do the same for the second piece, and the third, and all of them. You now have a square: as many rows as pieces, as many columns as pieces, and one number in every cell saying how strongly the piece on the left is attending to the piece on top.

That square is the whole idea. It is a woven cloth — the pieces are the warp standing up and the same pieces are the weft going across, and the machine's understanding of the sentence is literally the pattern where they cross. Then each piece rebuilds itself as a blend of everything it was looking at, weighted by those numbers. The word sat, having looked hardest at dog, becomes a version of itself that knows who was sitting.

Piece two told you one rule about this and it still holds: in a machine that writes, the eyes may only look backwards. Everything above the diagonal is cut away — every piece asking about a piece that has not been written yet, which for a row of eight is 28 of the 64 cells, a little under half. Turn that off in the instrument and you get the version used for reading rather than writing, which is allowed to see the whole row and is what every recogniser and translator in this series actually uses.

click any row to see what that word is looking at. then cut the future away

Instrument 03 · The cloth looking backwards only
rows ask · columns answer · grey cells are the future, cut away
64 cells in the full cloth 36 left once the future is cut
Click sat and it looks back at dog, across four words, in one hop. Click that and it finds dog too. Nobody wrote a grammar rule for either. The cloth is the only place that knowledge lives, and it is rebuilt from scratch for every sentence.

The shading here is a pattern we drew, chosen to be readable, not weights lifted out of a trained network — no model runs on this page. The counts are real: 64 and 36 are computed from the eight words on screen as N² and N(N+1)/2, which is why the second is a little over half the first rather than exactly half.

Deeper into the maze

Each piece is projected into three different lists of numbers: a query (what I am looking for), a key (what I can be found by) and a value (what I hand over if you look at me). The number in a cell is the dot product of one query with one key, divided by the square root of their width, and then a softmax turns each row into fractions that sum to one. The division is not decoration: without it the dot products grow with the width, the softmax saturates, and training stalls.

The cost is the honest problem. A row of 4,096 pieces makes a cloth of 16.7 million cells — per head, per layer. Take 32 heads and 32 layers and you are holding on the order of 17 billion of those numbers for a single sequence. Nearly every headline transformer variant of the last few years — sparse, linear, sliding-window, FlashAttention — is an attempt to avoid building that square all at once.

cell(i,j) = softmax( q_i · k_j / √d ) · N pieces → N² cells · 4,096 → 16,777,216

the flaw

The loom does not know which thread came first

Everything above has a hole in it, and it is the thing about transformers most worth understanding, because it is genuinely strange. Go back to the square. Piece one asks piece four how much it matters. Nothing in that question mentions where piece four is sitting. The cloth records which threads met, and how strongly — never in what order they were laid down.

So a plain transformer cannot tell the dog bit the man from the man bit the dog. Not "finds it difficult". Cannot. Be careful about exactly what is claimed here, because the sloppy version of it is wrong: shuffle the row and the cloth does move — the rows and columns get shuffled along with the words. What does not move is what the machine works out about any given word. Its picture of dog is built from which words the dog is related to and how strongly, and both of those come out the same whether the dog did the biting or had it done to it. To the machinery a row is a bag: a set of things that are all present, with no first and no last. Every other machine in this series is built out of something with this hole in it.

The fix is as blunt as the problem. Before anything else happens, you stitch a mark onto every thread saying where it sits — a small pattern of numbers added to the piece itself, so that dog-in-position-two is a genuinely different thing from dog-in-position-five. Order is not something the machine understands. It is a label we glue on, because otherwise it would be reading a heap.

swap the dog and the man with the marks off. then turn them on and swap again

Instrument 04 · Who bit whom identical cloth
left: the cloth · right: what it works out about “dog” · watch the bars across a swap
cannot tell what the machine can say about who bit whom
With the marks off, swap them as many times as you like: the bars on the right do not move. The machine's picture of dog is exactly the same whether the dog was the biter or the bitten, so there is nothing in it that could tell you which. Turn the marks on and the same swap moves them. The grid really is rebuilt from the swapped row every time, and the bars really are read back out of it.

As in instrument 03, the numbers in these cells are ours, not a trained model's — here each one is derived from the pair of words it joins, so it is not a softmax and the rows do not sum to one. That construction makes the property visible rather than discovering it: a machine that describes each piece only by what it is cannot help but be order-blind. Stitching positions in is the fix precisely because it changes what each piece is.

Deeper into the maze

The formal name for the hole is permutation equivariance: shuffle the inputs and the outputs come back shuffled the same way, unchanged in content. It is a property of the arithmetic, not an oversight, and it is exactly what makes the block work on unordered things like sets of atoms.

The original fix was a positional encoding — a fixed pattern of sines and cosines at many different wavelengths, added straight onto the embedding, chosen so that a shift by a constant is a linear transformation the network can learn to read as “this many places along”. Most current models instead use rotary embeddings (RoPE), which rotate the query and key vectors by an angle proportional to position, so the dot product in every cell depends only on how far apart the two pieces are rather than where they sit absolutely. That change is a large part of why context windows grew from 512 to 128,000.

no marks: “dog bit man” ≡ “man bit dog” · RoPE: cell(i,j) depends on (i − j)

the patterns

Several patterns woven through one cloth

One cloth is not enough, because a word is doing several jobs at once. In the dog that chased the cat sat down, the word sat needs to know who did the sitting (the dog), and also that it is the main verb, and also what came immediately before it. Those are different questions and one grid of numbers can only answer one of them well.

So the machine weaves several cloths side by side over the same row — typically twelve to a hundred of them — each with its own set of questions, and then lays them together. These are called heads, and here is the part worth keeping: nobody tells a head what to specialise in. They are identical at birth and differ only by their random starting numbers. Take a trained model apart afterwards and you find one head that reliably looks at the previous word, one that tracks what a pronoun refers to, one that watches punctuation, one that stares fixedly at the very first word of the row for reasons that took years to explain.

turn the patterns off one at a time and watch which relationships disappear

Instrument 05 · Four patterns, one cloth 4 patterns at once
four heads, four colours, one row of words · they overlap because words do several jobs
which heads
4 patterns switched on
The fourth one looks like a bug: a head that ignores the sentence and stares at the first word. It is real, it appears reliably, and it is now understood as the machine's way of saying nothing here is worth attending to — the softmax in every row must add up to one, so a head with no opinion has to put its weight somewhere, and it parks it on the first piece.

These four are drawn by us as clean examples. Real heads are messier and rarely do only one job. But every pattern shown here is one that people have genuinely found by taking trained models apart, including the last one.

Deeper into the maze

Heads are not extra machinery bolted on; the width is divided between them. A model 768 numbers wide with 12 of these — each one an attention head — gives each head 64 numbers to work with — so twelve heads cost about the same as one wide head and buy twelve independent patterns instead of one averaged one.

The parked head has a name, the attention sink, and it is not a curiosity: throw away the earliest tokens when trimming a long context and models do not degrade so much as fall over. Keeping four of them holds a Llama-2-13B at a perplexity of 5.40; keeping none sends the same model to 5158 — not a worse model, an incoherent one. The sink has nowhere to park. The most celebrated finding in this area is the induction head — a pair of heads in different layers that together implement “find where this happened before, and copy what came next”. That two-head circuit is a large part of how a model learns from examples inside its own prompt, which is the trick the entire industry runs on.

768 wide ÷ 12 heads = 64 each · layer-1 head finds it → layer-2 head copies what followed

the depth

Weaving over the woven

One pass of the shuttle is not a model. You do the whole thing again — new questions, new cloth, new blend — on the output of the pass before, dozens of times. Piece two put it as Hephaestus striking the same metal ninety-six times, and that is right, but it leaves out the detail that turns out to matter most.

Each pass does not replace what came before. It adds to it. There is a running total down the middle of the machine — every piece's numbers, carried forward unchanged — and what a layer produces is not a new version but a contribution, thrown onto the pile. Engineers call it the residual stream, and it is closer to a conversation than a production line: every layer can read everything written so far and add a remark, and nothing anybody said gets erased.

That design decision is why these models can be a hundred layers deep at all — a signal can travel from the bottom to the top without being multiplied through a hundred transformations that would destroy it. And it has a consequence you can feel in the instrument below: cut one layer out of a trained model and it mostly still works. Cut several and it degrades gently rather than dying. That is not robustness anyone engineered. It is what you get when the machine is a sum rather than a chain.

click passes to cut them out. the red rules are what the finished cloth should look like

Instrument 06 · The running total every pass in place
top: what each pass contributes · bottom: everything added together
0 passes cut out 100% of the finished cloth still recovered
Cut pass six and the total barely moves — sometimes it reads slightly above 100%, because that pass was adding about as much noise as signal. Cut five of the middle ones and it is still all there. Then cut the first pass, or the last: each costs about a tenth on its own, and together they take nearly half. The middle of the machine is redundant; the two ends are not. Compare either case with the walker in instrument 02, where losing one step means everything after it is built on nothing. A sum forgives what a chain cannot — but it does not forgive everything equally.

The arithmetic here is real — twelve fixed contribution vectors, genuinely summed, and the percentage is a genuine cosine similarity against the target. It is a toy of twelve numbers rather than four thousand, but the shape of what happens when you remove one is the shape that happens in the real thing.

Deeper into the maze

The running total is the residual stream, and the mechanical form is one line: the output of every block is x + f(x), never f(x). Because addition is commutative and each block writes into the same shared space, the stream is best read as a communication channel that layers write to and read from, rather than as a pipeline that transforms.

The evidence for the chapter's last claim is direct, and more interesting than "depth is redundant". Delete layers one at a time from a trained model and it keeps 72–95% of its top-1 accuracy with no retraining — but the damage is very unevenly spread. The middle is remarkably robust; interventions at the first and the last layer cause by far the most degradation. The usual reading is that the ends do jobs nothing else can do — turning tokens into features at the bottom, and sharpening features back into a next-token guess at the top — while the middle passes each nudge an already-formed representation. That is also the mechanism behind layer pruning, where a contiguous block of a large model's middle depth is dropped for cheaper serving at modest cost — and why the pruning recipes explicitly refuse to drop the final layer.

x → x + attention(x) → x + attention(x) + mlp(x) → … · remove one term, keep the rest

the glossary

The words the engineers use

the loom, the whole machinethe transformer
cutting the material into pieces and laying them in a rowtokenization, patching, framing
where a piece lives, as numbersan embedding
walking the thread one step at a timea recurrent network (RNN, LSTM)
throwing the whole row at onceparallel sequence processing
the cloth: every piece against every piecethe self-attention matrix
what I am looking forthe query
what I can be found bythe key
what I hand over when you look at methe value
turning a row of scores into shares that total onethe softmax
dividing before the softmax so it does not saturatescaling by √d
cutting away the futurecausal masking
why a long row costs so muchattention is O(N²) in time and memory
a bag, not a rowpermutation equivariance
the mark stitched on to say where a thread sitsa positional encoding
marks that record distance instead of placerotary embeddings (RoPE)
several patterns woven through one clothmulti-head attention
one of those patterns, on its ownan attention head
the head that stares at the first piecean attention sink
find where this happened before, copy what followedan induction head
weaving over the wovenstacked layers, model depth
the running total nothing is erased fromthe residual stream
throwing away depth to serve it cheaperlayer pruning
the same block, on picturesa vision transformer (ViT)

One sentence to take away

Almost everything in this series is one machine that lays your problem out in a row, has every piece ask every other piece how much it matters, and does the asking all at once — which is not cleverer than walking the row, only shaped so that ten thousand chips can help.

Athena found no fault in the weaving. What she could not forgive was the picture Arachne chose to put in it — which is, more or less, where the rest of the argument about these machines has ended up.

the sources

Where these ideas come from

Five papers, and between them they are most of why the last decade happened. Each note says what the paper actually established.

  1. A. Vaswani et al., “Attention Is All You Need” (2017). The machine, in one paper. Worth knowing that it is a translation paper — the job in piece 09 — and that its case was as much about training in parallel as about quality: it reached the state of the art in a small fraction of the training cost of the recurrent models it replaced.
  2. A. Dosovitskiy et al., “An Image is Worth 16×16 Words” (2020). Chapter one's claim, demonstrated: cut a photograph into 16×16 patches, feed them in as if they were words, change essentially nothing else, and it matches the specialised vision architectures of the day.
  3. A. Gulati et al., “Conformer: Convolution-augmented Transformer for Speech Recognition” (2020). The same block with sound going in, and the architecture behind a great many of the recognisers in piece 01. The systems we run at Phonetico are fine-tuned Whisper models, which are plain encoder-decoder transformers rather than Conformers — a different member of the same family, and the point of this chapter is that the family is what matters.
  4. J. Su et al., “RoFormer: Enhanced Transformer with Rotary Position Embedding” (2021). Chapter four's fix as it is actually done now: rotate the query and key by an angle set by position, so each cell depends on the distance between two pieces rather than their absolute places.
  5. N. Elhage et al., “A Mathematical Framework for Transformer Circuits” (2021). Where the residual stream in chapter six is treated as the central object rather than a training trick, and where induction heads were identified and named.
  6. G. Xiao et al., “Efficient Streaming Language Models with Attention Sinks” (2023). The head that stares at the first word, named and measured: the paper that showed dropping the earliest tokens from a long context does not degrade a model gracefully but destroys it, and that keeping a handful of them is enough to prevent that.
  7. V. Lad, W. Gurnee & M. Tegmark, “The Remarkable Robustness of LLMs: Stages of Inference?” (2024). The measurement chapter six's instrument is built on: delete layers one at a time and a trained model keeps 72–95% of its top-1 accuracy, with the middle robust and interventions at the first and last layers doing by far the most damage.