Generative AI
Generating is predicting
The most surprising sentence about generative AI is this: it generates nothing. It predicts.
A program that estimates tomorrow's electricity consumption does essentially the same thing as a program that writes a text. Both are given a sequence of values and estimate the next one. The only difference lies in what you do with the estimate. In forecasting you simply read it off. In generating you append it to the sequence and ask again: and what comes now?
Out of this single feedback loop comes everything that is sold today as generative AI. A text generator is a weather forecast for words, applied over and over to its own output.
The question: how does a machine remember what came before?
For the prediction to succeed, the program has to know the context. The next measurement depends on the previous ones, the next word on the sentence so far. An ordinary neural network cannot do this: it only ever sees one fixed input and has no memory. The whole development of the past thirty years can be read as a struggle over this memory.
Recurrent networks: the loop
The first answer was recurrent networks (RNN). The network processes the sequence step by step and feeds its own intermediate result back in as an additional input. This state is its short-term memory.
The idea is elegant and works badly. With long sequences the information from the beginning fades, because at every step it is pushed through the same computation again. The network forgets the start of the sentence before the sentence has ended.
LSTM: forgetting on purpose
The second answer came in 1997 from Sepp Hochreiter and Jürgen Schmidhuber: the Long Short-Term Memory.1 They added small gates to the loop, and the gates are themselves learned. One gate decides what is taken into memory, a second what is deleted, a third what is passed to the outside.
An LSTM can therefore learn to hold on to a detail across a hundred words and to drop the unimportant at once. This made machine translation, speech recognition in the telephone and usable text prediction work for the first time.
Two drawbacks remained. The model works through the sequence strictly one item after another, so it can hardly be spread across many processor cores. And everything it wants to retain out of a thousand words has to fit through a single memory state: a bottleneck.
Attention: looking at everything at once
The third answer threw out the bottleneck. Instead of squeezing the past into a single state, the model is allowed at every step to look back at all previous positions and to weigh for itself which ones matter right now. This weighting is called attention.
At the word "she" in a long paragraph, the model looks for the place the word refers to and weights it highly. Nothing has to be handed along through a hundred steps; the reference is established directly.
In 2017 a group at Google showed that the loop can be dropped entirely and that attention alone suffices.2 The result is called the transformer. Because no step has to wait for the previous one any more, training can be distributed across thousands of graphics cards. It is precisely this parallelisability, not any special cleverness of the architecture, that made today's large models possible.
Not only text
Images usually come about differently, following the same basic idea. In diffusion, a model learns to remove noise from an image step by step.3 To generate, you start with pure noise and let the model denoise until an image stands there. Here too nothing is invented; in many small steps the model predicts how things continue.
What follows from this in practice
- Different answers: the estimated probabilities are sampled from. How strongly is governed by a value called the temperature. That is why asking the same question twice is twice the same procedure but not the same answer.
- Invented sources: the model produces what plausibly continues, not what is true. An invented reference follows the same statistics as a real one.
- Window size matters: whatever lies outside the text window under consideration does not exist for the model.
- The beginning determines a lot: because every output is appended to the sequence so far, the opening colours everything that follows. This is why the wording of a request has such a strong effect.