@stanfordnlp: The “problem” with CS336 is not the ~22 hours of videos but the larger number of hours it takes to do the assignments. …

X AI KOLs Following News

Summary

Stanford's CS336 course on language modeling from scratch is announced, featuring intensive hands-on assignments covering tokenizers, transformers, data, and alignment.

The “problem” with CS336 is not the ~22 hours of videos but the larger number of hours it takes to do the assignments. But that is where most of the real learning occurs. We’re reminded of @karpathy’s seminal tweet: https://x.com/karpathy/status/1756380066580455557?s=61… 2026 site: https://cs336.stanford.edu
Original Article
View Cached Full Text

Cached at: 06/28/26, 10:07 PM

The “problem” with CS336 is not the ~22 hours of videos but the larger number of hours it takes to do the assignments. But that is where most of the real learning occurs. We’re reminded of @karpathy’s seminal tweet: https://x.com/karpathy/status/1756380066580455557?s=61… 2026 site: https://cs336.stanford.edu


Stanford CS336 | Language Modeling from Scratch

Source: https://cs336.stanford.edu/

Content

What is this course about?

Language models serve as the cornerstone of modern natural language processing (NLP) applications and open up a new paradigm of having a single general purpose system address a range of downstream tasks. As the field of artificial intelligence (AI), machine learning (ML), and NLP continues to grow, possessing a deep understanding of language models becomes essential for scientists and engineers alike. This course is designed to provide students with a comprehensive understanding of language models by walking them through the entire process of developing their own. Drawing inspiration from operating systems courses that create an entire operating system from scratch, we will lead students through every aspect of language model creation, including data collection and cleaning for pre-training, transformer model construction, model training, and evaluation before deployment.

Prerequisites

  • Proficiency in PythonThe majority of class assignments will be in Python. Unlike most other AI classes, students will be given minimal scaffolding. The amount of code you will write will be at least an order of magnitude greater than for other classes. Therefore, being proficient in Python and software engineering is paramount.
  • Experience with deep learning and systems optimizationA significant part of the course will involve making neural language models run quickly and efficiently on GPUs across multiple machines. We expect students to be able to have a strong familiarity with PyTorch and know basic systems concepts like the memory hierarchy.
  • College Calculus, Linear Algebra(e.g. MATH 51, CME 100)You should be comfortable understanding matrix/vector notation and operations.
  • Basic Probability and Statistics(e.g. CS 109 or equivalent)You should know the basics of probabilities, Gaussian distributions, mean, standard deviation, etc.
  • Machine Learning(e.g. CS221, CS229, CS230, CS124, CS224N)You should be comfortable with the basics of machine learning and deep learning.

Note that this is a 5-unit class. This is a very implementation-heavy class, so please allocate enough time for it.

Coursework

Assignments

  • Assignment 1: Basics- Implement all of the components (tokenizer, model architecture, optimizer) necessary to train a standard Transformer language model. - Train a minimal language model.
  • Assignment 2: Systems- Profile and benchmark the model and layers from Assignment 1 using advanced tools, optimize Attention with your own Triton implementation of FlashAttention2. - Build a memory-efficient, distributed version of the Assignment 1 model training code.
  • Assignment 3: Scaling- Understand the function of each component of the Transformer. - Query a training API to fit a scaling law to project model scaling.
  • Assignment 4: Data- Convert raw Common Crawl dumps into usable pretraining data. - Perform filtering and deduplication to improve model performance.
  • Assignment 5: Alignment and Reasoning RL- Apply supervised finetuning and reinforcement learning to train LMs to reason when solving math problems. - Optional Part 2: implement and apply safety alignment methods such as DPO.

All (currently tentative) deadlines are listed in theschedule.

GPU compute for self-study

If you are following along at home, you can access GPU compute from a cloud provider to complete the assignments.

Here are a few options (public pricing for a single B200 GPU on March 28, 2026):

For convenience and to save money, we recommend debugging correctness of your implementation on CPU first and then using GPU(s) (with the count recommended in the assignments) for completing training runs (A1, A4, A5) or benchmarking GPU operations (A2).

Honor code

