language-diffusion-models

Course Content & Learning Path

A from-scratch, build-it-yourself course on diffusion models for language. Every lesson is a single self-contained, runnable Jupyter notebook: you train a real (tiny) model on a toy corpus in seconds, with the math tied line-by-line to the papers that introduced each idea. No prior diffusion knowledge required — just PyTorch and the transformer.


How to use this course

Prerequisites: comfort with PyTorch and the transformer architecture; basic probability (categorical distributions, KL divergence, Bayes’ rule). Calculus and linear algebra at the level of “I can read $\prod$, $\sum$, and a matrix product.”

Time: ~45–90 minutes per lesson including exercises.


The arc of the course

  DISCRETE tokens                                     CONTINUOUS embeddings
  ───────────────                                     ─────────────────────
  L1  masking (absorbing-state)                       L3  Diffusion-LM
  L2  D3PM — any transition kernel                        (Gaussian noise in R^d,
  L4  scaling up — LLaDA-style:                            + gradient guidance)
      generalization, guidance, fast sampling
  L5  SEDD — score/ratio matching  (advanced)

  Suggested order: L1 → L2 → L3 → L4 → L5

Part I (Lessons 1–5) is complete and verified end-to-end — and Lesson 6, the first of the advanced Part II track, is built too. 🎓


Lesson 1 — Foundations: Masked (Absorbing-State) Diffusion ✅

Notebook: 01_foundations_masked_diffusion.ipynb

The simplest language diffusion model, end to end. The forward process replaces tokens with [MASK]; a bidirectional transformer learns to fill them back in.

Lesson 2 — General Transition Kernels: the D3PM Framework ✅

Notebook: 02_d3pm_transition_kernels.ipynb Math reference: reference/D3PM_MATH.md

Generalize Lesson 1’s single kernel to any categorical transition matrix, and compare the uniform and absorbing kernels head-to-head.

Lesson 3 — Continuous / Embedding-Space Diffusion (Diffusion-LM) ✅

Notebook: 03_diffusion_lm_embedding_space.ipynb

A completely different way to diffuse language: instead of corrupting discrete tokens, embed them into $\mathbb R^d$ and run Gaussian diffusion in that continuous space (the exact DDPM image-diffusion math), then round back to tokens.

Lesson 4 — Making Masked Diffusion Practical (LLaDA-style) ✅

Notebook: 04_scaling_diffusion_llm.ipynb

Turn Lesson 1’s masking model into a practical, LLaDA-style one — and measure real generalization instead of memorization.

Lesson 5 — Score-Entropy Discrete Diffusion (SEDD) ✅

Notebook: 05_sedd_score_entropy.ipynb Math oracle: tools/sedd_reference_check.py

The advanced capstone. Stop predicting the posterior/token; instead learn the ratios $p_t(y)/p_t(x)$ of the data distribution — the concrete score (the discrete analogue of a “score”).


Part II — Advanced / Frontier track (planned)

Part I (Lessons 1–5) covers the foundations. This planned second track digs into the two things that make diffusion LMs practically exciting — how you reveal tokens and how you generate in parallel — plus the 2025–2026 frontier.

Lesson 6 — Masking & unmasking strategies (the decoding zoo) ✅

Notebook: 06_unmasking_strategies.ipynb

One fixed model, many samplers — decoding quality is a first-class design choice.

Lesson 7 — Parallelization & fast generation 🔜

Diffusion’s headline advantage over autoregressive LLMs: generate many tokens at once. This lesson makes it real and measures it:

Lesson 8 — The 2025–2026 frontier 🔜

The research edge, tied back to what you built:

⚠️ Honesty note on “2026 methods.” This course’s author knowledge runs to early 2026. Lessons 6–7 rest on established, verified methods. Lesson 8’s newest, post-cutoff work will get a fresh, cited literature pass before it’s written — no invented papers. If you want the very latest, that literature review is the first step.

(Lesson 6 is built and verified; Lessons 7–8 are the remaining roadmap. Each follows Part I’s recipe: tiny, runnable, verified, beginner-friendly, one paper-family at a time.)


Concept map (where each idea is introduced)

Concept Lesson
Forward (corruption) process 1
Noise schedule $\bar\alpha_t$ 1, 2
Bidirectional denoiser + time conditioning 1
ELBO → weighted cross-entropy 1
Ancestral sampling, infilling 1
Transition matrices $Q_t$, the kernel family 2
Closed-form marginal & posterior, Bayes 2
x0-parameterized reverse, term-by-term ELBO, hybrid loss 2
Continuous/embedding diffusion, rounding 3
Gradient guidance (continuous) / classifier-free guidance 3, 4
Generalization, conditional generation 4
Confidence-based sampling, steps↔quality (NFE) 4
Score / ratio matching 5
Continuous-time discrete diffusion 5

Papers referenced across the course


All five lessons are done and run end-to-end. The course is complete: a from-scratch, verified tour of language diffusion — discrete and continuous, prediction-based and score-based.