LLMs & Generative AI
Transformer Architecture
A Transformer processes tokens through repeated attention and feed-forward blocks. Attention lets each token mix information from other tokens, which made large-scale language modeling dramatically more effective.
- Self-attention computes token-to-token relevance
- Multi-head attention learns multiple relationship types
- Position information is added explicitly
- Feed-forward layers transform each token representation
- Residual connections and normalization make deep stacks trainable
- Decoder-only Transformers predict the next token
| Part | Job |
|---|---|
| Embeddings | Represent tokens as vectors |
| Position encoding | Expose token order |
| Attention | Route information between tokens |
| Feed-forward network | Transform token representations |
| Residuals | Preserve signal across depth |
| Layer normalization | Stabilize training |