flâneur — a map of the web's best reading

You Could’ve Invented Transformers, by Gwern · Gwern.net

gwern.net. · 1,924 words · saved by 1 readers

There are many Transformer⁠ tutorials (⁠eg⁠), but they generally focus on presenting a relatively contemporary implementation. This leaves the reader a bit mystified: this complex assemblage of MLPs and self-attention layers and normalization appears to have ‘dropped out of the sky’. How could Noam Shazeer and the other authors have invented the Transformer—divine benevolence (as all else)? Why does this complicated Transformer head block work so well for sequence prediction? Which parts are required, and which are there for optimization purposes? The Transformer was discovered by a huge amount of trial-and-error⁠ (much like resnets⁠), so following the historical sequence is neither possible nor enlightening. However, at this point, I believe we now understand Transformers & variations well enough that we can invent an imaginary history of Transformers for pedagogical purposes, in the vein of the “You Could Have Invented X” snowclone⁠ (eg. monads⁠, parser combinators, zippers, Fenwick

--- title: 'You Could’ve Invented Transformers' author: Gwern description: "Proposal for a ‘You Could Have Invented Transformers’ tutorial; someone should write a series showing a logical recreation of Transformers from primitive n -gram language models to full-strength Transformers." created: 2025-05-25 modified: 2025-05-25 status: finished importance: N/A confidence: log css-extension: dropcaps-de-zs toc-not backlink: True ... There are many [Transformer](https://arxiv.org/abs/1706.03762#google "‘Attention Is All You Need’, Vaswani et al 2017") tutorials ([eg](/gpt-2#transformer-tutorial)),

Explore this link on the map →

related reading