Curriculum
One path, four levels, 8 modules. Each lesson is a page you read and a program you run — the code on every page is editable and executes in your browser.
67 lessons · about 21 hours of reading and running
Beginner
No programming experience assumed
Intermediate
You can write and read basic Python
Advanced
Comfortable with functions, classes and modules
Expert
Building real systems for production
Module 01 · Beginner
Python Foundations
Everything you need to read and write ordinary Python: values, names, operators, the four core collections, and the statements that make a program branch and repeat. Every page runs in your browser.
- 01Your first programRun real Python in your browser, understand what print actually does, and meet the error message you will see most often.8 min
- 02Variables and typesBind names to values, learn the five types you will use constantly, and see why Python cares about the difference between "28" and 28.12 min
- 03Working with textIndex, slice and transform strings — the type that carries every prompt, response and log line you will ever write.14 min
- 04Operators and expressionsArithmetic, comparison, logic and assignment — plus the integer division and truthiness rules that surprise people.12 min
- 05ListsThe ordered, mutable collection you will reach for more than any other — building it, changing it, slicing it, and knowing when it is the wrong tool.15 min
- 06DictionariesKey-value mapping — the structure behind JSON, API payloads, model configs and almost every record you will ever handle.15 min
- 07Sets and tuplesTwo collections with sharp edges — sets for uniqueness and fast membership, tuples for values that must not change.12 min
- 08Making decisionsif, elif and else — plus indentation, the conditional expression, and the guard-clause pattern that keeps code flat.12 min
- 09Repeating workfor and while loops, range, enumerate and zip — and the three keywords that let you steer a loop from the inside.15 min
Module 02 · Intermediate
Core Python
Move from scripts to software. Functions and scope, comprehensions and generators, modules and virtual environments, files and JSON, exceptions, classes and dataclasses, and the type hints that every AI codebase leans on.
- 01Functions, arguments and scopePackage behaviour behind a name — defaults, keyword-only arguments, *args and **kwargs, and the mutable-default bug that has broken more chat helpers than any other.18 min
- 02Comprehensions and generator expressionsBuild a list, dict or set in one expression — and learn when swapping the brackets for parentheses turns the whole thing lazy.16 min
- 03Iterators, generators and lazy pipelinesThe protocol behind every for loop, how yield turns a function into a resumable stream, and how to chain generators into a pipeline that never loads the whole corpus.18 min
- 04Modules, packages and virtual environmentsSplit a script into files that import each other, understand how Python finds them, and pin an environment so your results reproduce on someone else's machine.18 min
- 05Files, paths and JSONpathlib instead of string surgery, context managers that always close, and JSON and JSONL — the two formats every dataset and API response arrives in.18 min
- 06Exceptions and defensive codetry, except, else and finally — plus custom exception classes, chaining with raise from, and the retry loop every API client eventually needs.18 min
- 07Classes, dunder methods and dataclassesBundle state with behaviour, make your objects work with len, in and == by implementing the protocols, and let dataclasses write the boilerplate for you.20 min
- 08Type hints and static checking with mypyAnnotate what your functions accept and return, model JSON payloads with TypedDict, describe duck typing with Protocol — and let mypy find the bug before you run anything.18 min
- 09Decorators and context managersWrap a function without touching it, build decorators that take arguments, and write your own with-blocks so setup and cleanup always pair up.20 min
- 10The standard library tour for AI workThe dozen modules that turn up in every AI codebase — collections, statistics, random and seeding, hashlib for cache keys, re for cleaning text, and os.environ for the API key you must never hard-code.20 min
Module 03 · Intermediate
Numerical Python
The mental model that separates people who use ML libraries from people who understand them: shapes, dtypes, broadcasting, and why a vectorised expression beats a Python loop by two orders of magnitude.
- 01Arrays, shapes and dtypesThe three questions to ask about any array — what shape, what dtype, is it a view — and why float32 halves the memory bill of every embedding you store.18 min
- 02Indexing, slicing and boolean masksSelect along several axes at once, filter with boolean masks instead of loops, and find the top-k results the way every retrieval system does.18 min
- 03Broadcasting rulesHow NumPy stretches a small array to meet a large one, the two-line rule that decides whether it will, and the keepdims trick that makes row-normalising a batch of embeddings a one-liner.18 min
- 04Vectorisation vs. Python loopsWhy the same arithmetic runs a hundred times faster as an array expression, which functions are genuinely vectorised, and how to write a numerically stable softmax.18 min
- 05Linear algebra you actually needDot products, matrix multiplication, norms and cosine similarity — the handful of operations that every embedding, attention head and linear layer is built from.20 min
- 06Random number generation and seedingThe modern Generator API, why a global seed is a trap, and how to sample tokens from a distribution with a temperature — reproducibly.16 min
- 07Matrix calculus intuition for gradientsWhat a gradient is, how the chain rule composes one, and how to check an analytic gradient against a numerical one — the intuition every training loop rests on.20 min
Module 04 · Intermediate
Data Wrangling
Real datasets are messy, and most of an AI project is spent here. Load, reshape, join, group, and visualise data — and learn the failure modes that quietly poison a model downstream.
- 01Series and DataFramesThe two pandas objects everything else is built on — a labelled array and a labelled table — and the five commands you run on every dataset you meet.18 min
- 02Selecting, filtering and assigningloc and iloc, boolean masks that read like sentences, and the chained-assignment mistake that silently does nothing.18 min
- 03Missing data and type coercionFind what is missing, decide honestly what to do about it, and fix the column that arrived as text — the two problems that quietly poison a model downstream.18 min
- 04Group-by, aggregate, pivotSplit-apply-combine — the operation that answers "how does this vary by model, by difficulty, by day?" — plus transform, pivot tables and crosstabs.20 min
- 05Joins and reshapingMerge predictions onto ground truth without silently duplicating rows, and move between the wide shape people read and the long shape tools want.20 min
- 06Time series basicsParse timestamps properly, index by them, resample to a coarser grain, and use rolling windows to watch a model's latency and quality drift.18 min
- 07Plotting with matplotlibDraw the four charts that answer most questions about a model — line, bar, histogram and scatter — and read the distribution a summary statistic hides.18 min
- 08Exploratory analysis without fooling yourselfSimpson's paradox, survivorship bias, small-group noise and the multiple-comparisons trap — the four ways a correct calculation tells you something false.20 min
Module 05 · Advanced
Machine Learning Foundations
Fit your first models, then take the lid off. Train/test discipline, pipelines, metrics that match the problem, and gradient descent and backpropagation implemented from scratch in NumPy.
- 01The estimator API and your first modelfit, predict, score — the three methods every scikit-learn model shares, and why a linear classifier over embeddings is the baseline you have to beat.18 min
- 02Train, validation and test splitsWhy a model must be judged on data it has never seen, how to split three ways, and the five kinds of leakage that make a held-out score a lie.18 min
- 03Pipelines and preprocessingBind preprocessing to the model so it cannot leak, cannot be forgotten at prediction time, and travels as one object you can save.18 min
- 04Choosing metrics that match the problemWhy accuracy lies on imbalanced data, what precision and recall actually trade off, and how to pick a threshold from the cost of each kind of mistake.20 min
- 05Cross-validation and hyperparameter searchGet an estimate with an error bar instead of one number from one lucky split, and search a parameter grid without leaking the validation set into the model.20 min
- 06Overfitting, regularisation and the bias-variance trade-offWatch a model memorise noise as you give it more capacity, read a learning curve to tell whether more data would help, and use regularisation to buy generalisation with a little bias.20 min
- 07Gradient descent from scratchBuild the optimiser every model is trained with — full-batch, stochastic and mini-batch — and see exactly what the learning rate does when you get it wrong.20 min
- 08A neural network in pure NumPyBuild a two-layer classifier — forward pass, cross-entropy loss, backpropagation and a training loop — in about forty lines, with no framework involved.24 min
- 09PyTorch: tensors, autograd and a training loopBuild a working autograd engine in eighty lines so nothing about PyTorch is mysterious, then read the real training loop you will run on your own machine.24 min
Module 06 · Advanced
LLM Engineering
Working with a large language model as a component in a program. The Messages API, streaming, system prompts, structured JSON output, tool use, and the agent loop that turns a model into something that acts.
- 01How an LLM API call actually worksThe request, the response and the statelessness — what you send, what comes back, and why the model has no memory between calls.18 min
- 02The Anthropic Python SDK: messages and streamingInstall it, call it, stream it, and handle the errors properly — including the retry rules that decide whether your client survives a bad afternoon.20 min
- 03System prompts, few-shot examples and prompt filesWhat belongs in the system prompt, how to show the model examples instead of describing them, and why prompts belong in version-controlled files rather than f-strings.20 min
- 04Structured output and schema validation with PydanticStop parsing prose. Declare the shape you need, have the API constrain the model to it, and validate what comes back — because a model's JSON is still untrusted input.20 min
- 05Tool use and the function-calling loopGive the model hands — define tools, run the request/execute/return loop, handle parallel calls and failures, and write descriptions the model can actually act on.22 min
- 06Building an agent loop from first principlesAn agent is the tool loop plus a termination policy, a budget and an approval gate — and the hardest part is deciding not to build one.22 min
- 07The Model Context Protocol (MCP)One standard for exposing tools, resources and prompts to any model client — what the protocol actually is, how to connect to a server, and why an MCP server is code you are trusting.20 min
- 08Token accounting, caching and cost controlCount tokens properly, cache the stable prefix, find the one-character change that silently destroys your hit rate, and know which levers are free before you trade quality for money.22 min
Module 07 · Expert
Retrieval and RAG
Give a model access to knowledge it was never trained on. Chunking strategies, embeddings, vector indexes, hybrid and re-ranked retrieval, and how to evaluate whether the answer was actually grounded.
- 01Embeddings and vector similarityTurn text into vectors whose geometry means something, measure similarity properly, and handle the practical parts — batching, caching and the fact that you can never mix two models' vectors.20 min
- 02Chunking strategies that survive contact with real documentsSplitting on a character count cuts sentences in half and answers with them. Split on structure, overlap deliberately, and carry the metadata that lets a chunk explain where it came from.20 min
- 03Building a vector indexExact search is one matrix product and works further than you think. Build an index with metadata filtering and persistence, then learn what approximate search buys and what it costs.20 min
- 04Hybrid search: dense plus keywordEmbeddings miss the exact error code, the product name and the rare identifier. BM25 finds them and misses the paraphrase. Run both and fuse the rankings.20 min
- 05Re-ranking and context assemblyRetrieve widely, then choose carefully — cross-encoders, maximal marginal relevance, de-duplication, and the context budget that decides what the model actually sees.20 min
- 06A complete RAG pipelineIngest, chunk, embed, index, retrieve, re-rank, assemble, answer, cite — every stage from this module wired together, with the contract that makes an answer checkable.24 min
- 07Measuring groundedness and retrieval qualityRecall@k, MRR and nDCG for the retriever; groundedness and citation accuracy for the answer — and the ablation that tells you which stage is actually at fault.22 min
Module 08 · Expert
Production AI Systems
The engineering that separates a notebook from a service. asyncio and concurrent API calls, retries and rate limits, pytest for non-deterministic systems, evaluation harnesses, observability, packaging and deployment.
- 01asyncio: concurrency for I/O-bound AI workloadsA hundred API calls one after another take a hundred times as long as one. Run them concurrently, bound the concurrency, and never block the event loop.22 min
- 02Retries, timeouts, backoff and rate limitsRetry the right failures, back off with jitter so your clients stop synchronising, respect Retry-After, and shed load before the service does it for you.22 min
- 03Testing non-deterministic systems with pytestThe model is not the unit under test. Test everything around it deterministically with fakes and fixtures, assert properties rather than exact strings, and keep the statistical question separate.22 min
- 04Building an evaluation harnessA runnable eval set, graders that check properties, results recorded with the prompt and model that produced them, and a comparison that tells you exactly which examples changed.22 min
- 05LLM-as-judge, and its failure modesA model can grade what no assertion can reach — and it has biases towards length, towards itself, and towards agreeing with whatever it just read. Calibrate it against humans before you trust a number it produced.22 min
- 06Structured logging, tracing and observabilityA print statement cannot be queried. Emit JSON events with a request id, time every stage as a span, record the fields that explain an answer — and never log the key or the prompt by accident.20 min
- 07Serving models with FastAPITyped request and response models, async endpoints, streaming, dependency injection for the client, and error handling that turns an upstream 429 into the right status code.22 min
- 08Packaging, dependency pinning and reproducibilityDeclare dependencies in pyproject.toml, lock them so a build resolves identically in a year, and record the seeds, versions and data hashes that let somebody reproduce a number you reported.20 min
- 09Cost, latency and capacity planningTurn a product requirement into concurrency, a rate-limit headroom figure and a monthly bill — before you build it, and in numbers you can defend.22 min