
Establish the hierarchy AI → Machine Learning → Deep Learning → Generative AI → Foundation Models → LLMs. Introduce NLP, generative models, foundation models, and what makes a model “large.” Explain how an LLM differs from a traditional task-specific ML model.
Demonstrates that self-attention alone does not intrinsically encode sequence order. Introduces permutation behavior and explains why token content and token position must both influence Transformer representations.
Introduces learned absolute positional embeddings and the sinusoidal encoding of the original Transformer. Explains how positional vectors are combined with token representations, their mathematical construction, and their limitations for long sequences.
Motivates relative positional information and introduces relative position embeddings/biases. Explains why the relationship "token (j) is 3 positions before token (i)" may be more useful than their absolute indices. Introduces ALiBi as an important alternative position-bias mechanism.
Develops RoPE geometrically and mathematically as position-dependent rotations of queries and keys. Explains how absolute rotations produce relative-position information in query-key interactions and why RoPE became central to modern decoder-only LLMs.
Revisits causal masking from Module 4 from a sequence-modeling perspective: which positions are visible to each token, why training must respect autoregressive factorization, and how the causal receptive field expands across the sequence. Distinguishes causal order from positional encoding.
Defines context length, prompt tokens, generated tokens and maximum sequence length. Explains how positional mechanisms, attention computation, KV-cache requirements and training distribution constrain usable context. Distinguishes context window from persistent memory.
Compares full attention with local/sliding-window and global attention patterns. Explains the computation and information-flow tradeoffs and shows how modern models combine local and global layers to reduce long-context cost while retaining long-range communication.
Explains what happens when a RoPE model is asked to process sequences longer than those seen during training. Introduces interpolation vs extrapolation, RoPE scaling, Position Interpolation, YaRN and related strategies, and discusses why increasing a declared context length does not automatically guarantee reliable long-context reasoning.
Establishes BERT-type encoder-only, T5-type encoder-decoder and GPT/Llama/Gemma-type decoder architectures. Compares attention direction, training objective, information flow and typical use cases. Explains why modern generative LLMs are predominantly decoder-only. Connects these families to their characteristic training objectives: masked language modeling, denoising/span corruption, and causal language modeling.
Uses the baseline decoder from Module 5 as a reference and shows how representative modern models change position encoding, normalization, attention-head sharing, context strategy, FFN design, sparsity, and multimodal interfaces. The emphasis is on reading architecture choices, not re-teaching the decoder stack.
Revisits Multi-Head Attention and develops Multi-Query and Grouped-Query Attention. Explains query heads vs KV heads, head sharing, tensor dimensions and why reducing KV heads lowers KV-cache memory and inference bandwidth requirements.
Compares attention variants in terms of representational capacity, KV-cache size, decoding speed and memory. Integrates full/global, local/sliding-window and hybrid attention patterns introduced in Module 6 and shows how modern models combine these choices.
Introduces major alternatives to standard quadratic self-attention, including linear-attention ideas, recurrent/hybrid sequence models, structured state-space models, and Mamba-style selective state spaces. Compares their state, parallelism, sequence-length scaling, and quality/efficiency tradeoffs without treating them as drop-in equivalents.
Defines dense parameter activation and contrasts it with conditional/sparse computation. Explains that a model may contain a very large number of parameters while activating only a subset for each token. Introduces sparsity as an architectural mechanism rather than ordinary numerical pruning.
Develops expert layers, routers, routing scores, Top-k expert selection, shared vs routed experts and weighted expert outputs. Shows how MoE commonly replaces or augments dense FFN computation while leaving the attention mechanism conceptually separate.
Distinguishes total model capacity from parameters activated per token. Examines expert capacity, load balancing, communication overhead and routing imbalance. Uses current Llama 4 and Gemma 4 examples to show why a model can have hundreds of billions of total parameters but use far fewer per token.
Conducts a structured architecture comparison using BERT, T5, GPT-style models, Llama 3, Llama 4 and Gemma 4. Students identify causal structure, normalization, positional mechanism, attention variant, dense/MoE FFN, context strategy and parameter activation, then reason about why each design choice was made.
Revisits autoregressive language modeling as a training objective rather than an inference mechanism. Constructs input-target pairs, explains teacher forcing and shifted labels, and shows how one sequence produces training targets at many token positions simultaneously.
Explains how tokenized corpora become fixed-length training sequences and batches. Covers sequence length, batch size, padding vs packing, document boundaries, special tokens and the number of tokens processed per optimization step.
Traces a complete batch through embeddings and the Transformer stack to logits [B, T, V], then aligns logits with next-token targets. Connects all architectural modules learned earlier to the actual pretraining computation.
Shows how next-token probabilities become per-token negative log-likelihoods and how losses are aggregated across sequence positions and batch examples. Introduces ignored/padded positions and connects training loss to perplexity conceptually.
Follows gradients from cross-entropy through the LM head, Transformer blocks, attention, FFNs and embeddings. Explains gradient accumulation over shared parameters and what loss.backward() computes for the complete model.
Revisits Adam from Module 2 at LLM scale. Explains first/second-moment estimates, learning rate, decoupled weight decay and the complete optimizer step, including why optimization state itself consumes substantial memory.
Explains why parameter initialization and update magnitude matter in deep Transformers. Covers initialization scale, learning-rate warmup, constant/cosine decay schedules, minimum learning rate and gradient-norm clipping.
Introduces training vs validation loss, periodic evaluation, checkpoint selection and reproducible resumption. Explains what a true training checkpoint must contain beyond model weights: optimizer state, training step, configuration and other relevant training state.
Integrates the module into executable code: load batch → forward → loss → zero gradients → backward → clip gradients → set learning rate → AdamW step → evaluate → checkpoint. Students train a small decoder-only language model and inspect its learning curve and generated samples.
Surveys major pretraining sources including web pages, books, code, scientific literature, encyclopedic material and other public text. Introduces raw documents vs extracted text vs tokens, data provenance and why diversity, quality and scale all matter. Introduces provenance, licensing/usage constraints, privacy/PII awareness, and reproducibility as practical data-governance considerations.
Builds the preprocessing pipeline: acquisition → content extraction → normalization → language identification → document cleaning → filtering. Uses Common Crawl-style data to show why raw internet data cannot simply be fed directly into an LLM.
Covers heuristic and model-based quality filters, language confidence, document length, repetition, malformed text, spam and undesirable content. Explains the fundamental tradeoff between aggressively improving average quality and accidentally removing useful diversity.
Introduces exact and near-duplicate detection, document- and substring-level deduplication, hashing/MinHash concepts and why duplicates waste compute and may increase memorization. Separately explains benchmark contamination and train/validation/test leakage.
Explains how web, code, mathematics, science and other sources are assigned sampling weights rather than simply concatenated. Introduces up/down-sampling, data-mixture optimization, synthetic data, model-generated rewriting and the risks of poor synthetic feedback loops.
Introduces model size (N), training-token count (D), and compute budget (C). Develops approximate Transformer training-compute accounting and explains the central resource-allocation problem: under fixed compute, should we train a larger model, process more tokens, or train longer?
Introduces power-law relationships between language-model loss and model/data/compute scale, following the Kaplan-style scaling-law framework. Explains log-log plots, fitted exponents, irreducible loss and why small experimental runs can inform much larger training decisions.
Develops the model-size/data-size tradeoff under fixed compute and explains how Chinchilla revised earlier scaling intuition by showing that many large models were undertrained on too few tokens. Distinguishes compute-optimal parameter count from simply choosing the largest possible model.
Integrates the module. Students receive a fixed compute/data budget and design a training plan: corpus mixture, filtering, deduplication, parameter count, token budget and expected loss. They fit a simple scaling law from smaller training runs and justify the planned larger run.
Explains why Transformer training maps well to GPUs. Compares CPU and GPU execution, parallelism, matrix multiplication and accelerator throughput. Introduces GPU cores, tensor/matrix units and why large batched tensor operations dominate LLM workloads.
Teaches students to estimate parameter memory, gradients, optimizer states, activations and training FLOPs before running a model. Introduces memory vs compute bottlenecks and establishes a quantitative framework for answering "Will this model fit?" and "How expensive is this step?"
Covers registers/on-chip memory, caches/SRAM concepts, HBM/GPU memory and host memory. Explains bandwidth, data movement, arithmetic intensity and compute-bound vs memory-bound operations using a roofline-style intuition.
Compares FP32, FP16 and BF16 in range, precision, memory and throughput. Explains mixed precision, master/optimizer states, loss scaling where needed, and introduces FP8 as a modern accelerator optimization rather than a replacement for understanding FP16/BF16.
Revisits gradient accumulation as a systems tool, distinguishes microbatch from global batch size, and explains activation checkpointing/recomputation: storing fewer forward activations and recomputing them during backward to reduce memory at additional compute cost.
Explains what a GPU kernel is, why launching/materializing many intermediate operations can be inefficient, and how kernel fusion reduces data movement. Develops FlashAttention as an IO-aware implementation of exact attention that avoids materializing the full attention intermediates in slow GPU memory.
Introduces Triton conceptually as a language for writing custom GPU kernels at a higher abstraction level than CUDA. Students implement/profile a simple operation and inspect how blocking, memory access and fusion affect performance before examining an attention kernel.
Starts multi-GPU training with replicated models and partitioned batches. Develops gradient synchronization through all-reduce, then explains why DDP still replicates model state and how ZeRO/FSDP progressively shard optimizer states, gradients and parameters.
Explains how models too large for one GPU can be partitioned within individual layers, across model depth and across sequence dimensions. Distinguishes tensor parallelism from pipeline parallelism and, critically, sequence parallelism from context parallelism.
Explains expert parallelism for MoE models, token dispatch and all-to-all communication. Integrates DP/FSDP, TP, PP, CP and EP into multidimensional training configurations and introduces communication topology, NCCL collectives and computation/communication overlap.
Have you ever wondered what really happens inside ChatGPT, Claude, or Gemini after you press Enter? This course takes you inside a Large Language Model, step by step, and explains the mechanisms in plain language, without hiding behind buzzwords.
You will start with the basics of AI, machine learning, and language modeling. Then you’ll build the math you need (vectors, probability, gradients, backpropagation) so that nothing feels like magic. From there, you’ll follow the full journey of a prompt: tokenization, embeddings, the Transformer architecture, self-attention, positional encoding, and how models are trained at scale.
You’ll also learn how a raw base model becomes a helpful AI assistant through fine-tuning, RLHF, DPO, and alignment. You’ll see how answers are generated token by token with temperature, top-k, top-p, and the KV cache. Finally, you’ll explore modern topics such as in-context learning, RAG, tool use and AI agents, Mixture-of-Experts, hallucinations, bias, security, evaluation, quantization, LoRA, and the future of LLMs.
What you’ll learn
How LLMs work from input text to final output
The math behind neural networks, explained simply
How tokenization and embeddings turn text into numbers
How self-attention and multi-head attention work
How LLMs are trained, fine-tuned, and aligned
How decoding strategies shape the model’s answers
How RAG, tools, and agents extend what LLMs can do
Why LLMs hallucinate, and how they are evaluated and made faster
Who this course is for
Students, developers, data professionals, and curious learners who want to truly understand LLMs, not just use them.