Skip to content

Commit 721d55a

Browse files
committed
Replace Week 7 GPT content with diffusion models (lectures 21-23, animations, notebook, cross-refs)
1 parent 7daaf19 commit 721d55a

288 files changed

Lines changed: 7343 additions & 2192 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

admin/syllabus.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ We strive to create an inclusive learning environment where all students feel su
119119
| 4 | Jan 26--30 | Word Embeddings, Contextual Embeddings, Dimensionality Reduction | [Assignment 2](https://contextlab.github.io/llm-course/assignments/assignment-2/) due (Jan 26) |
120120
| 5 | Feb 2--6 | Attention Mechanisms, Transformer Architecture | [Assignment 3](https://contextlab.github.io/llm-course/assignments/assignment-3/) due (Feb 6), [Assignment 4](https://contextlab.github.io/llm-course/assignments/assignment-4/) released (Feb 6) |
121121
| 6 | Feb 9--13 | BERT Deep Dive, Encoder Models | |
122-
| 7 | Feb 16--20 | GPT Architecture, Scaling Up, Implementation | [Assignment 4](https://contextlab.github.io/llm-course/assignments/assignment-4/) due (Feb 16), [Final Project](https://contextlab.github.io/llm-course/assignments/final-project/) released (Feb 16), [Assignment 5](https://contextlab.github.io/llm-course/assignments/assignment-5/) available (optional/extra credit) |
122+
| 7 | Feb 16--20 | Diffusion Models, Extensions, Applications & Ethics | [Assignment 4](https://contextlab.github.io/llm-course/assignments/assignment-4/) due (Feb 16), [Final Project](https://contextlab.github.io/llm-course/assignments/final-project/) released (Feb 16), [Assignment 5](https://contextlab.github.io/llm-course/assignments/assignment-5/) available (optional/extra credit) |
123123
| 8 | Feb 23--27 | **No classes** (instructor away) | Work on [Final Project](https://contextlab.github.io/llm-course/assignments/final-project/) |
124124
| 9 | Mar 2--6 | RAG, Mixture of Experts, Ethics | |
125125
| 10 | Mar 9 | Final Project Presentations | [Final Project](https://contextlab.github.io/llm-course/assignments/final-project/) due (Mar 9, 11:59 PM EST) |
@@ -180,13 +180,13 @@ We strive to create an inclusive learning environment where all students feel su
180180
| Wed Feb 11 | Lecture 19 | BERT Variants | [HTML](https://contextlab.github.io/llm-course/slides/week6/lecture19.html), [PDF](https://contextlab.github.io/llm-course/slides/week6/lecture19.pdf) | [Liu et al. (2019)](https://arxiv.org/abs/1907.11692), [Sanh et al. (2019)](https://arxiv.org/abs/1910.01108) |
181181
| Fri Feb 13 | Lecture 20 | Applications of Encoder Models | [HTML](https://contextlab.github.io/llm-course/slides/week6/lecture20.html), [PDF](https://contextlab.github.io/llm-course/slides/week6/lecture20.pdf) | |
182182
\needspace{3in}
183-
### Week 7: Decoder Models & GPT (February 16--20)
183+
### Week 7: Diffusion Models (February 16--20)
184184

185185
| Day | Lecture | Topics | Slides | Materials |
186186
|-----|---------|--------|--------|-----------|
187-
| Mon Feb 16 | Lecture 21 | GPT Architecture | [HTML](https://contextlab.github.io/llm-course/slides/week7/lecture21.html), [PDF](https://contextlab.github.io/llm-course/slides/week7/lecture21.pdf) | [Radford et al. (2018)](https://cdn.openai.com/research-covers/language-unsupervised/language_understanding_paper.pdf), [Radford et al. (2019)](https://cdn.openai.com/better-language-models/language_models_are_unsupervised_multitask_learners.pdf), **[Assignment 4](https://contextlab.github.io/llm-course/assignments/assignment-4/) Due (Feb 16, 11:59 PM EST)**, **[Final Project](https://contextlab.github.io/llm-course/assignments/final-project/) Released**, **[Assignment 5](https://contextlab.github.io/llm-course/assignments/assignment-5/) Available (Optional/Extra Credit)** |
188-
| Wed Feb 18 | Lecture 22 | Scaling Up to GPT-3 and Beyond | [HTML](https://contextlab.github.io/llm-course/slides/week7/lecture22.html), [PDF](https://contextlab.github.io/llm-course/slides/week7/lecture22.pdf) | [Brown et al. (2020)](https://arxiv.org/abs/2005.14165), [OpenAI (2023)](https://arxiv.org/abs/2303.08774) |
189-
| Fri Feb 20 | Lecture 23 | Implementing GPT from Scratch | [HTML](https://contextlab.github.io/llm-course/slides/week7/lecture23.html), [PDF](https://contextlab.github.io/llm-course/slides/week7/lecture23.pdf) | [Let's build GPT (Karpathy)](https://www.youtube.com/watch?v=kCc8FmEb1nY) |
187+
| Mon Feb 16 | Lecture 21 | Diffusion Models | [HTML](https://contextlab.github.io/llm-course/slides/week7/lecture21.html), [PDF](https://contextlab.github.io/llm-course/slides/week7/lecture21.pdf) | [Ho et al. (2020)](https://arxiv.org/abs/2006.11239), [Song & Ermon (2019)](https://arxiv.org/abs/1907.05600), **[Assignment 4](https://contextlab.github.io/llm-course/assignments/assignment-4/) Due (Feb 16, 11:59 PM EST)**, **[Final Project](https://contextlab.github.io/llm-course/assignments/final-project/) Released**, **[Assignment 5](https://contextlab.github.io/llm-course/assignments/assignment-5/) Available (Optional/Extra Credit)** |
188+
| Wed Feb 18 | Lecture 22 | Diffusion Model Extensions | [HTML](https://contextlab.github.io/llm-course/slides/week7/lecture22.html), [PDF](https://contextlab.github.io/llm-course/slides/week7/lecture22.pdf) | [Rombach et al. (2022)](https://arxiv.org/abs/2112.10752), [Peebles & Xie (2023)](https://arxiv.org/abs/2212.09748) |
189+
| Fri Feb 20 | Lecture 23 | Diffusion Applications and Ethics | [HTML](https://contextlab.github.io/llm-course/slides/week7/lecture23.html), [PDF](https://contextlab.github.io/llm-course/slides/week7/lecture23.pdf) | [Ramesh et al. (2022)](https://arxiv.org/abs/2204.06125), [OpenAI (2024) - Sora](https://openai.com/research/video-generation-models-as-world-simulators) |
190190
### Week 8: No Classes (February 23--27)
191191

192192
Instructor away February 23--27. No classes this week. Use this time to work on your [final project](https://contextlab.github.io/llm-course/assignments/final-project/).
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
# Week 7 Diffusion Rewrite — Session Notes (2026-02-12)
2+
3+
## Status
4+
Replacing Week 7 from "GPT/Decoder Models" to "Diffusion Models".
5+
6+
## Completed (committed)
7+
- Cross-reference updates: lecture20.md, lecture27.md, README.md, syllabus.md (uncommitted changes from prior session)
8+
- Animation infrastructure: render_gifs.py, postprocess_gifs.py, requirements.txt, README.md (uncommitted new files)
9+
10+
## In Progress (background tasks)
11+
All 4 content files are being generated by background agents:
12+
13+
| Task ID | File | Agent | Session ID |
14+
|---------|------|-------|------------|
15+
| bg_55690b17 | lecture21.md (diffusion architecture) | deep | ses_3abe4e6ccffeIxuC41mJgn0fb9 |
16+
| bg_66ef8d46 | lecture22.md (extensions) | deep | ses_3abe480feffeANUy7UfoxJ9QLd |
17+
| bg_4ba2b2b4 | lecture23.md (applications/ethics) | deep | ses_3abe4148affeNSF9u0KPz5qPvA |
18+
| bg_45dcd847 | diffusion_scenes.py (10 Manim scenes) | ultrabrain | ses_3abe320d3ffepDE9jAj9uyQEh8 |
19+
20+
## Remaining after content creation
21+
1. Create diffusion_demo.ipynb companion notebook
22+
2. Render Manim GIFs (requires manim venv)
23+
3. Compile all 3 lectures with compile.sh
24+
4. Verify via Playwright screenshots
25+
5. Verify citation URLs
26+
6. Run tests
27+
7. Commit and push
28+
29+
## Key Constraints
30+
- Assignment announcements ONLY in lecture21 (not 22/23)
31+
- Companion notebook referenced ONLY in lecture23
32+
- Animation GIFs ONLY in lecture21
33+
- gpt_from_scratch_demo.ipynb stays as-is (Assignment 5 ref)
34+
- Sentence case capitalization
35+
- Use 'C' for embedding dimension (consistency with lecture 15)

slides/README.md

Lines changed: 32 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -237,43 +237,45 @@ Explore concepts hands-on with our interactive web demos! Each demo runs directl
237237
- 📊 [Slides PDF](https://contextlab.github.io/llm-course/slides/week6/lecture20.pdf) | 🌐 [Slides HTML](https://contextlab.github.io/llm-course/slides/week6/lecture20.html)
238238
---
239239

240-
## Week 7: Decoder Models & GPT
241-
242-
**Monday (Lecture 21):** GPT Architecture
243-
- Generative pre-training paradigm, fine-tuning, weight tying
244-
- The BooksCorpus controversy: training data ethics
245-
- Open-weight decoders: the LLaMA revolution
246-
- Test-time compute and inference scaling
247-
- Modern decoder innovations: RMSNorm, SwiGLU, RoPE, GQA
248-
- Multi-token prediction and hybrid architectures (Jamba)
249-
- Reading: [Radford et al. (2018)](https://cdn.openai.com/research-covers/language-unsupervised/language_understanding_paper.pdf) - GPT-1
250-
- Reading: [Radford et al. (2019)](https://cdn.openai.com/better-language-models/language_models_are_unsupervised_multitask_learners.pdf) - GPT-2
251-
- Reading: [Touvron et al. (2023)](https://arxiv.org/abs/2302.13971) - LLaMA
252-
- Reading: [Gloeckle et al. (2024)](https://arxiv.org/abs/2404.19737) - Multi-token prediction
240+
## Week 7: Diffusion Models
241+
242+
**Monday (Lecture 21):** Diffusion Models
243+
- The diffusion architecture: forward process, reverse process, noise schedules
244+
- U-Net for noise prediction with timestep conditioning
245+
- Training objective: predicting the noise (simplified DDPM loss)
246+
- Score matching intuition and sampling algorithms (DDPM, DDIM)
247+
- Animated walkthrough of the complete diffusion pipeline
248+
- Reading: [Ho, Jain & Abbeel (2020)](https://arxiv.org/abs/2006.11239) - Denoising Diffusion Probabilistic Models
249+
- Reading: [Sohl-Dickstein et al. (2015)](https://arxiv.org/abs/1503.03585) - Deep Unsupervised Learning using Nonequilibrium Thermodynamics
250+
- Reading: [Song & Ermon (2019)](https://arxiv.org/abs/1907.05600) - Generative Modeling by Estimating Gradients
251+
- Reading: [Nichol & Dhariwal (2021)](https://arxiv.org/abs/2102.09672) - Improved DDPM
253252
- **📝 Assignment 4 Due (Feb 16, 11:59 PM EST)**
254253
- **Final Project Released:** [Final Project](https://contextlab.github.io/llm-course/assignments/final-project/) (Due: Mar 9, 11:59 PM EST)
255254
- **Assignment 5 Available (Optional/Extra Credit):** [Build GPT](https://contextlab.github.io/llm-course/assignments/assignment-5/)
256-
- 🎮 **Try it:** [GPT Playground](https://contextlab.github.io/llm-course/demos/gpt-playground/)
257255
- 📊 [Slides PDF](https://contextlab.github.io/llm-course/slides/week7/lecture21.pdf) | 🌐 [Slides HTML](https://contextlab.github.io/llm-course/slides/week7/lecture21.html)
258256

259-
**Wednesday (Lecture 22):** Scaling Up to GPT-3 and Beyond
260-
- From GPT-1 to GPT-4: the scaling journey
261-
- Beyond RLHF: DPO and GRPO alignment methods
262-
- Reasoning models (o1, o3, DeepSeek-R1) and emergent abilities debate
263-
- Reading: [Brown et al. (2020)](https://arxiv.org/abs/2005.14165) - GPT-3
264-
- Reading: [Rafailov et al. (2023)](https://arxiv.org/abs/2305.18290) - DPO
265-
- Reading: [Schaeffer et al. (2023)](https://arxiv.org/abs/2304.15004) - Are Emergent Abilities a Mirage?
257+
**Wednesday (Lecture 22):** Diffusion Model Extensions
258+
- Latent diffusion: VAE compression for efficient generation
259+
- Classifier-free guidance for conditional generation
260+
- Diffusion Transformer (DiT): replacing U-Net with transformers
261+
- Flow matching and rectified flow: simpler, faster diffusion
262+
- Stable Diffusion 3: MMDiT architecture
263+
- Reading: [Rombach et al. (2022)](https://arxiv.org/abs/2112.10752) - Latent Diffusion Models
264+
- Reading: [Ho & Salimans (2022)](https://arxiv.org/abs/2207.12598) - Classifier-Free Diffusion Guidance
265+
- Reading: [Peebles & Xie (2023)](https://arxiv.org/abs/2212.09748) - Scalable Diffusion Models with Transformers (DiT)
266+
- Reading: [Lipman et al. (2023)](https://arxiv.org/abs/2210.02747) - Flow Matching for Generative Modeling
266267
- 📊 [Slides PDF](https://contextlab.github.io/llm-course/slides/week7/lecture22.pdf) | 🌐 [Slides HTML](https://contextlab.github.io/llm-course/slides/week7/lecture22.html)
267268

268-
**Friday (Lecture 23):** Implementing GPT from Scratch
269-
- Build a complete mini-GPT (~30M params) in PyTorch
270-
- Tokenization, embeddings, masked attention, transformer blocks, training loop
271-
- Weight tying, gradient accumulation, LR scheduling, mixed precision training
272-
- Text generation: greedy, temperature, top-k, nucleus sampling
273-
- KV caching, FlashAttention, and nanoGPT comparison
274-
- Tutorial: [Let's build GPT (Karpathy)](https://www.youtube.com/watch?v=kCc8FmEb1nY)
275-
- Reading: [Dao et al. (2022)](https://arxiv.org/abs/2205.14135) - FlashAttention
276-
- 📓 [Companion Notebook](https://colab.research.google.com/github/ContextLab/llm-course/blob/main/slides/week7/gpt_from_scratch_demo.ipynb)
269+
**Friday (Lecture 23):** Diffusion Applications and Ethics
270+
- Text-to-image: DALL-E 2, Stable Diffusion, Imagen
271+
- Text-to-video: Sora and spacetime patches
272+
- Text-to-audio: FluxMusic and spectral diffusion
273+
- Discrete diffusion for text generation (MDLM)
274+
- Ethics: deepfakes, consent, bias in generation, regulation
275+
- Reading: [Ramesh et al. (2022)](https://arxiv.org/abs/2204.06125) - DALL-E 2
276+
- Reading: [OpenAI (2024)](https://openai.com/research/video-generation-models-as-world-simulators) - Sora
277+
- Reading: [Sahoo et al. (2024)](https://arxiv.org/abs/2406.07524) - Masked Diffusion Language Models
278+
- 📓 [Companion Notebook](https://colab.research.google.com/github/ContextLab/llm-course/blob/main/slides/week7/diffusion_demo.ipynb)
277279
- 📊 [Slides PDF](https://contextlab.github.io/llm-course/slides/week7/lecture23.pdf) | 🌐 [Slides HTML](https://contextlab.github.io/llm-course/slides/week7/lecture23.html)
278280
---
279281

slides/week10/lecture27.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ Please be a supportive and engaged audience -- ask questions, offer feedback, an
108108
| 3--4 | Embeddings (LSA → Word2Vec → ELMo) | Meaning lives in vector space |
109109
| 5 | Transformer architecture | Attention is all you need |
110110
| 6 | BERT and encoder models | Bidirectional understanding |
111-
| 7 | GPT and decoder models | Autoregressive generation at scale |
111+
| 7 | Diffusion models | Iterative refinement and generation beyond text |
112112
| 8 | *(Break)* | |
113113
| 9 | Agents, MoE, ethics | Action, efficiency, responsibility |
114114
| 10 | **Your projects** | Putting it all together |

slides/week6/lecture20.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -392,6 +392,6 @@ Which framework you adopt determines your answer to every question on the next s
392392

393393
<div class="tip-box" data-title="Up next...">
394394

395-
Week 7: GPT and autoregressive generation — from decoder architecture to scaling laws
395+
Week 7: Diffusion models — from denoising to text-to-image generation
396396

397397
</div>

slides/week7/animations/README.md

Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
# Diffusion Model Animation GIFs for Lecture 21
2+
3+
This directory contains Python Manim scripts to generate animated GIFs for the diffusion model lecture slides.
4+
5+
## Prerequisites
6+
7+
1. Python 3.9+
8+
2. System dependencies for Manim:
9+
- macOS: `brew install py3cairo ffmpeg pango`
10+
- Ubuntu: `sudo apt install libcairo2-dev ffmpeg libpango1.0-dev`
11+
12+
3. Avenir font (for macOS, this is pre-installed)
13+
14+
## Setup
15+
16+
```bash
17+
cd slides/week7/animations
18+
python -m venv venv
19+
source venv/bin/activate # or `venv\Scripts\activate` on Windows
20+
pip install -r requirements.txt
21+
```
22+
23+
## Rendering GIFs
24+
25+
```bash
26+
python render_gifs.py
27+
```
28+
29+
This will:
30+
1. Render each scene as an MP4 via Manim
31+
2. Convert to high-quality GIFs with transparent backgrounds
32+
3. Save GIFs to `./gifs/` directory
33+
34+
## Output
35+
36+
Generated GIFs:
37+
- `forwarddiffusion.gif` - Progressive noising from clean image to pure noise
38+
- `noiseschedule.gif` - Linear vs cosine noise schedules
39+
- `reverseprocess.gif` - Iterative denoising from noise to clean image
40+
- `unetarchitecture.gif` - U-Net encoder-decoder with skip connections
41+
- `timestepembedding.gif` - Sinusoidal timestep conditioning
42+
- `trainingobjective.gif` - Training loop visualization
43+
- `simplifiedloss.gif` - DDPM simplified loss equation breakdown
44+
- `scorematching.gif` - Score function vector field visualization
45+
- `samplingprocess.gif` - DDPM sampling algorithm step by step
46+
- `diffusionvstransformer.gif` - Autoregressive vs diffusion paradigm comparison
47+
48+
## Rendering Individual Scenes
49+
50+
```bash
51+
# Render a single scene
52+
manim -qh --format=mp4 -r 1920,1080 --fps 24 diffusion_scenes.py ForwardDiffusion
53+
54+
# Preview (faster, lower quality)
55+
manim -ql --format=gif --transparent diffusion_scenes.py ForwardDiffusion
56+
```
57+
58+
## Customization
59+
60+
Edit `diffusion_scenes.py` to modify:
61+
- Colors (Dartmouth palette used throughout)
62+
- Font sizes
63+
- Animation timing
64+
- Grid sizes and values
65+
66+
## Integration with Slides
67+
68+
The generated GIFs are designed to have transparent backgrounds, allowing them to overlay seamlessly on the slide background. Reference them in lecture21.md like:
69+
70+
```markdown
71+
![height:500](animations/gifs/forwarddiffusion.gif)
72+
```
73+
74+
## Content Source
75+
76+
Animation content based on:
77+
- [Ho, Jain & Abbeel (2020)](https://arxiv.org/abs/2006.11239) - DDPM
78+
- [Song & Ermon (2019)](https://arxiv.org/abs/1907.05600) - Score matching
79+
- [Ronneberger et al. (2015)](https://arxiv.org/abs/1505.04597) - U-Net architecture

0 commit comments

Comments
 (0)