메뉴
HN
Hacker News 57일 전

스탠퍼드 CS336: 밑바닥부터 시작하는 언어 모델링

IMP
8/10
핵심 요약

스탠퍼드 대학교에서 2026년 봄 학기에 개설되는 'CS336: 밑바닥부터 시작하는 언어 모델링' 강의 소개글입니다. 이 수업은 기존의 뼈대 코드를 활용하는 것과 달리, 학생들이 직접 데이터 수집부터 Transformer 모델 구현, GPU 분산 학습 및 최적화까지 대규모 언어 모델(LLM) 전체를 구축하는 실무적인 과정을 강조합니다. AI 연구원 및 엔지니어에게 필수적인 심화 구현 능력과 시스템 최적화 기술을 배우는 데 매우 중요한 코스입니다.

번역된 본문

CS336: 밑바닥부터 시작하는 언어 모델링 스탠퍼드 / 2026년 봄 (이전 학기: 2025년 봄 | 2024년 봄)

운영진:

  • Tatsunori Hashimoto, Percy Liang (강사)
  • Herman Brunborg, Marcel Rød, Steven Cao (조교)

일정 및 장소:

  • 강의: 월요일/수요일 오후 3:00~4:20, Skilling Auditorium
  • 녹화본: YouTube 재생목록
  • 오피스 아워: 강사 및 조교별로 주중 여러 시간에 걸쳐 Gates 건물 각 실에서 진행됨
  • 연락처: 학생은 공개 Slack 채널을 통해 모든 질문을 해야 하며, 개인적인 문의는 이메일(cs336-spr2526-staff@lists.stanford.edu)로 연락해야 합니다.

강의 내용: 이 수업은 무엇에 관한 것인가요? 언어 모델은 현대 자연어 처리(NLP) 애플리케이션의 초석 역할을 하며, 단일 범용 시스템이 다양한 다운스트림 작업을 해결하는 새로운 패러다임을 열어주었습니다. 인공지능(AI), 머신러닝(ML), 자연어 처리(NLP) 분야가 지속적으로 성장함에 따라 과학자와 엔지니어 모두 언어 모델에 대한 깊은 이해를 갖는 것이 필수적이 되었습니다.

이 수업은 학생들이 직접 언어 모델을 개발하는 전 과정을 경험하며 포괄적인 이해를 제공하도록 설계되었습니다. 운영 체제를 밑바닥부터 직접 만드는 OS 수업에서 영감을 받아, 우리는 학생들이 언어 모델 생성의 모든 측면을 직접 경험하도록 이끌 것입니다. 여기에는 사전 학습을 위한 데이터 수집 및 정제, 트랜스포머(Transformer) 모델 구축, 모델 학습, 배포 전 평가 등이 모두 포함됩니다.

선수 요건:

  • 파이썬(Python) 능숙도: 대부분의 과제는 파이썬으로 진행됩니다. 다른 대부분의 AI 수업들과 달리, 학생들에게 제공되는 뼈대 코드(scaffolding)는 극히 최소한입니다. 작성해야 할 코드의 양이 다른 수업보다 최소 10배는 많을 것입니다. 따라서 파이썬과 소프트웨어 엔지니어링에 능숙한 것이 매우 중요합니다.
  • 딥러닝 및 시스템 최적화 경험: 상당 부분의 수업은 여러 머신에 걸쳐 GPU에서 신경망 언어 모델을 빠르고 효율적으로 실행하는 것과 관련이 있습니다. 학생들은 PyTorch에 매우 익숙하고 메모리 계층 구조와 같은 기본 시스템 개념을 알고 있을 것으로 기대합니다.
  • 대학 수준의 미적분학 및 선형대수학: 행렬/벡터 표기법과 연산을 이해할 수 있어야 합니다.
  • 기본 확률 및 통계: 확률의 기본, 가우시안 분포, 평균, 표준 편차 등의 기초 지식이 필요합니다.
  • 머신러닝 기초: 머신러닝 및 딥러닝의 기본기에 익숙해야 합니다.

참고: 이 수업은 5학점 과목입니다. 구현해야 할 내용이 매우 많으므로 수업을 위해 충분한 시간을 할당해 주시기 바랍니다.

