jaxverse
Contents

jaxverse

A little universe of learning machines, designed and built by Neo Mohsenvand.

Chapter 5 · Self-supervised learning · ≈15 min

The Next Token

Predict what comes next: the simplest game in the world, and the one behind every large language model. Train one, live, on three hundred thousand words of children’s stories.

Cover the next word of a sentence with your thumb and guess it. "The little dog wagged his ____" is barely a puzzle; "my favorite word is ____" is a coin toss over a dictionary. Guess, uncover, compare, score yourself; slide one word to the right and play again. That game is this chapter's entire subject — and the claim it has to make good on is that nothing else is needed. A large language model is this game, won at scale.

Plate I Guess the covered word
the little dog wagged his ?tail0.78headpawnosebonebarely a puzzleone word soaks up the beliefmy favorite word is?catbluepizzathesevengenuinely hardthe belief spread thin
The game, before any machinery: guess the covered word. A guess is a whole belief — a probability for every word you know — and how sharply it peaks is how easy the puzzle was.

Before a machine can play it, though, there is a problem to solve. Gradient descent works on numbers; it needs a slope to walk down. Words are not numbers, and the obvious fix — number the dictionary, so "cat" is 3,412 — is worse than useless, because that numbering claims cat and 3,411 are neighbors when nothing about the language agrees. What the model needs is for similar words to sit near each other, so that a gradient learned about one word does some good for its neighbors.

So each word gets a vector instead: a short list of numbers, a position in a space of many dimensions. Nobody assigns those numbers. They are learned, and they are learned by the very game this chapter is about. Push a word's vector toward the words that tend to sit beside it, pull it away from words drawn at random, and after enough sentences the space arranges itself — animals collecting in one region, names in another, "he" beside "she". The idea that a word should be a learned vector is older than it is famous1 ; this particular recipe is skip-gram, the heart of word2vec2 , and it is small enough to run in the page you are reading.

Plate II One lesson, drawn
thelittledogwaggedhistailthe window · every centre–neighbor pair is one lessonone-hot600 slotsa single 1says nothingthe table600 × 16all of it learneddense · v(dog)16 learned numbersthe point on the stagethe rule, one pair at a timev(dog)·u(wagged)σ→ 1a real neighbor · pull togetherv(dog)·u(spoon)σ→ 0one of 5 random words · push apartthe loss · −log σ(v·u₊) − Σ log(1 − σ(v·u₋))surprise at the neighbor, one term per random word
A word arrives as a one-hot column — six hundred slots and a single 1, a representation that says nothing about meaning — and leaves as its row of the table: sixteen dense numbers, all learned. The only pressure on that row is the rule on the right, applied a million times; the geometry in the plate below is what the pressure leaves behind.

Note what the word trades away in that picture. Its honest representation is the one-hot column on the left — six hundred slots, a single 1, every word exactly as far from every other. The dense row it picks up instead is short, crowded with real numbers, and initially random garbage; it becomes meaningful only because the rule on the right hammers on it once per lesson. Written out, one lesson costs

L  =  logσ(vu+)    k=15log(1σ(vuk))\mathcal{L} \;=\; -\log \htmlClass{eq-op}{\sigma}\big(\htmlClass{eq-model}{v}^{\top}\htmlClass{eq-world}{u_{+}}\big) \;-\; \sum_{k=1}^{5} \log\Big(1 - \htmlClass{eq-op}{\sigma}\big(\htmlClass{eq-model}{v}^{\top}\htmlClass{eq-mute}{u^{-}_{k}}\big)\Big)

