AI From Scratch
A complete course on artificial intelligence, from the mathematics up to LLMs, agents and MCP. Thirty chapters, each one worth reading on its own.
The Perceptron From Scratch: What a Neuron Computes
A neuron is a weighted sum and a threshold. That is the whole idea — and its limits are what forced everything that came after.
Where a Loss Function Comes From: Likelihood, Not Convention
Squared error is not a convention. It is a claim about the noise, and you can watch it be wrong.
Downhill: Gradient Descent, and the Two Steps Everyone Skips
Everybody writes the minus sign. Almost nobody says why it is there, or how big a step it survives.
Classification, Cross-Entropy, and How Not to Fool Yourself
Accuracy is the easiest number to report and the easiest one to be fooled by.
Backpropagation From Scratch: The Engine, Then the Network
Backpropagation is not a neural network algorithm. It is the chain rule, applied to a graph, in the efficient direction.
Getting It to Train, and Getting It to Generalise
The gradient is correct and the network still does not learn. This chapter is about the difference.
Build a BPE Tokenizer: Why Your Model Can't Count the R's
The model never sees letters. Everything strange about how it spells, counts and indents follows from that.
Next-Token Prediction: Embeddings, and What Perplexity Means
One objective, no labels, and a table of vectors nobody designed.
Attention and the Transformer Block, Derived From an Average
Attention is not a formula to accept. It is what you get when you stop averaging the past uniformly and let the model choose the weights.
Pretraining an LLM: Data, Compute, Scaling Laws and Cost
The remaining decisions are not programming decisions. They are purchases.
From Base Model to Assistant: SFT, RLHF, DPO and GRPO
A pretrained model does not answer questions. It continues text, and the difference is a second training stage nobody sees.
Chain of Thought, RLVR and Test-Time Compute, Measured
A model does not think. It spends more tokens before answering, and that is measurable and billable.
Making Inference Cheap: KV Cache, Batching and Quantization
Generation is not one problem. It is a compute-bound first token followed by thousands of memory-bound ones, and almost every trick in serving comes from that split.
Your First Production LLM Call: Streaming, Retries, Timeouts
The model is now behind a port. Almost nothing that goes wrong from here is mathematics.
Prompt Engineering, Measured: What Changes the Output
A prompt is measured, not debated. Four variants over twenty cases distinguish nothing at all.
The Context Window, Tokens and the Bill, Measured
The window is not memory. It is refilled from scratch on every call, and you pay for the refill.
Temperature, Top-p and the Determinism You Do Not Have
Temperature does not make a model more creative. It raises the probability of tokens the model itself scored at the bottom, and you can watch it happen.
Tool Calling and Structured Outputs: The Contract That Holds
The model never executes anything. It asks, in a shape you defined, and the shape is the only part you control.
RAG in Production: Chunking, Retrieval and Honest Citations
Bad chunking destroys the answer before search begins, and no reranker recovers it.
Fine-Tune, Retrieve or Prompt? The Decision Is Economic
Nobody asks this question about the model. They ask it about a budget.
Multimodal Pricing: What Images, Audio and Video Really Bill
A photograph does not cost one photograph. It costs tokens, by a formula you did not choose.
What an AI Agent Is: Five Classic Types, Two Rival Definitions
One tool in the catalogue turned one call into two and 39 input tokens into 420. Whether that made it an agent depends on whose definition you open.
Build an Agent Harness: The Loop and Its Five Ways Out
The loop is fifteen lines. Everything that makes it shippable is a way of leaving it.
Context Engineering: Why Your Agent Gets Dumber at Turn 40
The window did not overflow. The fact just moved, and the agent stopped finding it.
Multi-Agent Orchestration: Five Patterns, and When One Wins
Four arrangements, one task, one bill. The cheapest was wrong and the most expensive could not check its own workers.
MCP Explained Against the Spec: What a Server Really Is
It is not magic. It is a transport, a message format and three primitives, and you can type it by hand.
Ship an MCP Server: TypeScript and Python, Measured
Two SDKs, one wire. The interesting differences are the ones the protocol cannot see.
Agent Skills and SKILL.md: Progressive Disclosure, Measured
A skill is a folder with a Markdown file in it. Everything interesting follows from which part of that file gets read, and when.
LLM Evaluation: From Public Benchmarks to Your Golden Set
A number without an interval is an anecdote with decimals.
Prompt Injection and the Lethal Trifecta: Securing a Real Agent
The model cannot tell your instruction from a stranger's. Everything that works is built on accepting that.