과제:

  • 과제 1: 기초 (Basics) 표준 트랜스포머 언어 모델을 학습시키는 데 필요한 모든 구성 요소(토크나이저, 모델 아키텍처, 옵티마이저)를 직접 구현합니다. 최소 규모의 언어 모델을 학습시킵니다.
  • 과제 2: 시스템 (Systems) 고급 도구를 사용하여 과제 1의 모델과 레이어를 프로파일링 및 벤치마킹하고, 직접 작성한 Triton 기반의 FlashAttention2 구현을 통해 어텐션(Attention) 메커니즘을 최적화합니다. 과제 1의 모델 학습 코드를 메모리 효율적인 분산 버전으로 빌드합니다.
  • 과제 3: 확장 (Scaling) 모델 초기화와 가중치(weight) 및 활성화(activation) 역학을 연구하고 이해합니다. 트랜스포머의 각 구성 요소가 수행하는 기능을 깊이 이해합니다. 학습 API를 쿼리하여 모델 스케일링 법칙(scaling law)을 피팅하고 향후 모델 확장을 예측합니다.
  • 과제 4: 데이터 (Data) 원시 Common Crawl 덤프를 실제 사용 가능한 사전 학습 데이터로 변환합니다. 모델 성능을 향상시키기 위해 필터링 및 중복 제거 작업을 수행합니다.
원문 보기
원문 보기 (영어)
CS336: Language Modeling from Scratch Stanford / Spring 2026 ( previous offerings ) Spring 2025 | Spring 2024 Previous offerings: Spring 2025 | Spring 2024 --> Course Staff Tatsunori Hashimoto Instructor Percy Liang Instructor Herman Brunborg CA Marcel Rød CA Steven Cao CA Logistics Lectures: Monday/Wednesday 3:00-4:20pm in Skilling Auditorium Recordings: YouTube playlist Office hours: Percy Liang: Fridays 11am-12pm in Gates 366 Tatsu Hashimoto: Tuesdays 11-12am in Gates 364 Marcel Rød: Tuesdays 4:30-5:30pm in Gates 498, Wednesdays 4:30-5:30pm in Gates 415 Herman Brunborg: Wednesdays 1:30-2:30pm, Fridays 1:30-2:30pm, location Gates 392 Steven Cao: Mondays 4:30-5:30pm, Thursdays 9:30-10:30am, Gates 200 Contact : Students should ask all course-related questions in public Slack channels. All announcements will also be made in Slack. For personal matters, email cs336-spr2526-staff@lists.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 Python The 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 optimization A 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. serve to make the #coursework hyperlink display correctly (with the h2 header visible) --> 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 Study and understand model initializations and weight + activation dynamics. --> 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 the schedule . 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): Modal (sponsor): $6.25/hour . Offers $30 of free monthly compute. You are only charged for actual compute (no idle resources) and their UX makes switching between local dev and large-scale gpu experiments simple. ( Modal Pricing ) Lambda Labs : $6.69/hour ( Lambda Pricing ) RunPod : $4.99/hour ( RunPod Pricing ) Nebius : $5.50/hour ($3.05/hour preemptible) ( Nebius Pricing ) Together : $7.49/hour , minimum 8 GPUs, cheaper for longer commitments ( Together Pricing ) 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 student Honor Code seriously. 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 the AI policy . 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 has 6 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 thank Modal for sponsoring compute for this class. serve to make the #schedule hyperlink display correctly (with the h2 header visible) --> Schedule ( YouTube playlist ) # Date Description Course Materials Deadlines 1 Mon March 30 Overview, tokenization [Percy] lecture_01.py Assignment 1 out [ code ] [ preview ] 2 Wed April 1 PyTorch (einops), resource accounting (FLOPs, memory, arithmetic intensity) [Percy] lecture_02.py ( recording version ) 3 Mon April 6 Architectures, hyperparameters [Tatsu] lecture 3.pdf 4 Wed April 8 Attention alternatives and mixture of experts [Tatsu] lecture 4.pdf 5 Mon April 13 GPUs, TPUs [Tatsu] lecture 5.pdf 6 Wed April 15 Kernels, Triton [Percy] lecture_06.py Assignment 1 due Assignment 2 out [ code
관련 소식