Like all other classes at Stanford, we take the studentHonor Codeseriously. Please respect the following policies:

  • Collaboration: Study groups are allowed, but students must understand and complete their own assignments, and hand in one assignment per student. If you worked in a group, please put the names of the members of your study group at the top of your assignment. Please ask if you have any questions about the collaboration policy.
  • AI tools: Prompting LLMs such as ChatGPT is permitted for low-level programming questions or high-level conceptual questions about language models, but using it directly to solve the problem is prohibited. We strongly encourage you to disable AI autocomplete (e.g., Cursor Tab, GitHub CoPilot) in your IDE when completing assignments (though non-AI autocomplete, e.g., autocompleting function names is totally fine). We have found that AI autocomplete makes it much harder to engage deeply with the content. See theAI policy(inspired bythis).
  • Existing code: Implementations for many of the things you will implement exist online. The handouts we’ll give will be self-contained, so that you will not need to consult third-party code for producing your own implementation. Thus, you should not look at any existing code unless when otherwise specified in the handouts.

Submitting coursework

  • All coursework are submitted via Gradescope by the deadline. Do not submit your coursework via email.
  • If anything goes wrong, please ask a question in Slack or contact a course assistant.
  • You can submit as many times as you’d like until the deadline: we will only grade the last submission.
  • Partial work is better than not submitting any work.

Late days

  • Each student has6 late days to use. A late day extends the deadline by 24 hours.
  • You can use up to 3 late days per assignment.

Regrade requests

If you believe that the course staff made an objective error in grading, you may submit a regrade request on Gradescope within 3 days after the grades are released.

Sponsor

We would like to thankModalfor sponsoring compute for this class.

Schedule(YouTube playlist)

#DateDescriptionCourse MaterialsDeadlines1Mon March 30Overview, tokenization [Percy]lecture_01.pyAssignment 1out [code] [preview]2Wed April 1PyTorch (einops), resource accounting (FLOPs, memory, arithmetic intensity) [Percy]lecture_02.py(recording version)3Mon April 6Architectures, hyperparameters [Tatsu]lecture 3.pdf4Wed April 8Attention alternatives and mixture of experts [Tatsu]lecture 4.pdf5Mon April 13GPUs, TPUs [Tatsu]lecture 5.pdf6Wed April 15Kernels, Triton [Percy]lecture_06.pyAssignment 1due Assignment 2out [code] [preview]7Mon April 20Parallelism [Percy]lecture_07.py8Wed April 22Parallelism [Tatsu]lecture_08.pdf9Mon April 27Scaling laws [Tatsu]lecture_09.pdf10Wed April 29Inference [Percy]lecture_10.pyAssignment 2due Assignment 3out [code] [preview]11Mon May 4Scaling laws [Tatsu]lecture_11.pdf12Wed May 6Evaluation [Percy]lecture_12.pyAssignment 3due Assignment 4out [code] [preview]13Mon May 11Data (sources, datasets) [Percy]lecture_13.py14Wed May 13Data (filtering, deduplication, mixing, synthetic data) [Percy]lecture_14.py15Mon May 18Mid/post-training (SFT/RLHF) [Tatsu]lecture_15.pdf16Wed May 20Post-training - RLVR [Tatsu]lecture_16.pdfAssignment 4due Assignment 5out [code] [preview] [Optional Part 2]Mon May 25*No class (Memorial Day)*17Wed May 27Alignment - multimodality [Percy]lecture_17.py18Mon June 1Guest lecture: Daniel Selsam19Wed June 3Guest lecture: Dan FuAssignment 5due

Qihong Ruan (@Qihong53030163): Stanford’s CS336 — Language Modeling from Scratch is one of the best courses for understanding how LLMs are built end to end. The catch: 17 lectures, ~22 hours of video. So I built a companion notes site for the full Spring 2025 series: 👉 https://t.co/RZHko6Hdq5

For all 17

Similar Articles

CS336: Language Modeling from Scratch

Hacker News Top

Stanford is offering a comprehensive course, CS336, where students build a language model from scratch, covering data collection, transformer construction, training, and evaluation.