Chapter 24: Research & Cutting-Edge Techniques¶
Read and reproduce frontier work: implement scaled dot-product attention and a mixture-of-experts router from scratch in NumPy, and learn to turn papers into code.
Metadata¶
| Field | Value |
|---|---|
| Track | Advanced |
| Time | 8 hours |
| Prerequisites | Chapters 1, 9, 11, 18 |
Learning Objectives¶
- Read a paper efficiently — abstract, figures, equations, then details
- Translate equations to code and verify against mathematical invariants
- Implement scaled dot-product attention and confirm its softmax properties
- Implement mixture-of-experts top-k gating and sparse expert combination
- Reason about scaling — why MoE buys capacity without proportional compute
- Sanity-check implementations with shape and probability assertions
- Survey current frontiers — long context, MoE, multimodality, reasoning
- Plan a reproduction of a paper end to end
What's Included¶
Notebooks¶
| Notebook | Description |
|---|---|
01_reading_papers.ipynb | A method for reading papers and turning equations into verified code |
02_attention_from_scratch.ipynb | Scaled dot-product attention, the core of the transformer |
03_mixture_of_experts.ipynb | Top-k gating and sparse expert combination |
Scripts¶
config.py— Chapter config: seeds, model dimensionsattention.py— Numerically stable softmax and scaled dot-product attentionmoe.py— Top-k gating and sparse mixture-of-experts forward pass
Exercises¶
- Problem Set 1: Attention — Verify softmax invariants and attention output shape
- Problem Set 2: Mixture of Experts — Check top-k routing and the sparse forward pass
- Solutions — in
exercises/solutions/(notebooks andsolutions.pyfor CI)
Diagrams (Mermaid)¶
attention.mermaid,moe.mermaid
Read Online¶
- 24.1 Introduction — A method for reading papers and turning equations into verified code
- 24.2 Intermediate — Scaled dot-product attention, the core of the transformer
- 24.3 Advanced — Top-k gating and sparse expert combination
Or try the code in the Playground.
How to Use This Chapter¶
Quick Start
Clone the repo, install dependencies, and open the first notebook.
git clone https://github.com/luigipascal/berta-chapters.git
cd berta-chapters/chapters/chapter-24-research-and-cutting-edge-techniques
pip install -r requirements.txt
jupyter notebook notebooks/01_reading_papers.ipynb
GitHub Folder
All chapter materials live in: chapters/chapter-24-research-and-cutting-edge-techniques/
Created by Luigi Pascal Rondanini | Generated by Berta AI