Attention Is All You Need
Ashish Vaswani, Noam Shazeer, Niki Parmar, Jakob Uszkoreit, Llion Jones, Aidan N. Gomez, Lukasz Kaiser, Illia Polosukhin
NeurIPS 2017 · arXiv 1706.03762 · Read the paper ↗
The paper that replaced recurrence with attention. Every modern LLM is a stack of the blocks you build here.
8 steps · 0 solved
Start: Positional encoding →- 1Positional encodingInject token order with fixed sine and cosine waves.Generate sinusoidal position encodings
- 2Scaled dot-product attentionScore queries against keys, scale by sqrt(d_k), mask, softmax, mix values.GPT decoder: causal self-attention for one head
- 3Split and merge headsReshape one projection into h heads and back.Split and merge attention heads
- 4Multi-head attentionRun attention in parallel heads, for self and cross attention.Write multi-head attention that works for self and cross attention
- 5Layer normalizationNormalise each token's features to zero mean and unit variance.Implement LayerNorm forward
- 6Encoder blockAttention, feed-forward, residuals and post-norm, as in the paper.Implement the original post-norm transformer block
- 7Warmup learning rateThe paper's warmup then inverse square root schedule.Compute the Noam warmup learning rate
- 8Label smoothingThe regularised cross-entropy used to train the model.Cross-entropy with label smoothing from raw logits
More transformers and llms papers
- LoRA: Low-Rank Adaptation of Large Language Models 2021
- FlashAttention: Fast and Memory-Efficient Exact Attention with IO-Awareness 2022
- RoFormer: Enhanced Transformer with Rotary Position Embedding 2021
- Direct Preference Optimization: Your Language Model is Secretly a Reward Model 2023
- Switch Transformers: Scaling to Trillion Parameter Models with Simple and Efficient Sparsity 2021
- Fast Inference from Transformers via Speculative Decoding 2022
- LLM.int8(): 8-bit Matrix Multiplication for Transformers at Scale 2022