The course
AI engineering from first principles
174 lessons in seven phases. Every lesson runs real Python in your browser, ends with a quiz, and feeds a spaced-repetition review deck. 30 lessons are free, no account needed.
Phase 0 · 3–4 weeks
Tools
Python, the terminal and calling APIs. 24 lessons, all free to try.
- Your first program FreeRun Python, print output, and read an error message without panicking.
- Variables FreeGive values names so your program can remember and reuse them.
- Numbers and arithmetic FreeIntegers, decimals, rounding, and the math behind every metric.
- Strings and f-strings FreeWork with text: join it, slice it, clean it, and format it.
- Decisions with if/else FreeCompare values and choose what happens next.
- Lists FreeKeep many values in order, then index, slice and change them.
- Loops FreeRepeat work over every item without copy-pasting code.
- Dictionaries FreeLook values up by name: the shape of almost all real-world data.
- Functions FreePackage steps into reusable, testable pieces with inputs and outputs.
- Comprehensions FreeFilter and transform a whole collection in one readable line.
- Errors and exceptions FreeRead tracebacks, and handle the failures you expect.
- Modules and imports FreeUse Python's standard library instead of reinventing it.
- Classes and objects FreeBundle data with the functions that work on it.
- JSON FreeThe text format APIs and LLMs use to exchange structured data.
- Files and CSV data FreeRead and write files, and turn a spreadsheet export into Python data.
- NumPy arrays FreeDo math on whole columns at once, the foundation of every ML library.
- The terminal FreeNavigate folders and run programs by typing commands.
- Version control with git FreeSave snapshots of your work, undo mistakes, and share code.
- Packages and environments FreeInstall libraries with pip and keep projects isolated with venv.
- How APIs work FreeRequests, responses, methods, status codes and headers.
- Calling APIs from Python FreeSend requests, read JSON responses, and handle failures.
- API keys and secrets FreeAuthenticate safely and keep keys out of your code.
- Your first LLM call FreeSend messages to a model and read its reply, tokens and stop reason.
- Capstone: ad-copy reviewer FreeCombine files, functions, JSON and an LLM call into one small tool.
Phase 1 · 6–8 weeks
Building with LLMs
Prompting, retrieval, tools, agents and evals. 31 lessons, 1 free to try.
- What an LLM actually does FreeNext-token prediction, and why that produces useful behavior.
- Tokens and the context windowHow text becomes tokens, and what fits in one request.
- Prompt fundamentalsClear instructions, context and constraints: the 80% of prompting.
- System prompts and rolesSet behavior once, separately from the conversation.
- Examples in promptsShow the model what good looks like (few-shot prompting).
- Structured outputGet reliable JSON back that your code can use.
- Prompt chainingBreak big tasks into a pipeline of smaller model calls.
- Choosing a modelTrade capability, speed and cost across model families.
- Reasoning models and effortWhen models think before answering, and how to control it.
- Streaming responsesShow output as it's generated instead of waiting.
- Conversations and memoryAPIs are stateless: how chat history and memory really work.
- Images and documentsSend screenshots, PDFs and charts as input.
- EmbeddingsMeaning as a list of numbers, so text can be compared.
- Similarity searchFind the most relevant text by comparing embeddings.
- Chunking documentsSplit long documents so the right piece can be retrieved.
- Vector databasesStore and search millions of embeddings quickly.
- Retrieval-augmented generationAnswer from your own documents instead of the model's memory.
- Making RAG goodHybrid search, reranking and citations.
- Hallucinations and groundingWhy models make things up, and how to design against it.
- Tool useLet the model call your functions (function calling).
- The agent loopModel → tool → result → model, until the task is done.
- Model Context ProtocolA standard way to plug tools and data into any AI app.
- Agent design patternsRouting, orchestrator-workers and when not to build an agent.
- LLMs in automationsPut models inside scripts and workflow tools that run on their own.
- Prompt injection and securityHow untrusted text hijacks models, and how to limit the damage.
- EvalsMeasure output quality with test sets instead of vibes.
- LLM-as-judgeGrade open-ended output with rubrics and a second model.
- Cost and latencyPrompt caching, batching and routing to cheaper models.
- Logging and monitoringSee what your LLM app actually did in production.
- Shipping an LLM appDeploy, secure keys, rate-limit and handle failures.
- Capstone: research agentA marketing research agent with retrieval, tools and evals.
Phase 2 · 6–8 weeks
Math, when you need it
The linear algebra, calculus and probability models run on. 29 lessons, 1 free to try.
- Vectors FreeA list of numbers as a point or an arrow in space.
- Vector arithmetic and lengthAdd, scale and measure vectors.
- Dot product and cosine similarityThe one operation behind similarity search and attention.
- MatricesTables of numbers that hold datasets and model weights.
- Matrix multiplicationMany dot products at once: what a neural network layer computes.
- Matrices as transformationsA matrix stretches, rotates and projects space.
- Transpose, identity and inverseThe matrix operations you'll see in every formula.
- TensorsArrays with more axes: batches, sequences, heads.
- Eigenvectors (intuition)The directions a transformation leaves pointing the same way.
- SVD and PCACompress data to its most important directions.
- Functions and graphsRead a graph and see how an output depends on an input.
- Exponentials and logarithmsGrowth, decay, and why logs turn products into sums.
- DerivativesThe slope at a point: how fast the output changes.
- Derivative rulesPower, sum and product rules, so you rarely compute from scratch.
- The chain ruleDerivatives of functions inside functions: the heart of backprop.
- Partial derivativesChange one input at a time when there are many.
- GradientsThe vector of all partial derivatives: which way is uphill.
- Optimization by walking downhillRepeatedly step against the gradient to find a minimum.
- Probability basicsEvents, outcomes and the rules for combining them.
- Conditional probability and BayesUpdate beliefs when new evidence arrives.
- DistributionsRandom variables and the shapes their outcomes take.
- Mean, variance and spreadExpected value, variance and standard deviation.
- The normal distributionThe bell curve, and why it shows up everywhere.
- Samples and confidenceEstimate from a sample and say how sure you are.
- A/B tests and significanceTell a real lift from noise.
- Maximum likelihoodChoose the parameters that make the data most probable.
- SoftmaxTurn any list of scores into probabilities.
- Entropy and surpriseMeasure uncertainty in bits.
- Cross-entropy and KL divergenceThe loss function language models are trained on.
Phase 3 · 4–6 weeks
Machine learning
Learning from data, and knowing when it worked. 24 lessons, 1 free to try.
- What machine learning is FreePrograms that learn rules from examples instead of being told them.
- Features and labelsSupervised learning: inputs, targets and predictions.
- Preparing dataClean, encode and scale data before a model sees it.
- Feature engineeringTurn raw data into signals a model can use.
- Train, validation and test setsHold data back so you can trust your results.
- Linear regressionFit a line, and predict numbers from features.
- Loss functionsOne number that says how wrong the model is.
- Training with gradient descentAdjust weights step by step to reduce the loss.
- Learning rateStep size, convergence and divergence.
- Logistic regressionPredict probabilities for yes/no outcomes.
- Multiclass classificationSoftmax and cross-entropy for more than two classes.
- Decision treesLearn a flowchart of yes/no questions.
- Random forests and boostingMany weak models voting beat one strong one.
- Nearest neighborsPredict from the most similar examples.
- Overfitting and underfittingMemorizing versus learning.
- RegularizationPenalize complexity so models generalize.
- Bias and varianceThe two ways a model can be wrong.
- Precision, recall and F1Accuracy lies; these don't.
- ROC curves and AUCJudge a classifier across every threshold.
- Cross-validationReuse limited data for more reliable estimates.
- ClusteringGroup similar items without labels (k-means).
- Dimensionality reductionVisualize and compress high-dimensional data.
- The scikit-learn workflowFit, predict and evaluate with the standard ML library.
- Capstone: churn predictionPredict which customers will leave, and measure it properly.
Phase 4 · 6–8 weeks
Deep learning
Neural networks, backprop and training them well. 23 lessons, 1 free to try.
- The artificial neuron FreeWeighted sum plus a nonlinearity.
- Activation functionsReLU, sigmoid, GELU, and why nonlinearity matters.
- Multi-layer networksStack layers to learn complex functions.
- The forward passFollow numbers through a network to a prediction.
- Computation graphsEvery calculation as a graph of small operations.
- BackpropagationThe chain rule applied backwards to get every gradient.
- Build an autograd engineWrite backprop yourself in ~100 lines (micrograd).
- Weight initializationStart weights at the right scale.
- The training loopForward, loss, backward, step, repeat.
- Mini-batches and SGDTrain on small random batches instead of everything at once.
- OptimizersMomentum and Adam.
- Normalization layersBatch and layer norm keep training stable.
- DropoutRandomly switch off neurons to prevent overfitting.
- Vanishing and exploding gradientsWhy deep networks were hard to train.
- Debugging trainingRead loss curves and fix what's wrong.
- Residual connectionsSkip connections that let gradients flow.
- Convolutional networksPattern detectors for images.
- Recurrent networksProcess sequences step by step, and their limits.
- Embedding layersLearned lookup tables that turn tokens into vectors.
- PyTorch tensorsNumPy-like arrays that run on GPUs.
- PyTorch autograd and modulesLet PyTorch compute gradients; build models with nn.Module.
- GPUs and computeWhy deep learning runs on graphics cards.
- Capstone: train a classifierBuild, train and debug a network end to end.
Phase 5 · 6–8 weeks
Transformers
Attention, GPT from scratch and pretraining. 21 lessons, 1 free to try.
- Language modeling FreePredict the next token, and score it with cross-entropy.
- Tokenization and BPEHow tokenizers are built from data.
- A bigram modelThe simplest language model, built from counts.
- Sampling strategiesTemperature, top-k and top-p: turning probabilities into text.
- Neural language modelsWhy counting fails, and what embeddings fix.
- Attention: the intuitionEach token decides which other tokens matter to it.
- Queries, keys and valuesThe three projections behind attention.
- Scaled dot-product attentionThe attention formula, line by line.
- Causal maskingStop tokens from seeing the future.
- Multi-head attentionSeveral attention patterns in parallel.
- Positional encodingsTell the model where each token sits.
- The transformer blockAttention, MLP, residuals and norms together.
- The GPT architectureA stack of decoder blocks that predicts the next token.
- Build a tiny GPTWrite and train a small GPT from scratch.
- Encoders and embedding modelsBERT-style models and where they fit.
- Pretraining at scaleData, compute and what models learn from the internet.
- Scaling lawsHow loss falls predictably with size, data and compute.
- Inference and the KV cacheWhy generation is fast after the first token.
- Long contextEfficient attention and million-token windows.
- Mixture of expertsRoute each token to a few specialist sub-networks.
- Multimodal transformersHow models see images and hear audio.
Phase 6 · 6–8 weeks
Modern LLM engineering
Post-training, fine-tuning, serving and safety. 22 lessons, 1 free to try.
- Base models vs assistants FreeWhat post-training adds to a pretrained model.
- Supervised fine-tuningTeach behavior from example conversations.
- Instruction and preference dataThe datasets that shape assistant behavior.
- RLHFReward models and reinforcement learning from human feedback.
- DPO and direct preference methodsPreference training without a separate reward model.
- Constitutional AITraining with AI feedback guided by written principles.
- Training reasoning modelsReinforcement learning on verifiable problems.
- Prompting vs RAG vs fine-tuningPick the cheapest approach that works.
- LoRAFine-tune a big model by training small low-rank updates.
- Fine-tune an open modelRun a real fine-tune and evaluate the result.
- DistillationTrain a small model to imitate a large one.
- QuantizationStore weights in fewer bits to run models cheaply.
- Serving modelsBatching, throughput and latency in production.
- Speculative decodingDraft with a small model, verify with a big one.
- Running open models locallyDownload, quantize and run a model on your own machine.
- Benchmarks and their limitsWhat leaderboards measure, and what they miss.
- InterpretabilityLooking inside models to see what they compute.
- Alignment and safetyMaking capable models behave as intended.
- Multi-agent systemsCoordinating many agents on one large job.
- Evaluating agentsMeasure multi-step, tool-using behavior.
- Reading AI papersGet the idea out of a research paper in 30 minutes.
- Capstone: a tuned, evaluated assistantFine-tune, evaluate and deploy a specialist assistant.