Transformer

Step through the full architecture — embeddings, attention, MLP, residual connections, layernorm — watching one token’s vector transform at every stage on its way to logits.

A transformer is a stack of identical blocks, each doing two things: attention (tokens exchange information) and an MLP (each token thinks on its own). Residual connections add each block's output onto a running stream instead of replacing it, which is what makes very deep stacks trainable.

This workspace walks a sentence through embeddings, three transformer blocks, and the final unembedding to logits, tracking one token's vector as a heat-strip that visibly changes at every stage. The residual additions, layer normalisations, and final softmax are computed for real; the attention and MLP outputs are authored (they are what a real model learns).

Open the interactive Transformer workspace →