Take it in two halves. v\htmlClass{eq-model}{v} is the centre word's row of the table — the dense vector everything here is about — and u+\htmlClass{eq-world}{u_{+}} belongs to the neighbor actually seen beside it. The sigmoid σ\htmlClass{eq-op}{\sigma} turns their dot product into a verdict between 0 and 1 — did these two really co-occur? — and logσ-\log \htmlClass{eq-op}{\sigma} is the surprise at the truth, large exactly when the verdict on a real pair was low. The sum plays prosecutor: five words uk\htmlClass{eq-mute}{u^{-}_{k}} drawn at random, each punished for scoring. Nothing else appears in L\mathcal{L}, so the only way down is to move the vectors — pull v\htmlClass{eq-model}{v} toward u+\htmlClass{eq-world}{u_{+}}, push it off the five impostors.3 Geometry is not a by-product of this objective; it is the objective. An untrained sigmoid shrugs ln2\ln 2 at each of the six verdicts, so the plate's loss meter starts near 4.2 and falls as the space takes shape.

What that loss is doing underneath is less mysterious than it looks. Run the algebra out and skip-gram with negative sampling turns out to be quietly factorising a plain table of counts — how often each word appears beside each other word, compared with how often chance alone would put them there.4 The network is a way of doing that arithmetic one pair at a time, on a corpus far too large to hold the table for. The meaning was in the co-occurrence statistics all along; what the vectors add is that you can carry them around.

Plate III Words become vectors waiting
the embedding lab loads when you reach it
A PCA shadow of a 16-dimensional space — the top 600 words of this book's story corpus, redrawn as skip-gram training runs on your CPU. Words used alike drift together: animals with animals, names with names, he beside she. The cloud turns on its own; drag to steer it, or flatten it to the 2-D shadow, and use the slider to decide how much of the vocabulary the stage draws. Hover any label or pick from the menu to re-rank the neighbour list, which is computed in the full space by cosine similarity.

What you are looking at is a shadow of a sixteen-dimensional space — its three principal directions, the rest projected away, spinnable because even a shadow keeps more of its shape in three dimensions than in two — so read distances loosely. What survives the projection is the grouping, and the neighbor list beside it is computed in the full space, by cosine similarity: the angle between two vectors, ignoring their length. Nothing labeled any of this. The only pressure applied was "predict your neighbors", and geometry was the answer.

The vector arithmetic is the famous part. If the step from "boy" to "girl" is roughly the same displacement as from "he" to "she", then subtracting one and adding the other should land near the fourth word — and on this corpus it does. With 600 words and sixteen dimensions the hits are approximate and easy to break; at web scale, on billions of words, this stops being a party trick and becomes the substrate every language model computes on. You will not find the famous king − man + woman ≈ queen here, and the reason is instructive: these are children's stories, and "king" appears nine times in three hundred thousand words. A vector is learned from the company its word keeps — a word barely mentioned barely exists.

That famous example has always been sold harder than it deserves. The usual way of scoring it forbids the answer from being any of the three words you put in, which quietly removes the most likely wrong answers before the arithmetic is judged — and king is a very likely wrong answer to king − man + woman. Take the rule away and a good deal of the accuracy goes with it.5 The vectors do carry direction and relation. They carry rather less of it than the party trick implies.

One question remains before the real model: vectors for what, exactly? Words are a convenient story, but a vocabulary of English words is both enormous and never enough — someone will always write "unbelievability". Real models predict tokens: word-pieces, fragments like "wag" and "ged", and nobody designs those either. They are grown out of the data by byte-pair encoding6 , an algorithm of almost embarrassing plainness — it was a file-compression trick before anyone pointed it at language: start from the raw alphabet, count every adjacent pair in the corpus, fuse the most frequent pair into a new token, repeat. Common words end up as single tokens, rare words shatter into a few, and every entry in the vocabulary is a vote cast by frequency.

Plate IV Two words, as the tokenizer leaves them
little␣l№20it№17le№45itt№108ittle№118␣little№124common — one token after 124 mergeswagged␣w№5ed№8␣wa№14rare — still ␣wa + g + g + ed after 300
Two words, as this book's actual tokenizer leaves them. Every pill is a merge the corpus voted for, numbered in the order it was elected; the tinted pieces are the tokens the model will actually read. Frequency decides everything — "little" is everywhere in children's stories, "wagged" is not.

