LLMs

Transformer

A transformer is a sequence architecture built around attention and position-wise feed-forward blocks.

Input embeddings + positionsMulti-head attentionFeed-forwardRepeat block × NOutput probabilities
A transformer is a sequence architecture built around attention and position-wise feed-forward blocks. Values shown in the worked visual are illustrative unless the labels state otherwise.

How it works

Attention exchanges information across positions, while feed-forward layers transform each position. Residual paths and normalization stabilize the stack.

A concrete example

Illustrative: 24 blocks process a sequence of 2,048 tokens at model width 2,048.

Do not confuse it with RNN

a transformer processes attention relationships directly; an RNN carries a recurrent state step by step.

Study the full lesson