Generative AI#
Topic Course · Independent study
From probability to attention.
From models to agents.
A personal learning course by Chi-Kuang Yeh, beginning with statistics and statistical machine learning, and learning modern generative AI from the ground up.
Begin with what you know#
You understand probability, inference, linear algebra, optimization, and statistical machine learning. This course uses that background to explain generative AI, attention, transformers, and agents. No prior Python or GenAI knowledge is assumed. We introduce the programming language alongside the mathematics.
This is a self-paced Topic Course for independent study, with material that can later be adapted for teaching. There is no fixed semester or grading. The lessons are in English, using the terminology of the research literature.
Start with the complete first chapter
Chapter 1: From probability models to generative AI develops categorical estimation, log loss, smoothing, sampling, temperature, and a working bigram language model. It includes explained Python code, executed outputs, eight exercises, worked solutions, and a downloadable notebook.
A course in three stages#
Stage |
Chapters |
What you will understand |
|---|---|---|
Model the data |
1–4 |
Probability models, Python, embeddings, and attention as a context-dependent weighted average. |
Understand generation |
5–10 |
Transformers, language models, latent variables, diffusion, adaptation, and retrieval. |
Evaluate the system |
11–14 |
Uncertainty, agents, reliable experiments, and a small teaching or research project. |
Every chapter starts with a concrete question, develops a statistical formulation, and connects it to a small Python experiment. NumPy makes the mathematics visible; later chapters introduce PyTorch for neural networks.
Each chapter also includes a pipeline or framework diagram with the inputs, outputs, and checks at each stage. Read these alongside the code to distinguish fitting from prediction, model generation from evaluation, and an agent’s proposals from tool execution. The RAG chapter follows one question through indexing, retrieval, context selection, prompt construction, response validation, and evaluation.
Recommended system-building route: Chapters 1–6 → live lab 1 → Chapter 10 and live lab 2 → Chapter 11 → Chapter 12 and live lab 3 → Chapters 13–14 and live lab 4. Chapters 7–9 form an optional branch after Chapter 6. See the guided live notebooks and the prerequisite table in the course guide.
Study and experiment#
Set up Python and JupyterLab. You can also read the rendered lessons without installing anything.
Work through Chapter 1, running cells from top to bottom.
Use the statistical translation guide and selected readings when terminology is unfamiliar.
Follow the 14-chapter course guide, then complete the worked simulation-assistant project.
Complete core course: All 14 chapters contain developed lessons, mathematical explanations, executable Python experiments, exercises, worked solutions, and downloadable notebooks. The core chapter examples run on a laptop CPU without API keys or pretrained-model downloads. Appendix A supplies a step-by-step Python/PyTorch bridge. Appendix B adds a real local instruction model, RAG, an LLM tool policy, and a natural-language simulation assistant; its optional live run requires a model download, while the book analyzes saved real-model traces. The short Python warm-up remains available as a supplement.
The progression includes neural-network training, embeddings, masked attention, a tiny transformer, character generation, a VAE, diffusion, low-rank adaptation, preference learning, retrieval, uncertainty, tool-use policies, reliability experiments, and a worked statistical simulation assistant. Chapters 5–6 use the same tiny decoder for architecture, training, held-out scoring, and generation. Retrieval and agent chapters retain transparent baselines and link to the executed real-model comparisons in Appendix B. All chapters include worked examples, separate student notebooks, acceptance checks and transfer experiments. Chapters 10–14 use a common evaluation record.