The plate below runs that exact loop — not a replay of a stored merge list, the algorithm itself — on the same 1.5 million characters the model further down is trained on. It needs no GPU and trains no network; it only counts. One rule keeps the result readable, and every real tokenizer has it: a merge may never cross from one word into the next. A word carries its leading space, drawn ␣ here, which is why “the” and “ the” are two different tokens — and why nothing in the vocabulary is ever half of one word glued to half of another. Watch which fusions this corpus elects first.

Plate V Grow a vocabulary waiting
the tokenizer trains when you reach it
Byte-pair encoding, running for real: the vocabulary is not designed, it is voted for by the corpus, one most-frequent pair at a time. th, ␣the, ing — watch English assemble itself by frequency, and note that a token never spans two words. Nothing here is prerecorded; every count comes from scanning your own copy of the corpus, and the millisecond figure is how long that scan took on this machine. Compression is the score — each merge shortens the corpus by one token per fusion it makes — and the first three hundred merges are exactly the vocabulary the scribe below reads, so keep merging and send it a longer one if you want to see what changes.

The game itself

Now the machine. A model that plays left to right, predicting each token from everything before it, is called autoregressive. The design gives up nothing, because probability's chain rule factors any sequence exactly:

P(x1,x2,,xT)  =  t=1TP(xtx<t)\htmlClass{eq-out}{P}(x_1, x_2, \ldots, x_T) \;=\; \prod_{t=1}^{T} \htmlClass{eq-out}{P}(x_t \mid x_{<t})

The left side is the thing we actually want — a probability for whole sentences, paragraphs, books. The right side is one small question, what comes next?, asked once per position. Answer the small question well and the identity hands you everything else.

And the answers cost nothing to grade. In Chapter 3 every training example needed a person to write down the answer — ten thousand digits, ten thousand labels. Here the label is the text itself: the covered token was there all along, put down for free by whoever wrote the sentence. Every position in every sentence is a graded exercise that nobody had to grade. This is self-supervised learning, and the zero price of its labels is precisely why it scales to the whole internet while hand-labeled datasets stall at millions.

Training scores each answer by the probability the model gave to the token that actually came; the cross-entropy is its average surprise,

L  =  1Tt=1TlogP(xtx<t)\mathcal{L} \;=\; -\,\frac{1}{T} \sum_{t=1}^{T} \log \htmlClass{eq-out}{P}(\htmlClass{eq-world}{x_t} \mid \htmlClass{eq-world}{x_{<t}})

measured in nats, the natural-log unit of surprise. Learn to read that number like a gauge: at loss 1.2 the model is, on average, as uncertain as someone choosing among e1.23.3e^{1.2} \approx 3.3 plausible next tokens. A model that knows nothing sits at lnV\ln V for a vocabulary of VV, every door held equally open; the ultramarine curve starts exactly there, and every hundredth of a nat it sheds is a regularity of English found and kept.

And the vocabulary is the one you just grew. The scribe below reads the 369 word-pieces that three hundred merges elect on this corpus — the same three hundred the plate above runs by default — so its attention rows, two plates from now, are words reading words rather than letters reading letters. If you kept merging up there, hand your longer vocabulary over with send to the scribe; a different vocabulary means a different embedding table, so the model restarts, which is the honest cost of the decision. You can also switch it back to single characters, and should at least once: it is the slow, legible version, where you can watch spelling itself get invented.

Plate VI Watch it learn to write waiting
the scribe boots when you reach it — 1.5 MB of stories, a vocabulary of word-pieces, and a small transformer built on your GPU
After every burst of forty steps the desk re-asks the same prompt at the same temperature, so the only thing that changes between samples is the weights. One token is a word-piece from the vocabulary grown two plates up, which is why sentence-shaped grammar arrives within a couple of thousand steps; switch to single characters and the same schedule runs slower, with spelling visibly invented along the way. Bits per character sits beside the loss because it is the only unit in which the two vocabularies can be compared. Ask your own question any time: temperature rescales confidence before each draw, 0.2 playing the favourite and 1.4 gambling.

