Lesson 4 of 12 · 2 min
Transformer Architecture
Original paper: "Attention Is All You Need" (Vaswani et al., 2017)
High-level structure:
[Input tokens]
↓
[Embedding + Positional Encoding]
↓
[Encoder Block × N] [Decoder Block × N]
- Multi-head Self-Attention - Masked Self-Attention
- Feed-Forward Network - Cross-Attention (to Encoder)
- Layer Norm - Feed-Forward Network
↓ ↓
[Encoder Output] [Decoder Output → Linear → Softmax]Encoder: Understands input. Used in BERT, classification models.
Decoder: Generates output one token at a time. Used in GPT models.
Encoder-Decoder: Full transformer. Used in T5, translation models.
