Transformers from Scratch
The full series in one post: why attention replaced recurrence; every building block of the Transformer — intuition, formula, PyTorch code, a numpy reference and an honest FLOPs count; then the assembled model, trained on a toy task, with the memory costs and the KV-cache explained.