From noise to grammar

If you let the scribe run, you watched an order of acquisition that nobody programmed. Word shapes first, then real words in plausible company, then clauses whose subject and verb mostly agree, and somewhere past a thousand steps a sentence you could believe a child wrote. Grammar arrived in that order for a plain reason: gradient descent spends its budget where the loss falls fastest, and short, local regularities pay off first. The curriculum fell out of prediction pressure alone.

Switch the vocabulary to characters and you can watch the layer underneath. A character model starts by learning English's letter frequencies — too many e's and spaces to be random — then pairs: q finds u, h learns to trail t and s. Only then do word shapes appear, and the whole schedule runs slower. The word-piece scribe skipped all of it, because that layer of regularity was already cashed into the vocabulary by three hundred merges: the, said and little arrive whole, leading space and all, as one token each, and spelling them is not a problem the model ever has. Same corpus, coarser atoms, longer reach — the same ninety-six-slot window now holds about two hundred and thirty characters instead of ninety-six.

There is a colder way to say what happened: the model compressed the corpus. Cross-entropy is literally a size — a nat is 1/ln21.441/\ln 2 \approx 1.44 bits — and the plate reports bits per character beside its loss so that the two vocabularies can be compared at all. Guessing uniformly among 69 characters costs 6.11 bits per character. The tokenizer alone drops that to 3.53, before a single gradient step, purely by making the guesses coarser. Training then takes it under 1.6, which is better than gzip -9 manages on the same text (2.42) and close to brotli (1.87). The honest asterisk: those two ship a self-contained file, while the scribe's bits assume you already have its weights — and a complete description would have to count those too. Prediction and compression are one skill in two vocabularies, and the loss chart doubles as a receipt for how much structure the model has taken in.

None of which is new. Shannon measured English this way in 1951 by sitting people down with covered text and asking them to guess the next letter, then turning their guesses into a number — somewhere between 0.6 and 1.3 bits per character, which is roughly where a good model sits today.7 The identity runs the other way too: hand a large language model to a compression routine and it beats the specialist formats outright, on text and — stranger — on images and audio it was never trained on.8 Something that predicts well enough is a compressor, whatever it was built to be.

You may also have noticed the scribe's register — sunny, simple, faintly like a bedtime story, whatever you prompt it with. Its whole world is 1.5 million characters of children's stories, so that is the only English in existence for it. A model is its diet. The large models everyone talks to differ from this one less in kind than in menu: they have read a substantial fraction of everything, and every register — helpful, legalistic, purple — is in there, waiting on the prompt.

The loss you watched was an average over thousands of positions, and averages hide texture. Some tokens are nearly free; some cost dearly. The meter below un-averages the number: it bills a sentence one token at a time and, for each one, shows the entropy of the model's guess — how widely it was hedging — along with the five candidates it liked best. Watch where the heat lands. A common word arriving where it is expected costs almost nothing; the expensive tokens are the ones carrying the actual news of the sentence, which is a fair working definition of information.

Plate VII The surprise meter waiting for the scribe
this plate reads the scribe from the plate above — it boots when you reach it, and starts out surprised by everything
Each token's background is what the model paid to see it — hotter is more surprising. Function words in expected places run cool; the nouns and names carrying the sentence's actual news run hot, and a word the vocabulary never learned costs most of all, because the model must spell it out of fragments. Hover or tap any token for the five candidates it was weighing there, with the one that actually came in vermilion; a leading space is drawn ␣, since “the” and “ the” are different tokens. The first token carries a dotted underline because nothing precedes it, so it is never predicted.

Inside one guess

So far the model has been a box that eats context and emits a distribution. Open it. The scribe is a transformer, the architecture behind essentially every model in this book's orbit, and a single guess travels five stages — each one visible, with real numbers, in the last plate of this chapter.

