Notebooks
One Lab per Module, Each Opens in Google Colab
Start with the setup notebook, then follow the modules in order. Every notebook downloads its own data from this repository, so any lab opens cold, without the labs before it. Lab 10, for example, downloads the preference data and reward model that Lab 9’s code built. One comparison is optional and needs a file from an earlier lab: Lab 12 draws Lab 11’s language model beside its own decision model only if you upload the lab11_decisions_<provider>.jsonl file that Lab 11’s Exercise 4 writes. Without that file, Lab 12 draws its own model alone. It refuses a file written by Lab 11’s offline test double, because a test double is not a model.
Keep each lab’s headline number, and the conditions needed to compare it, in the results worksheet. A term you have forgotten is in the glossary.
Before Day 1
Start here · 10 minutes
Setup and Environment Check
Check the runtime, load optional API keys from Colab Secrets, and choose a provider.
Day 1 · Foundations
| # | Notebook | Briefing | Lab |
|---|---|---|---|
| 1 | Text as Data Tokenization, n-gram language models, TF-IDF and linear classifiers: the count-based baseline everything else is measured against. | Read | Open in Colab |
| 2 | Word Vectors and Neural Networks From one-hot vectors to learned embeddings, with a PyTorch refresher and the first neural language model. | Read | Open in Colab |
| 3 | Sequence Models RNNs, LSTMs and neural language modeling, and why gradients vanish over long sequences. | Read | Open in Colab |
| 4 | Seq2seq and Attention Encoder-decoder models, the fixed-vector bottleneck, and attention as the fix. | Read | Open in Colab |
Day 2 · Transformers and Pretraining
| # | Notebook | Briefing | Lab |
|---|---|---|---|
| 5 | The Transformer Self-attention, multi-head attention and positional encodings, assembled into a small GPT. | Read | Open in Colab |
| 6 | Pretraining and the Hugging Face Stack Subword tokenization, masked and causal pretraining, and using pretrained models through Hugging Face. | Read | Open in Colab |
| 7 | Fine-Tuning and LoRA Turning a pretrained language model into an instruction follower, efficiently. | Read | Open in Colab |
Day 3 · Using and Aligning LLMs
| # | Notebook | Briefing | Lab |
|---|---|---|---|
| 8 | LLMs Through APIs OpenAI and Claude side by side: prompting, structured output, tool use, cost and evaluation. | Read | Open in Colab |
| 9 | Reinforcement and Preference Learning Text generation as a reinforcement-learning problem, the policy gradient, and reward models learned from comparisons. | Read | Open in Colab |
| 10 | RLHF The full reinforcement-learning-from-human-feedback pipeline, DPO, and the ways it goes wrong. | Read | Open in Colab |
Day 4 · Calibration, Decisions, RAG
| # | Notebook | Briefing | Lab |
|---|---|---|---|
| 11 | Calibration What a probability should mean, how to measure it, and how to use confidence to decide when to abstain. | Read | Open in Colab |
| 12 | Calibrated Decisions: RLCD and Jev Training and using models for calibrated decisions: outcome rewards, thresholds from costs, and TypeSafe’s RLCD and Jev as a case study in what is and is not public. | Read | Open in Colab |
| 13 | Retrieval-Augmented Generation Building a RAG pipeline with LlamaIndex and LangChain, and evaluating retrieval and answers separately. | Read | Open in Colab |
Day 5 · Agents and Capstone
| # | Notebook | Briefing | Lab |
|---|---|---|---|
| 14 | Agents Tool-using agents as explicit graphs in LangGraph, with state, human-in-the-loop interrupts and confidence-gated control. | Read | Open in Colab |
| 15 | Capstone Combine retrieval, an agent graph and calibrated control into one system, evaluate it, and explain the design. | Read | Open in Colab |
Notebooks are stored without outputs. Work through the cells one at a time. Runtime → Run all stops at the first exercise you have not written, which is the point: to see a whole lab run, tick WORKED_EXAMPLE in the harness cell first.
How the Labs Are Laid Out
Run the cells in this order:
- Harness. The first code cell. It keeps the folded solutions from replacing your code and records which checkpoints passed. Leave
WORKED_EXAMPLEunticked to do the lab yourself (learner mode); tick it to run every reference solution in place of your code (worked-example mode). - Setup. Installs, imports and seeds.
- Data. Downloads the lab’s data and checks it.
- Exercises. Each has a
# TODOcell for you to complete, then a folded solution, then a checkpoint.- Solution. Try the exercise first, then open the solution to compare. Running a solution cell stores the reference; it does not overwrite your function.
- Checkpoint. Passes or fails, and says whose code it checked: yours or the reference.
- Stretch. An optional final section. Nothing later depends on it.
- Summary. The last code cell lists which checkpoints passed on your own code.
A checkpoint’s message tells you which of three things happened:
| The checkpoint says | What it means | What to do |
|---|---|---|
| TODO N is not written yet | You have not run your # TODO N cell, or your function still raises NotImplementedError. |
Write the exercise and run its cell, then rerun the checkpoint. |
| failed on your code | Your function returned a wrong value. | Read the assertion message above it, fix TODO N, and rerun both cells. |
| failed on the reference solution | A problem with the lab or the runtime, not with your code. | Tell the instructor. |
If you are stuck on exercise N, run its folded solution cell, then workshop.use_reference(N), and go on with the reference solution. Rerun your # TODO N cell to switch back to your own code.
An error in the harness, setup or data cells is a setup problem, not an unfinished exercise: see Setup, which also explains the optional API keys.