Note Wisdom
Lecture 4 of Stanford CME295 walks through how large language models are actually built: pre-training on internet-scale data, the compute and scaling rules behind it, the parallelism and FlashAttention tricks that make it fit on GPUs, and the fine-tuning, LoRA, and evaluation work that follows.
Institution: Stanford
Original Course: Stanford CME295 Transformers & LLMs | Autumn 2025 | Lecture 4 - LLM Training
Instructor Bio: This lecture is co-delivered by **Afshine Amidi** and **Shervine Amidi**, adjunct faculty at Stanford University's Institute for Computational and Mathematical Engineering (ICME). Afshine Amidi earned his engineering degree from École Centrale Paris in 2016 and a Master of Science from the Massachusetts Institute of Technology in 2017. He currently leads LLM initiatives for promotional writing at Netflix, and previously held roles at Uber and at Google on the Gemini team. He co-authors widely used technical study guides on machine learning, transformers, and algorithms. Shervine Amidi holds B.S. and M.S. degrees in engineering from École Centrale Paris (2016), as well as an M.S. in Computational and Mathematical Engineering from Stanford University (2019). He is a Senior Machine Learning Engineer at Netflix, and previously worked at Google DeepMind on the Gemini team, Google Assistant, and Uber's data science division. He has served as a teaching assistant for multiple core Stanford CS courses and has been an adjunct lecturer at the university since 2021.
Course Description: This lecture provides an in-depth look at the pre-training pipeline for large language models. It covers data collection and curation strategies, including web scraping, dataset filtering, deduplication, and data mixing across domains. The lecture explains the next-token prediction objective and the cross-entropy loss that drives pre-training, then dives into optimization techniques including AdamW optimizer settings, learning rate scheduling with warmup and cosine decay, gradient clipping, and batch size considerations. It also discusses practical training challenges such as instability, loss spikes, and the infrastructure required for training models at scale.
All contents below are exclusive to the paid Word file, NOT available on this web page
Skip hours of watching lectures. Get organized notes, exam prep materials and problem solutions all in one Word file.
Click to see everything included
All contents below are exclusive to the paid Word file, NOT available on this web page

