Stanford CME295:
A Free Course on Transformers and LLMs, With Every Lecture
From tokenization to GRPO and on-policy distillation in nine lectures. Stanford posts every recording on YouTube, with free slides and a cheatsheet. Every lecture is here with its chapter links, plus what is still to come this quarter.
Updated: November 2, 2026 · Term: Autumn 2026 · Released: 4 of 9 lectures · Cost to follow: free
At a glance
- Course: CME295 Transformers and Large Language Models, Stanford University, Autumn 2026. It is the second edition; the 2025 syllabus is still online.
- Taught by: twin brothers Afshine Amidi and Shervine Amidi, both adjunct professors at Stanford and authors of the course textbook.
- Format: one lecture of about 1 hour 45 minutes each Friday, recorded and posted to YouTube by Stanford Online. No homework, a midterm and a final.
- Level: for anyone with calculus, linear algebra and basic machine learning. There is no programming homework.
- Free to follow: lecture videos, slide PDFs, the midterm with solutions, and an illustrated cheatsheet in 15 languages.
Watch the full playlist
All the lectures live in one Stanford Online playlist on YouTube, which picks up new lectures as they are posted. Start from lecture 1 and let it play through.
What it teaches
CME295 explains how a modern LLM works, from the first token to a reasoning model. In the course's words, students learn "the evolution of NLP methods, the core components of the Transformer architecture, along with how they relate to LLMs as well as techniques to enhance model performance for real-world applications." The first four lectures build the model and train it. The last five cover what happens around it: systems, agents, evaluation, diffusion LLMs and current trends.
Tokens, embeddings, attention, the Transformer, then the LLM: mixture of experts, RoPE, GQA and normalization choices.
Pretraining, SFT and LoRA, preference tuning with RLHF and DPO, then the RL math behind PPO, GRPO and on-policy distillation.
Distributed training and inference, AI agents and MCP, LLM-as-a-judge evaluation, diffusion LLMs and multimodality.
The lectures so far
Press play to open a lecture on YouTube, or pick a chapter to start it at that point. The chapter times are the ones Stanford published with each video.
Lecture 1: Transformers
Sep 25 · 1:44:28Starts from the history of NLP and builds the Transformer piece by piece: how text becomes tokens and vectors, why recurrent networks struggled, and how attention fixed it. It ends with a full worked example.
16 chapters
- 0:00Welcome
- 3:43Difference from last year’s edition
- 5:01Class logistics
- 12:42Timeline
- 16:56Tokenization
- 37:27Word2vec (CBOW, Skip-gram)
- 48:26RNN, LSTM
- 55:18Attention
- 57:16Self-attention mechanism
- 59:54Query, key, value
- 1:09:35Transformer architecture
- 1:12:19Input
- 1:16:27Transformer Encoder
- 1:18:19Transformer Decoder
- 1:22:16Computational tricks
- 1:27:35End-to-end example
Lecture 2: Large Language Models
Oct 2 · 1:43:15From the Transformer to today's LLMs: encoder-only vs decoder-only models, scaling laws, mixture of experts and the architecture tricks in current open models, then prompting, context rot and chain of thought.
19 chapters
- 0:00Introduction
- 4:47BERT and encoder-only models
- 13:47GPT and decoder-only models
- 16:10Encoder-decoder versus decoder-only
- 19:23Scaling laws
- 26:49Large Language Model definition
- 29:05Mixture of experts (MoE)
- 33:11MoE-based LLMs
- 36:03Load balancing loss
- 45:36Position embeddings
- 1:01:58Rotary position embeddings (RoPE)
- 1:09:28Sliding Window Attention (SWA)
- 1:13:15Group Query Attention (GQA)
- 1:18:13Pre-Norm versus Post-Norm
- 1:19:41LayerNorm versus RMSNorm
- 1:21:09Next token prediction
- 1:35:22Prompting
- 1:38:38Context rot
- 1:41:42Chain of Thought (CoT)
Lecture 3: LLM training
Oct 9 · 1:44:32The full training pipeline: pretraining and data mixtures, midtraining and long context, supervised finetuning and LoRA, preference tuning with RLHF and DPO, and training for reasoning with GRPO and on-policy distillation.
16 chapters
- 0:00Introduction
- 3:36Pretraining
- 10:33Cross-entropy loss
- 17:15Data mixtures
- 22:18Midtraining
- 23:41Long context training
- 31:47Supervised finetuning (SFT)
- 40:15Low-Rank Adaptation (LoRA)
- 46:37Preference tuning
- 54:44Bradley-Terry formulation
- 1:01:49Reinforcement Learning from Human Feedback (RLHF)
- 1:05:38Direct Preference Optimization (DPO)
- 1:12:08Reasoning
- 1:20:56Group Relative Policy Optimization (GRPO)
- 1:23:31On-Policy Distillation (OPD)
- 1:27:47End-to-end example
Lecture 4: Reinforcement Learning with LLMs
Oct 16 · 1:43:27The math behind post-training. Derives the policy gradient, then walks from REINFORCE to PPO, shows how DPO connects to it, and compares GRPO, its limits and fixes (DAPO, Dr. GRPO) and on-policy distillation.
20 chapters
- 0:00Introduction
- 6:35RL setup
- 9:32Reward design
- 12:23Policy gradient
- 17:12Derivation of the gradient
- 23:50REINFORCE
- 25:51Importance sampling ratio
- 33:22Challenges of policy gradients
- 40:34Proximal Policy Optimization (PPO)
- 42:49Value function and advantage
- 51:16Policy ratio
- 53:03Ratio clipping
- 57:45KL Penalty
- 59:48Connection with DPO
- 1:07:29Group Relative Policy Optimization (GRPO)
- 1:09:42Comparison of GRPO and PPO
- 1:18:25Limitations of GRPO
- 1:22:41DAPO, Dr. GRPO
- 1:25:17On-Policy Distillation (OPD)
- 1:39:32Self (OPSD) and Multi-Teacher (OPD) variants
Still to come
The rest of the quarter, from the course syllabus. Videos join the playlist above as they are posted, so far within about a week of each lecture.
| Date | Lecture | Topics |
|---|---|---|
| Oct 23 | Midterm | Exam and solutions (PDF), taken after lectures 1 to 4 |
| Oct 30 | 5. LLM systems | Distributed training, inference optimizations, KV caching, speculative decoding, efficient kernels, Flash Attention, hardware trade-offs. Slides are out; video coming. |
| Nov 6 | 6. AI agents | Tool calling, MCP, memory and retrieval, context compaction, harness optimization, coding agents, skills and plugins |
| Nov 13 | 7. LLM evaluation | LLM-as-a-judge, best practices, biases and pitfalls, agent evaluation, benchmarks |
| Nov 20 | 8. Diffusion LLMs | Continuous, discrete and masked diffusion, training and inference |
| Dec 4 | 9. Trending topics | Recap, multimodality, closing thoughts |
| Dec 9 | Final exam | Covers the full course |
How to follow it on your own
- Every lecture video, on the playlist above
- Slide PDFs for each lecture on the syllabus page
- The midterm and its solutions, a ready-made self-test
- The illustrated cheatsheet, in 15 languages
- Ed Discussion and the Canvas course
- Sitting and grading of the exams
- Staff support and office hours
- The textbook is paid, though Stanford's library holds a copy
With no homework, the course is easy to follow at home: one lecture a week, slides open alongside, takes about two hours. The chapter links make it easy to rewatch a single idea, such as RoPE or the GRPO objective, without scrubbing through a full session. Try the midterm after lecture 4, before you look at the solutions.
The textbook is the Amidis' Super Study Guide: Transformers & Large Language Models, built from the same illustrated style as their widely shared Stanford cheatsheets. The free cheatsheet is a good substitute if you want the diagrams without the book.
Our take
This is the course we would point a product leader or engineer to who wants to understand what is inside the model, not just call it. It is short, it is current, and it keeps up: the Autumn 2026 edition now covers on-policy distillation, GRPO variants like DAPO and Dr. GRPO, context rot, and a full lecture on agents with MCP, skills and plugins. Lectures 3 and 4 alone are among the clearest free explanations of post-training we have seen.
It pairs well with our other course guide. CME295 explains the model; Harvard CS2680 is about building and serving the system around it, with hands-on assignments. Watch CME295 first, then build with CS2680.
Source: the CME295 course site, its syllabus and FAQ, and the Stanford Online YouTube playlist, as of November 2, 2026. Videos are hosted on YouTube and belong to Stanford. This guide is independent and not affiliated with Stanford. Spot something out of date? Tell us.