Stanford CS 329Z · Engineering AI Agents
AI Agents, from first principles
These are self-study lessons built on the lectures of the Stanford course CS 329Z “Engineering AI Agents”. Every lesson starts from first principles. Each new term is explained where it first appears, and each formula is first worked by hand on small numbers.
Note: This is not an official Stanford site. These are personal notes made while studying the course. The slides and ideas belong to the course, and each lesson credits them at the bottom.
What you can read now
Lecture 3 · 18 lessons
RAG + Agents
How to give an LLM the right information at the right time, and where that approach breaks. The lessons build these ideas one at a time: retrieval, vectors, probability, the RAG model, chunking, BM25, DPR, measuring a retriever, hybrid search, ColBERT, agentic RAG, Search-R1, and the ways RAG fails.
Lessons for the other lectures will be added later.
Four versions of every lesson
Every lesson is written at two levels, and both exist in Hindi and English. A switch at the top of each lesson changes the level or the language at any time.
| Easy | Dense | |
|---|---|---|
| What it is | The core idea, step by step, with small numbers | The whole easy lesson, followed by steps that reach the level of the Stanford slides |
| For whom | A first reading | When you want every line and symbol on the slides |
| Maths | As much as the core calculation needs | All the maths on the slides, explained from school level |
Who these lessons are for
The lessons assume you read code and know school maths, but that ML and statistics terms are new to you. There are no analogies. Each idea is explained on a small version of the real system, such as 3 passages and vectors of 4 numbers, so the arithmetic can be done by hand.
How to read
- Open the lecture's index. Its map shows what to read before each lesson.
- Each lesson starts with a ladder. If you already know a step, skip to the next one.
- Work out the “Think first” questions yourself before opening the answer.
- Click any word with a dotted underline and ▾. Its definition opens right there.
How these lessons were written
The lessons follow a fixed set of rules, and each rule rests on research about teaching and writing. Every number was recomputed by a script. Read the full method: the teaching rules, their sources, and how each lesson was checked.