Plate VIII The transformer as a map
one block · repeated ×2once␣upon␣a␣timescoresone per token · 369softmaxthe belief␣there1token + position2q·k·v3attention4mlp5scores → belief
The whole machine as a map. Each token rides its own lane; attention is the only place lanes touch, and the curves only ever point backwards. Every lane ends in a guess — the map follows the last one, whose belief names the next token.

One: every token becomes a vector, exactly as words did in the first plate, plus a second vector encoding where it sits — attention sees a bag of tokens and has no inherent sense of order, so position must be supplied. This model supplies it the plain way, one learned vector per slot; current models mostly rotate each query and key by an angle set by its position instead, which lets attention see how far apart two tokens are rather than which slots they sit in.9 Two: each vector is projected three ways, into a query (what am I looking for?), a key (what do I offer?) and a value (what I would pass along).

Three: attention itself — and it has earned the chapter's slowest minute, because this single line is most of what the word transformer means10 :

attention(Q,K,V)  =  softmax ⁣(QKdk+M)V\mathrm{attention}(\htmlClass{eq-model}{Q}, \htmlClass{eq-model-2}{K}, \htmlClass{eq-model-3}{V}) \;=\; \htmlClass{eq-op}{\operatorname{softmax}}\!\left(\frac{\htmlClass{eq-model}{Q}\,\htmlClass{eq-model-2}{K}^{\top}}{\sqrt{d_k}} + \htmlClass{eq-mute}{M}\right)\htmlClass{eq-model-3}{V}
Plate IX Self-attention, held still
the tokens · Xonce␣upon␣a␣timevector + positionWQWKWVthree learned lensesQKV−∞scores · QKᵀ/√dₖsoftmax0attention·z · the readouta weighted blend of valuesattention(Q, K, V) = softmax(QKᵀ/√dₖ + MV
Follow the rose outline. The last token asks with its query row, is scored against every key, has its future struck out by the mask, receives a budget of exactly 1 from the softmax — and spends it on a blend of the values. That blend is all attention ever outputs.

Read it inside out. QK\htmlClass{eq-model}{Q}\,\htmlClass{eq-model-2}{K}^{\top} dots every query against every key — how well does what I'm looking for match what you offer? — one number per pair of positions, a whole table of raw affinities at once. The dk\sqrt{d_k} underneath is quiet but load-bearing: dot products of longer vectors are larger by accident of dimension, and dividing by 24\sqrt{24} here keeps the softmax from saturating into all-or-nothing before training has said anything. M\htmlClass{eq-mute}{M} is the mask — zero at and below the diagonal, -\infty above it — the game's one rule, no reading the future, enforced as arithmetic: e=0e^{-\infty} = 0, so a future token gets exactly nothing, not merely little. Then softmax\htmlClass{eq-op}{\operatorname{softmax}} — the same machine that turned scores into beliefs in Chapter 3 — runs along each row and turns it into a budget of exactly 1.0. And multiplying by V\htmlClass{eq-model-3}{V} spends the budget: each token's output is a weighted blend of what earlier tokens offered to pass along.

Two things about this line repay staring. It is the only place in the whole architecture where tokens touch — everywhere else each position is processed alone. And it contains no parameters: everything learnable lives in the three lenses WQ,WK,WVW_{\htmlClass{eq-model}{Q}}, W_{\htmlClass{eq-model-2}{K}}, W_{\htmlClass{eq-model-3}{V}} that manufacture the queries, keys and values, so what training changes is not how attention works but what each token asks for and offers. The scribe runs this line four times per block — four heads, each in its own 24 dimensions, each free to learn a different sense of relevance — and you can watch their real rows disagree in the last plate.

Four: each token thinks alone. Its vector is widened fourfold, rectified — negatives clipped to zero — and squeezed back to size; most of the parameters live here. Stages two through four form one block, and blocks stack: this model has two, frontier models roughly a hundred. Five: the final vector meets one last matrix that turns 96 numbers into one score per token in the vocabulary, and a softmax turns scores into probabilities. Draw one, append it, run the pass again. That loop is all "generating text" has ever meant.

That list of five leaves out what happens between the blocks, and it is the whole shape of the thing. A block does not hand its output onward. It adds to what it was given: attention computes something and adds it in, the little network computes something and adds it in, and the vector for each token runs the entire length of the model, picking up contributions along the way. What travels through a transformer is not a signal being transformed stage by stage but a shared channel — a residual stream — that every block reads from and writes into.11 It is why depth degrades gracefully rather than catastrophically: a block with nothing useful to say can write approximately nothing and cost the model almost nothing. And it is the reason interpretability work talks about what a particular head writes to the stream, as though the model were a workshop of specialists sharing one notebook. Which, read this way, it is.

One thing rides along with that picture. Because every block adds, the stream grows: by the last block a token's vector is the sum of everything written into it, at whatever size that came to. So a block does not read the stream raw — it reads a rescaled copy, normalized to a predictable size, while the stream itself passes through untouched. Two lines of arithmetic, and where they sit is not a detail: put the rescaling between the blocks instead of inside them and the gradients near the output blow up at the start of training, which is why the early transformers needed a careful warm-up to survive their own first steps.12 Moving it inside is why a hundred blocks stack without one.

Plate X One forward pass, opened up waiting for the scribe
this plate opens up the scribe from the plate above — it boots when you reach it
The five stages a token travels through on its way to a prediction. The shapes are this model's real architecture; the attention rows and the final distribution are real numbers, read from the weights you trained above — not an illustration of a transformer, but a reading of one. Because the vocabulary is word-pieces, the attention grid is words reading words: look for a verb attending to its subject, or a name being carried forward. Stages two through four form one block, and this model stacks two of them; frontier models stack the same block roughly a hundred deep, with vectors thousands of numbers wide, and nothing else about the picture changes.

The same game, a billionfold

Everything in this chapter scales without changing shape. Take the scribe's loss, its update rule θθηθL\htmlClass{eq-model}{\theta} \leftarrow \htmlClass{eq-model}{\theta} - \htmlClass{eq-knob}{\eta} \htmlClass{eq-world}{\nabla_\theta \mathcal{L}}, the five stages you just walked; multiply the parameters by a few million, the corpus by a billion, and the training run by months on thousands of GPUs — and you have the large language models everyone talks to. They descend the same cross-entropy on the same next-token game, and their loss charts look like yours with more zeros on the axis. What you trained here is not a metaphor for them. It is one of them, small.

That the multiplying works is not a hope; it is a measured curve. Loss falls as a power law in parameters, in data and in compute, and it stays a power law across seven orders of magnitude — straight lines on a log plot, straight enough that a run's final loss can be predicted before it starts.13 Straight lines are what made the spending defensible. They are also easy to read wrong: for two years the field built models far larger than the text it was feeding them, until the measurement was redone more carefully and the recommended trade between size and data moved sharply toward data.14 A law with the wrong constants still looks like a law.

Scale buys a continuation of exactly what you watched: fluency first, then knowledge — because past a certain point the cheapest way to keep shaving nats off "the capital of France is ____" is to know the capital of France. It does not buy truth, since the objective rewards the plausible continuation and confident nonsense is often the most plausible continuation of confident nonsense. And nowhere in L\mathcal{L} is there a goal: nothing in the game prefers being helpful, or honest, or anything at all beyond sounding like the diet.

That is not a flaw in the training so much as a boundary of it. Prediction has no preferences. To give a model preferences — to make it want to be useful rather than merely likely — you need a signal that judges outcomes instead of continuations: a reward. Consequences are a different teacher, and they get the next chapter.

Sources

  1. 1 A Neural Probabilistic Language Model Bengio et al. · 2003 · JMLR 3 · jmlr.org Twenty years early: learn a vector per word and predict the next one with a neural network, so that a sentence never seen can borrow from a sentence that was.
  2. 2 Efficient Estimation of Word Representations in Vector Space Mikolov et al. · 2013 · ICLR 2013 workshop · arXiv:1301.3781 word2vec. The models are deliberately shallow — the point of the paper is that throwing away the hidden layer let them train on a hundred billion words.
  3. 3 Distributed Representations of Words and Phrases and their Compositionality Mikolov et al. · 2013 · NeurIPS 2013 · arXiv:1310.4546 Negative sampling — the loss written out in this chapter — and the paper that put the analogy arithmetic in front of everyone.
  4. 4 Neural Word Embedding as Implicit Matrix Factorization Levy & Goldberg · 2014 · NeurIPS 2014 · papers.nips.cc Shows that skip-gram with negative sampling is quietly factorising a word-by-context table of co-occurrence statistics. The neural part is a way of doing the arithmetic, not the source of the magic.
  5. 5 Issues in evaluating semantic spaces using word analogies Linzen · 2016 · RepEval 2016 · arXiv:1606.07736 The famous analogy result is doing less work than it appears to: the standard scoring rule forbids the answer from being any of the three input words, and much of the accuracy comes from that exclusion rather than from the arithmetic.
  6. 6 Neural Machine Translation of Rare Words with Subword Units Sennrich, Haddow & Birch · 2016 · ACL 2016 · arXiv:1508.07909 Byte-pair encoding was a data-compression trick from 1994. This is the paper that pointed it at vocabulary, and every tokenizer since is a variation on it.
  7. 7 Prediction and Entropy of Printed English Shannon · 1951 · Bell System Technical Journal 30(1) · princeton.edu The next-token game, played by people, in 1951 — Shannon sat readers down with covered text and had them guess the next letter, and turned their guesses into a measurement of English itself.
  8. 8 Language Modeling Is Compression Delétang et al. · 2023 · ICLR 2024 · arXiv:2309.10668 Takes the identity literally and uses a language model as a general-purpose compressor. It beats the specialist formats — on text, and, oddly, on images and audio it was never trained on.
  9. 9 RoFormer: Enhanced Transformer with Rotary Position Embedding Su et al. · 2021 · Neurocomputing 568 · arXiv:2104.09864 How position is actually supplied in current models: rotate each query and key by an angle proportional to its position, so what attention sees is the distance between two tokens rather than their absolute slots.
  10. 10 Attention Is All You Need Vaswani et al. · 2017 · NeurIPS 2017 · arXiv:1706.03762 The transformer. The title is an argument: everything before it wrapped attention around a recurrent network, and the finding was that you could throw the recurrence away.
  11. 11 A Mathematical Framework for Transformer Circuits Elhage et al. · 2021 · Anthropic · transformer-circuits.pub Where the residual-stream reading of a transformer is set out carefully: not a pipeline that transforms a vector but a shared channel that every block reads from and adds to.
  12. 12 On Layer Normalization in the Transformer Architecture Xiong et al. · 2020 · ICML 2020 · arXiv:2002.04745 Where the norm goes turns out to matter more than what it is. Put it between the blocks and the gradients near the output blow up at initialization, so the run needs a warm-up to survive its own first steps; put it inside, before each read, and they are well behaved from the start. The scribe uses the second arrangement, with RMSNorm in place of the original.
  13. 13 Scaling Laws for Neural Language Models Kaplan et al. · 2020 · arXiv preprint · arXiv:2001.08361 Loss falls as a power law in parameters, data and compute, over seven orders of magnitude. The straightness of those lines is the reason anyone was willing to spend the money.
  14. 14 Training Compute-Optimal Large Language Models Hoffmann et al. · 2022 · NeurIPS 2022 · arXiv:2203.15556 Chinchilla. Redid the measurement and found the field had been building models far too large for the amount of text it was feeding them — a correction worth more than most architectural ideas of the same period.