How all of this was invented
The rest of the project tells you why each idea had to exist: a logical chain where every stage solves the wall the previous one hit.
This document tells you something else: when, who, and against what resistance. Because that logical chain, which now looks obvious, took eighty years to walk — with two collapses of the field along the way, correct ideas ignored for decades, and at least three people who were right twenty years before anybody listened.
Reading it changes the meaning of what you have built.
1943-1958 · That a neuron can be computed
1943 · McCulloch and Pitts. A neurophysiologist and a logician publish a mathematical model of the neuron: it sums inputs, compares against a threshold, fires or does not. They prove that a network of those can compute any logical function. It is the first time anybody says, with the maths in front of them, that thought might be computation.
There were no computers to test it on.
1949 · Donald Hebb. He proposes how the brain learns: "neurons that fire together, wire together". It is the first learning rule, and it is still the underlying intuition behind everything we do: adjust connections according to experience.
1958 · Frank Rosenblatt · the Perceptron. This is where it really begins. Rosenblatt builds the Mark I Perceptron: a physical machine, with potentiometers driven by electric motors as weights, that learns to classify simple images. And he proves the perceptron convergence theorem: if the data is separable by a line, the algorithm finds that line. Guaranteed.
What you build in
etapas/00_calentamiento/01_que_es_aprender.pyis, essentially, a perceptron with squared loss. Sixty-seven years later, the idea is the same: adjust numbers to bring an error down.
The press goes wild. The New York Times writes in 1958 that the Navy expects a machine able to "walk, talk, see, write, reproduce itself and be conscious of its existence". Rosenblatt does not deny it firmly enough.
That overreach is going to cost dearly.
1969-1980 · The first winter
**1969 · Minsky and Papert · Perceptrons. Marvin Minsky and Seymour Papert publish a rigorous mathematical analysis of what a single-layer perceptron can and cannot do. And they find the hole: XOR**. A perceptron only draws lines, and no line separates the ones from the zeros of XOR.
It is exactly the experiment in
etapas/00_calentamiento/03_xor_a_mano.py. You have watched it fail with your own eyes: the model gives up and predicts 0.500 for everything.
The nuance that almost always gets told wrong. Minsky and Papert knew that a network with hidden layers solves XOR — they say so in the book. Their argument was a different one: no algorithm was known for training those hidden layers. Rosenblatt's convergence theorem only held for one layer. For several, there was nothing.
They were right. But the effect of the book was devastating: funding for neural networks evaporated in the United States and the United Kingdom. Added to the Lighthill report (1973), which was brutal about British AI in general, the field enters its first winter.
Rosenblatt dies in 1971, in a boating accident, at 43. He never saw the answer.
1970 · Seppo Linnainmaa. A Finnish student publishes, in his master's thesis, the reverse mode of automatic differentiation: how to compute the derivatives of a composite function by walking the graph backwards.
That is backpropagation. It is published. In 1970. And nobody in the neural network field connects it to Minsky's problem for 16 years.
1974 · Paul Werbos. In his Harvard doctoral thesis, he explicitly applies that idea to training multilayer neural networks. The answer to the challenge in Perceptrons is written down, with a name attached, five years after the book.
Nobody pays attention. The field is dead and nobody is reading neural network theses.
1980 · Kunihiko Fukushima · the Neocognitron. In Japan, away from the epicentre of the winter, Fukushima builds an architecture with convolutional and pooling layers, inspired by the visual cortex. It is the direct ancestor of convolutional networks. What it lacks is backpropagation to train it properly.
1986-1998 · The thaw, and the second winter
1986 · Rumelhart, Hinton and Williams. They publish in Nature "Learning representations by back-propagating errors". They do not invent backpropagation — Linnainmaa and Werbos were already there — but they do something that turned out to be more important: they show that it works, on real problems, and explain it in a way the whole field understands.
And there is a detail that gives the paper its title and that is the heart of everything: they show that hidden layers learn useful representations on their own. Nobody tells them what to detect. They discover it.
It is exactly what you see in the final table of
etapas/00_calentamiento/03_xor_a_mano.py: each hidden neuron specializes in something, and in that new space the problem becomes easy.
The winter breaks. There is an explosion of work in the late 1980s.
1989 · Yann LeCun. He applies backpropagation to a convolutional network to read handwritten postcodes. It works in production: through the 1990s, a significant share of US bank cheques is read with that technology. It is the first big commercial success of deep learning, and almost nobody remembers it.
1991 · Sepp Hochreiter. In his diploma thesis he identifies the vanishing gradient problem: backpropagating through many layers or many time steps, the gradient gets multiplied by factors smaller than one and reaches zero. Deep networks cannot be trained.
You measure it in
etapas/07_entrenamiento/02_inicializacion.py: with the wrong initialization scale and no residual connections, the gradient at layer 1 is exactly 0.0. Not small: zero, down to the last bit.
1997 · Hochreiter and Schmidhuber · LSTM. The solution for sequences: a cell with gates deciding what to remember and what to forget, with a path along which the gradient flows without being multiplied. It is going to dominate language processing for fifteen years.
1998 · LeNet-5. LeCun publishes the mature convolutional architecture.
And then, once again, the field collapses. Second winter, for different reasons: support vector machines (SVMs) and kernel methods work better at almost everything, have beautiful theoretical guarantees and need no tricks or luck. Neural networks need data and compute that do not exist, and they are seen as alchemy.
Through the 2000s, saying you worked on neural networks was a bad idea for your academic career. Hinton, LeCun and Bengio carry on. They are a minority.
2003-2012 · The crossing and the explosion
2003 · Bengio, Ducharme, Vincent and Jauvin. "A Neural Probabilistic Language Model". Here is the seed of everything you use today.
The problem: n-gram models do not scale (the table explodes exponentially with the context). Bengio's solution: do not give each word a cell, give it a vector. Similar words end up with similar vectors, and the model generalizes to combinations it never saw.
It is the whole of stage 04. And the wall it breaks is one you measure yourself in stage 02: with 5 characters of context, the count table would take 600 GB and be almost entirely zeros.
2006 · Hinton. Deep belief networks and layer-by-layer pre-training. Technically it was superseded almost immediately, but it had an enormous sociological effect: it gave the area its respectability back. The rebranding as "deep learning" comes from here, partly to avoid the stigma of "neural networks".
2009 · Fei-Fei Li · ImageNet. 14 million hand-labelled images. The bet, against the grain at the time: the bottleneck is not the algorithms, it is the data.
She was right, and it is the lesson repeated most often in this project.
2010 · Glorot and Bengio. The analysis of why the initialization scale matters, and which one is correct.
The
1/√fan_inequation thatmininn/nn.pyuses comes from here.
2012 · AlexNet. The turning point.
Alex Krizhevsky, Ilya Sutskever and Geoffrey Hinton win ImageNet with a 15.3% error against 26.2% for the runner-up. In a competition where people fought over tenths of a point, eleven points of difference.
There was no brilliant new idea. There were four old things finally put together:
- GPUs. They trained on two gaming GeForce GTX 580s. That is the connection between 3D graphics and modern AI, and it is not metaphorical: the same operations.
- Data. ImageNet.
- ReLU instead of sigmoid: derivative 1 on the positive side, the gradient does not vanish.
- Dropout so it does not memorize.
Three of the four are in your code:
mininn/tensor.pyhas ReLU,mininn/nn.pyhas Dropout, and stage 06.4 shows you what changes when you use the GPU (16.8× faster, measured on your machine).
The field changes overnight. Within two years, everybody is doing deep learning.
2013-2017 · The road to the transformer
2013 · Mikolov · word2vec. Word embeddings you can train at scale, and the result that went around the world: king − man + woman ≈ queen. The geometry of the space encodes meaning.
You measure it in
etapas/04_mlp_lenguaje/02_ver_embeddings.py, with an awkward result: in the input matrix the vowels do not cluster (65.7% against 64.7% for chance) and in the output one they do (81.0%). The tutorial version of word2vec usually skips that distinction.
2014 · An extraordinary year.
- Sutskever, Vinyals and Le · seq2seq. Machine translation with two LSTMs: one encodes the whole sentence into a vector, the other decodes it. It works.
- Bahdanau, Cho and Bengio · attention. And they find seq2seq's flaw: stuffing a 50-word sentence into a single vector loses information. Their solution: let the decoder look at every position in the input and weight which ones interest it at each step.
Attention is born there. Not as a grand theory, but as a patch for a specific bottleneck.
- Kingma and Ba · Adam. The optimizer that has dominated everything since.
> You measure it in etapas/07_entrenamiento/01_optimizadores.py: SGD 2.68 · > momentum 2.25 · AdamW 1.93, with the same model and the same seed.
- Goodfellow · GANs. Another branch, which will end up leading to image generation.
2015 · He, Zhang, Ren and Sun · ResNet. The x + f(x) trick. It makes 152 layers trainable when the previous record was around 20.
You measure it in
etapas/07_entrenamiento/02_inicializacion.py, with a nuance the popular version of the story skips: with perfect initialization, a deep network without residuals does train too. What residuals contribute is not "fixing" the gradient, it is making training robust to the details. You stop having to get it right.
2016 · Sennrich, Haddow and Birch. They adapt BPE — a compression algorithm from 1994 — to subword tokenization. It solves the problem of never-before-seen words.
That is your stage 01. And the observation that makes it lovely: the algorithm only counts frequent pairs, and discovers
'tion','ing',' the',' of'on its own. Nobody teaches it morphology.
**2017 · Vaswani and seven others · "Attention Is All You Need".**
The paper that changes everything, and it is worth knowing where it came from: it was a piece of work on machine translation at Google. The practical problem they were attacking was that LSTMs are sequential — to process word 50 you have to have processed the previous 49 — and that wastes GPUs, which are machines for massive parallelism.
Their proposal: throw out recurrence entirely and keep only attention, which does parallelize. Hence the title, which was half a provocation.
Nobody foresaw what was coming. The paper talks about BLEU on English-German translation. It does not mention general language models, or chat, or anything of the sort.
That is your stage 05, and you derive it step by step by solving concrete problems, without copying the formula. Including the
1/√dk, which looks decorative and which you measure: without it, at dk=64, the softmax entropy is 0.000 and the gradient dies.
2018-2022 · Scale
2018 · Two roads.
- GPT-1 (Radford, OpenAI): the transformer decoder only, pre-trained to predict the next token, then fine-tuned.
- BERT (Devlin, Google): the encoder only, pre-trained by masking words at random.
BERT wins almost everything in 2018-2019 and looks like the future. But BERT does not generate text: it only understands. OpenAI's bet on the pure decoder was, at that moment, the less promising of the two.
Your GPT is the GPT-1 road.
etapas/06_transformer/gpt.py.
2019 · GPT-2. OpenAI announces the model is "too dangerous to release" and publishes it in stages. The episode generates an enormous debate about responsible publication, and seen from today it is almost endearing: GPT-2 is smaller than many models that now run on a laptop.
2020 · GPT-3 and the scaling laws.
- Kaplan et al. publish the scaling laws: the loss follows a power law with respect to parameters, data and compute. No visible ceiling and predictable. That is what convinces investors that spending a billion euros makes sense.
- GPT-3: 175 billion parameters. And the discovery nobody expected: in-context learning. You put three examples in the prompt and it does the task, with no additional training.
That was not designed. It emerged.
> And today we know a fair amount about why: induction heads, which > detect the pattern "A B … A" and predict "B". You can hunt for them in your > own model with etapas/06_transformer/03_ver_atencion.py.
2021 · Hu et al. · LoRA. Fine-tuning an enormous model by training two tiny matrices. It democratizes fine-tuning.
Your stage 09.2. With the detail that makes it work:
Bis initialized to zeros, so the model starts out identical to the original. You measure it: difference 0.00e+00.
2022 · The year that changed the public.
- Chinchilla (Hoffmann, DeepMind): GPT-3 was badly undertrained. The optimum is ~20 tokens per parameter, not 1.7. With the same compute, a well-trained 70,000 M model beats a badly trained 175,000 M one.
> Your stage 06.4 applies this arithmetic for real: it generates 77 M tokens > for a 4.2 M model, and you can see the result — training 0.2304 against > validation 0.2387, no overfitting.
- InstructGPT (Ouyang): RLHF. A base model does not answer, it continues text. Teaching it to obey using human preferences is what turns it into something usable.
> Your stages 09 and 10.
- 30 November 2022 · ChatGPT. Technically it was nothing new: InstructGPT with a chat box in front of it. But the interface mattered more than the model. A hundred million users in two months.
The change was not an idea. It was putting the idea within everybody's reach.
2023-2025 · Openness, efficiency, reasoning
2023.
- GPT-4. No technical details published. It is believed to be a mixture of experts.
- LLaMA (Meta): weights accessible for research. It leaks within a week, and with that the whole local ecosystem is born at once: llama.cpp, aggressive quantization, home fine-tuning. LLaMA 2 arrives with a commercial licence.
- DPO (Rafailov, Stanford): preference alignment without reinforcement learning or a reward model. An ordinary supervised loss.
> Your stage 10. 86.2% → 97.0% preference accuracy, measured.
- Mistral 7B: proves that a small model done well beats a large one done badly.
2024.
- Mixtral: an open mixture of experts. 47,000 M parameters, computes like a 13,000 M one.
- LLaMA 3: 15 trillion tokens — 1,875 per parameter, miles from the Chinchilla optimum. On purpose: if you are going to serve it to millions of people, what dominates total cost is inference, not training.
- Contexts of 128k and beyond. Multimodality as a matter of course.
2025 · Compute moves to answering time.
The most important conceptual change since the transformer itself: reasoning models. Instead of answering immediately, the model generates many thinking tokens first. And since every token is a complete pass through the network, generating more tokens is literally thinking more.
What is new is how it is trained: RL with verifiable reward. In maths and code the answer can check itself, so no humans are needed. The model generates thousands of attempts, the ones that get it right are rewarded, and it discovers strategies on its own like checking its work or backtracking when it goes wrong.
A second scaling law appears: no longer just "more training, better", but "more compute when answering, better".
Your project does not implement it, but it is explained in
docs/08-mas-alla.md. And note that it requires no new architecture: it is the same transformer you have built, trained with a different objective.
Five lessons the history makes clear
1. Correct ideas can wait decades. Backpropagation was published in 1970 and was not used until 1986. LeCun had convolutional networks running in production in 1989 and the field collapsed anyway. Being right is not enough; the rest of the world has to be ready.
2. Hardware and data almost always win, not the algorithm. AlexNet invented almost nothing: it put known things together when GPUs and ImageNet finally existed. The lesson repeats in your own project — experiment D in etapas/07_entrenamiento/03_sobreajuste.py shows that more data beats any regularization trick.
3. Advances come from fixing a concrete problem, not from grand visions. Attention was born to fix a bottleneck in translation. The transformer was born because LSTMs wasted GPUs. Nobody was designing ChatGPT.
4. The winters came from over-promising. The 1958 Perceptron was going to be conscious. The funding left when it became clear it would not. Worth keeping in mind right now.
5. And the thing that should surprise you most: the transformer of 2017 is still the transformer of today. RoPE, GQA, MoE, reasoning... all of it is optimization around a core that has not changed.
That core is the one you wrote. And stage 06.4 proves it to you by loading your weights into PyTorch: relative difference 1.0e-06.
To read the sources
The original papers, in order of impact on what you have built:
| Year | Paper | What it gave you |
|---|---|---|
| 1986 | Rumelhart, Hinton, Williams · Learning representations by back-propagating errors | stage 03 |
| 2003 | Bengio et al. · A Neural Probabilistic Language Model | stage 04 |
| 2015 | He et al. · Deep Residual Learning | residual connections |
| 2016 | Sennrich et al. · Neural MT of Rare Words with Subword Units | stage 01 |
| 2017 | Vaswani et al. · Attention Is All You Need | stages 05 and 06 |
| 2020 | Kaplan et al. · Scaling Laws for Neural Language Models | docs/04 |
| 2021 | Hu et al. · LoRA | stage 09.2 |
| 2022 | Hoffmann et al. · Training Compute-Optimal LLMs (Chinchilla) | stage 06.4 |
| 2022 | Ouyang et al. · InstructGPT | stages 09 and 10 |
| 2023 | Rafailov et al. · Direct Preference Optimization | stage 10 |
Nearly all of them are on arXiv and free. And now that you have written the code, they read differently: you recognize the equations because you have debugged them.
Next: 10-lo-que-no-cubre.md