Skip to content
All categories

ai

1264 posts

k-means and Gaussian Mixture Models: How Do You Cluster Without Labels? | Stanford CS229 Lecture 9

Lecture 9 starts from the two steps of k-means, assign and average, and explains why the algorithm always stops yet only reaches a local optimum. Replacing hard assignments with probabilities gives the Gaussian mixture model and the two steps of EM: an E-step that is Bayes' rule and an M-step that is a weighted average. The lecture ends with the picture behind EM, drawn with Jensen's inequality: each round builds a lower bound that touches the log-likelihood and climbs to its top. The full derivation waits for Lecture 10.

The EM Algorithm and PCA: How a Lower Bound Keeps the Likelihood from Dropping | Stanford CS229 Lecture 10

The first half uses Jensen's inequality to build a lower bound on the log-likelihood, the ELBO, then picks Q to be the posterior so the bound is tight at the current parameters. From that it follows that no round of EM can lower the likelihood, and plugging in a Gaussian mixture recovers last lecture's weighted-average formulas. The second half writes PCA as maximizing uᵀΣu over unit vectors; the answer is the eigenvector of the covariance matrix with the largest eigenvalue.

Diffusion Models: How Do You Learn to Run the Noising Process Backward? | Stanford CS229 Lecture 11

Each forward step multiplies the data by √(1−β_t) and adds Gaussian noise with variance β_t. Unrolled, x_t = √ᾱ_t·x_0 + √(1−ᾱ_t)·ε̂_t, and nothing here is learned. The reverse direction is learned with a Gaussian p_θ(x_{t−1}|x_t): apply last lecture's ELBO to the whole trajectory, split it with the KL chain rule, and the loss at each step is ‖μ̃_t(x_t,x_0) − μ_θ(x_t,t)‖²/(2β̃_t). The lecture stops at this expression; simplifying it into noise prediction is left for Lecture 12.

The Diffusion Noise-Prediction Loss, Foundation Models, and LoRA | Stanford CS229 Lecture 12

The first half collapses the diffusion ELBO into one expression: every time step is a squared error for guessing the noise that was added, which gives a five-step training procedure and a one-loop sampler. The second half opens the foundation-model unit: the two-stage paradigm of pretraining plus adaptation, linear probe, finetune, LP-FT, and why LoRA trains only 2dr parameters yet saves very little compute.

Contrastive Learning and Semantic Retrieval: How to Learn Vectors You Can Compare Without Labels | Stanford CS229 Lecture 13

This lecture unpacks the SimCLR loss into a B×B similarity matrix: each row is one softmax classification problem whose answer is the diagonal entry. The diagonal gets pulled up and everything else gets pushed down, so the model learns that similar things have nearby vectors without any labels. The second half uses the same vectors for semantic retrieval, then connects that to RAG.

Large Language Models: Next-Token Loss and How Attention Is Computed | Stanford CS229 Lecture 14

This lecture takes a large language model apart in three layers: tokenization turns text into token IDs, the chain rule splits the probability of a whole text into a sequence of next-token conditionals, and training sums the cross-entropy at every position. The second half opens up the Transformer: inner products of queries and keys go through a softmax to give weights, the weights average the values, and a causal mask blocks future positions. The cost of a single attention layer grows with the square of the sequence length T.

Attention Variants, MoE, and Prompting: What to Do When the KV Cache Is Too Big | Stanford CS229 Lecture 16

During generation, every head has to keep the keys and values of all past positions in GPU memory, and this KV cache caps the batch size. GQA lets τ query heads share one set of keys and values, shrinking the cache to 1/τ; sliding window attention cuts the T² compute down to T·w; MoE runs only 8 of 128 experts for each token. The second half covers how to use a trained model: few-shot and zero-shot prompting leave the parameters alone, SFT changes them, and its loss is computed only on the answer tokens.

Reinforcement Learning Basics and Policy Gradient: Taking a Gradient When the Parameters Hide in the Sampling Distribution | Stanford CS229 Lecture 18

The first 55 minutes of this lecture write sequential decision making as an MDP (states, actions, transition probabilities, rewards, discount factor) and show that the Bellman equation for a fixed policy is a system of linear equations. The last 20 minutes derive policy gradient: ∇p = p∇log p turns the gradient back into an expectation, the transition probabilities drop out of the gradient because they don't contain θ, and the lecture stops at the formula "sum of log-probability gradients × sum of discounted rewards", leaving variance reduction for the next lecture.

Baselines, PPO, and Verifiable Rewards: How Grading Only the Answer Trains Long Chains of Thought | Stanford CS229 Lecture 20

The last lecture of the term finishes policy gradient: past rewards and any baseline that depends only on the state can be removed from the weight without changing the expectation. It then derives PPO's clipped objective from importance sampling, splits it into four cases to see which samples still carry a gradient, and compares the change CISPO makes. Finally it writes token-by-token generation in a language model as an MDP, gives a reward of 1 only when the answer is right, and trains long chains of thought using the average over 8 samples of the same question as the baseline.

Why Generating an Answer Still Requires Verification | Stanford CS329A Lecture 1

An agent needs trustworthy feedback to correct its actions; improving one task’s result does not mean its model weights have learned.

Final Projects: Build a Reproducible Generative-Model Experiment | CMU 10-423 Topic Guide

Design controlled comparisons, retain paired outcomes, and distinguish replication from working code in a generative-model project.

Autodiff in Practice: From Hand Gradients to a Training Loop | CMU 10-423 Assignment 0

Knowing that backpropagation uses the chain rule is different from implementing a correct training loop.

Paper Reports: Turn a Model Summary into a Testable Argument | CMU 10-423 Assignment 623

Separate paper claims, empirical support, and your own interpretation through a role-based report and a controlled-comparison example.

Causal Attention: From Q, K, and V to the Next Token | CMU 10-423 Lecture 2

An RNN compresses the prefix into a state.

Training and Decoding: Why the Same Logits Produce Different Sequences | CMU 10-423 Lecture 3

Learning a next-token distribution and choosing a token from that distribution are consecutive but distinct operations.

Diffusion Training and Sampling: Random Timesteps and Reverse Chains | CMU 10-423 Lecture 8

Lecture 7 constructed noisy inputs and noise targets.

VAEs: Reconstruction, KL, and Reparameterization | CMU 10-423 Lecture 9

A conventional autoencoder compresses an input into a vector and reconstructs it.

ICL, SFT, and RLHF: From Changing Inputs to Changing Weights | CMU 10-423 Lecture 11

Separate what ICL, SFT, reward models, and RLHF each change, with worked examples and answered variations.

DPO and Latent Diffusion: Updating on Preferences, Conditioning the Denoiser | CMU 10-423 Lecture 12

Derive the DPO loss with a recomputable example, then trace shapes and conditioning paths in latent diffusion.

Vision-Language Models: Turning Images into Language-Model Inputs | CMU 10-423 Lecture 13

A complete worked example and answered variations for Vision-Language Models: Turning Images into Language-Model Inputs.