Hands-on labs
Each lab pairs with chapters of the guide, runs on a laptop CPU, and ends with exercises. Do the internals labs first; the security labs assume you have read the attack chapters. Use a disposable environment (a virtual machine or throwaway folder) for anything that handles untrusted files.
- Predict a model’s size from its configuration: about 30 minutes. Turn a config.json into a parameter count, a KV-cache size and a memory budget, then check it against the real model.
- Write attention from scratch: about 45 minutes. Grouped-query attention with rotary positions in about 40 lines of NumPy, verified by two properties.
- Tiled attention with online softmax: about 40 minutes. Reproduce the core idea of FlashAttention and show it equals ordinary attention.
- See tokens, chat templates and next-token probabilities: about 30 minutes. Make the first steps of the model visible with a small open model on CPU.
- Build and measure a prompt injection: about 60 minutes. Build a vulnerable app, measure an attack with confidence intervals, add a defense, and re-measure.
- Adversarial examples with FGSM: about 30 minutes. One gradient step on the input flips a classifier.
- Why loading a pickled model can run code: about 20 minutes. See the risk in a disposable environment, then compare with a data-only format.
- Membership inference with a loss threshold: about 30 minutes. Measure how much a model leaks about its training set.
- Run an automated LLM vulnerability scanner: about 45 minutes. Run an open-source scanner on a local model and learn to critique its output.
- Reproduce the Explorer’s forward pass: about 40 minutes. Rebuild the Model Explorer’s trained transformer in NumPy from its published weights and match every number.