# AI Engineering from Scratch > A free, open-source curriculum that builds every core AI algorithm by hand — 542 lessons across 20 phases, from linear algebra to autonomous agents. Python, TypeScript, Rust, Julia, Go. Canonical site: https://aiengineeringfromscratch.com Source: https://github.com/rohitg00/ai-engineering-from-scratch Glossary terms: 250 · Reusable outputs (prompts/skills/agents): 526 ## API and MCP - [AI Engineering from Scratch API docs](https://aiengineeringfromscratch.com/docs): public read-only API, authentication policy, errors, quotas, and versioning. - [OpenAPI 3.1](https://aiengineeringfromscratch.com/openapi.json): typed REST operations. - [MCP manifest](https://aiengineeringfromscratch.com/server.json): connect using Streamable HTTP at https://aiengineeringfromscratch.com/mcp. ## Developer resources - [Developer documentation](https://aiengineeringfromscratch.com/developer) — machine-readable site contracts and integration notes - [OpenAPI description](https://aiengineeringfromscratch.com/openapi.json) — read-only public resource inventory - [Sitemap](https://aiengineeringfromscratch.com/sitemap.xml) — canonical URL inventory - [Contact](https://aiengineeringfromscratch.com/contact) — maintainer and project contact route - [Privacy](https://aiengineeringfromscratch.com/privacy) — data and analytics policy ## Manuals Long technical manuals. Each one explains one subject at one exact version, and each section also has its own page. [Manuals index](https://aiengineeringfromscratch.com/manuals) [Manual sitemap](https://aiengineeringfromscratch.com/sitemap-manuals.xml) ### [A2A 101](https://aiengineeringfromscratch.com/manual-a2a-101): The Agent2Agent protocol, from its purpose to each request and response How one agent gives work to another agent that it cannot see inside. Each request, response, and stream event in this manual comes from a recorded run. Pinned to A2A protocol 1.0.1. - [How to read this manual](https://aiengineeringfromscratch.com/manual-a2a-101/front): Every claim in this manual traces to a ranked source, and every request, response, and stream frame comes from a capture kit you can run yourself. - [1.1 What A2A standardizes](https://aiengineeringfromscratch.com/manual-a2a-101/what-a2a-standardizes): A2A defines a data model, a set of operations, and three bindings for agents that cannot see inside each other, and leaves everything inside an agent to the… - [1.2 One task, request by request](https://aiengineeringfromscratch.com/manual-a2a-101/one-task-request-by-request): One streamed run of test-runner shows every piece of the protocol in order, from the card read to the moment the server closes the stream. - [2.1 AgentCard fields](https://aiengineeringfromscratch.com/manual-a2a-101/agentcard-fields): An AgentCard has 14 fields, eight of them REQUIRED, and together they say what an agent offers, where to reach it, and what it demands. - [2.2 Discovery and supportedInterfaces](https://aiengineeringfromscratch.com/manual-a2a-101/discovery-and-supported-interfaces): The spec standardizes only the well-known path to a card, and a client takes the first supportedInterfaces entry it speaks before it checks a capability flag. - [2.3 Extended cards and signatures](https://aiengineeringfromscratch.com/manual-a2a-101/extended-cards-and-signatures): GetExtendedAgentCard returns a fuller card to an authenticated caller, and signatures lets any caller check that a card is the one its publisher signed. - [3.1 Message](https://aiengineeringfromscratch.com/manual-a2a-101/message): A Message is one turn in a conversation, and its role and three ids say which way it travels and which task it continues. - [3.2 Part](https://aiengineeringfromscratch.com/manual-a2a-101/part): Every piece of content in A2A is a Part that holds exactly one of text, raw, url, or data, and its mediaType says how to read it. - [3.3 Artifact and chunks](https://aiengineeringfromscratch.com/manual-a2a-101/artifact-and-chunks): A task returns its results as artifacts, and a long artifact arrives as chunks that you join by artifactId until lastChunk marks the end. - [3.4 Task, TaskStatus, and TaskState](https://aiengineeringfromscratch.com/manual-a2a-101/task-and-task-state): A Task carries one TaskStatus, whose state is one of nine TaskState values, and the specification names those values without a table of the transitions… - [3.5 contextId](https://aiengineeringfromscratch.com/manual-a2a-101/context-id): A contextId groups many tasks into one conversation, a taskId groups many messages into one job, and only the server creates a task id. - [4.1 SendMessage](https://aiengineeringfromscratch.com/manual-a2a-101/send-message): SendMessage carries one message and a SendMessageConfiguration, and the agent answers with a Message or a Task that, by default, is terminal or interrupted. - [4.2 Interrupted states: INPUT_REQUIRED and AUTH_REQUIRED](https://aiengineeringfromscratch.com/manual-a2a-101/input-required-and-auth-required): A task can stop and wait for you, and the two kinds of waiting are answered in different places: input on the task itself, authorization outside the protocol. - [4.3 GetTask and ListTasks](https://aiengineeringfromscratch.com/manual-a2a-101/get-task-and-list-tasks): GetTask and ListTasks are your recovery path, and both follow exact rules about which parts of a task they leave out. - [4.4 CancelTask and terminal states](https://aiengineeringfromscratch.com/manual-a2a-101/cancel-task-and-terminal-states): Four terminal states end a task, the agent chooses three of them and CancelTask asks for the fourth, and no later call moves a task out of one. - [4.5 SendStreamingMessage and SubscribeToTask](https://aiengineeringfromscratch.com/manual-a2a-101/streaming-and-subscribe-to-task): A stream is a live view of one task, so a dropped connection costs you the frames sent while you were away and never the task itself. - [4.6 Push notification configs](https://aiengineeringfromscratch.com/manual-a2a-101/push-notification-configs): A TaskPushNotificationConfig tells an agent where to POST the same StreamResponse objects a stream carries, with credentials you chose, after your request has… - [5.1 JSON-RPC](https://aiengineeringfromscratch.com/manual-a2a-101/json-rpc): JSON-RPC posts every operation to one URL, names it in method, carries the request message in params, and returns the response message or an error in a 200… - [5.2 HTTP+JSON](https://aiengineeringfromscratch.com/manual-a2a-101/http-json): HTTP+JSON names each operation with a verb and a path from the proto's google.api.http annotations, and sends the request and response messages as plain JSON… - [5.3 gRPC](https://aiengineeringfromscratch.com/manual-a2a-101/grpc): The gRPC binding is the proto itself: the eleven rpcs of A2AService in package lf.a2a.v1, carried over HTTP/2 with TLS, with the service parameters in metadata. - [5.4 A2A-Version and A2A-Extensions](https://aiengineeringfromscratch.com/manual-a2a-101/version-and-extension-headers): Two service parameters travel as HTTP headers or gRPC metadata on every request, and a missing A2A-Version means 0.3, which a 1.0 agent must refuse. - [5.5 Errors](https://aiengineeringfromscratch.com/manual-a2a-101/errors): Nine A2A errors map into three bindings, and because their status codes collide, the ErrorInfo reason in the details is what tells them apart. - [6.1 Security schemes and in-task authorization](https://aiengineeringfromscratch.com/manual-a2a-101/security-schemes-and-in-task-authorization): The card declares which credentials an agent accepts, HTTP checks them on every request, and a running task can still stop to ask for an approval. - [6.2 Extensions](https://aiengineeringfromscratch.com/manual-a2a-101/extensions): An extension is a URI that a card declares, a client activates per request with A2A-Extensions, and both sides carry as metadata keyed by that URI. - [6.3 Security requirements](https://aiengineeringfromscratch.com/manual-a2a-101/security-requirements): Sections 13 and 14 list what a server and a client MUST and SHOULD check, and most of those checks fall on data that another agent sent. - [7.1 A client](https://aiengineeringfromscratch.com/manual-a2a-101/a-client): A working client is a loop that reads cards, picks an agent for each skill, and has a branch for every state a task can reach. - [7.2 A server](https://aiengineeringfromscratch.com/manual-a2a-101/a-server): A server is a card, one handler per binding, three checks before any work, an executor, an owner-scoped task store, and one event queue that feeds streams and… - [7.3 Conformance testing](https://aiengineeringfromscratch.com/manual-a2a-101/conformance-testing): a2a-tck grades one server against v1.0.0 on three bindings, and a run against the capture kit shows which failures are the server's and which are the TCK's. - [7.4 From 0.3 to 1.0](https://aiengineeringfromscratch.com/manual-a2a-101/from-0-3-to-1-0): Version 1.0 renames every operation, changes every enum value, flattens the card and the parts, and rejects a request without A2A-Version, so a 0.3 client… - [R.1 Operations by binding](https://aiengineeringfromscratch.com/manual-a2a-101/ref-operations-by-binding): Every A2A operation has one name in JSON-RPC and gRPC, one route in HTTP+JSON, one request and one response message, and a fixed list of errors. - [R.2 Objects and fields](https://aiengineeringfromscratch.com/manual-a2a-101/ref-objects-and-fields): The proto defines every object in a request, a response, or a stream frame, and each field has one lowerCamelCase JSON name, one type, and a presence rule. - [R.3 Task states](https://aiengineeringfromscratch.com/manual-a2a-101/ref-task-states): Nine values describe a task, and whether the current one is active, interrupted, or terminal tells the client what it can do next. - [R.4 Errors](https://aiengineeringfromscratch.com/manual-a2a-101/ref-errors): Every A2A error has a JSON-RPC code, an HTTP status, a gRPC status, and an ErrorInfo reason, and over HTTP the reason is what tells seven of them apart. - [R.5 Glossary](https://aiengineeringfromscratch.com/manual-a2a-101/ref-glossary): Each term below has one meaning across the manual, and its link names the section that defines it. - [R.6 Sources](https://aiengineeringfromscratch.com/manual-a2a-101/ref-sources): The manual rests on one pinned release, one reference SDK, five more SDKs, one test kit, and one capture kit, and it names every place where those sources… - [R.7 Index of figures](https://aiengineeringfromscratch.com/manual-a2a-101/ref-index-of-figures): Every figure in the manual, by the claim it makes. ### [Agent Substrate 101](https://aiengineeringfromscratch.com/manual-agent-substrate-101): Install, run, connect, and debug stateful agent actors on Kubernetes, with a measured answer for each decision How to install Agent Substrate, run actors that suspend and resume, control their network, connect kagent and agentgateway, and fix a cluster from the symptom. Measured on our own clusters with Agent Substrate v1.0.0. Pinned to Agent Substrate 1.0.0. - [How to read this manual](https://aiengineeringfromscratch.com/manual-agent-substrate-101/front): Install Agent Substrate on a kind cluster from the release images, wake one actor with a request, and then learn each part with the number we measured for it. - [1.1 What Substrate does, and what it leaves to you](https://aiengineeringfromscratch.com/manual-agent-substrate-101/what-substrate-does-and-what-it-leaves-to-you): Substrate runs many stateful actors on few worker pods and resumes one when a request arrives, and it leaves the suspend call, the pool size, and GPU work to… - [1.2 One request, from the client to the actor and back](https://aiengineeringfromscratch.com/manual-agent-substrate-101/one-request-from-client-to-actor): A request to a suspended actor passes the proxy, atenet-router, ate-api-server, and Postgres before a worker restores the actor, and a request to a running… - [2.1 Install with ate-setup](https://aiengineeringfromscratch.com/manual-agent-substrate-101/install-with-ate-setup): Install from the release images: that path skips the image builds, the Rust compile, and a failure that the upstream quickstart does not mention. - [2.2 kubectl ate](https://aiengineeringfromscratch.com/manual-agent-substrate-101/kubectl-ate): kubectl ate talks to ate-api-server and reads Postgres, and without --token-file every caller acts as one shared identity. - [2.3 Your first actor and kubectl ate proxy](https://aiengineeringfromscratch.com/manual-agent-substrate-101/your-first-actor-and-the-proxy): kubectl ate proxy is a tool for your own machine: it tunnels through the Kubernetes API server, so it fails when that server is down while actor traffic… - [2.4 What the install created](https://aiengineeringfromscratch.com/manual-agent-substrate-101/what-the-install-created): The system install created 15 running pods in three namespaces and three custom resources, and it put every atespace, template, actor, and worker in Postgres… - [3.1 ActorTemplate and the golden snapshot](https://aiengineeringfromscratch.com/manual-agent-substrate-101/actortemplate-and-the-golden-snapshot): Substrate snapshots each ActorTemplate once, and an actor created after that starts suspended from the snapshot, so its first call pays a restore. - [3.2 Actor and its seven states](https://aiengineeringfromscratch.com/manual-agent-substrate-101/actor-states): An actor is always in one of seven states, and that state decides what a request, a resume, and a suspend do. - [3.3 SuspendActor and ResumeActor](https://aiengineeringfromscratch.com/manual-agent-substrate-101/suspendactor-and-resumeactor): Substrate suspends an actor only when a caller asks, and on our test server a resume cost about 2 ms for each MiB that holds data. - [3.4 Snapshot fidelity, and where a snapshot lives](https://aiengineeringfromscratch.com/manual-agent-substrate-101/snapshot-fidelity-and-where-a-snapshot-lives): A snapshot keeps what its fidelity names, it is as large as the memory that holds data, and for five minutes it exists on one node only. - [3.5 CRASHED and RevertActor](https://aiengineeringfromscratch.com/manual-agent-substrate-101/crashed-and-revertactor): A crashed actor stays crashed until you call RevertActor, which returns it to its last completed snapshot and drops every call after it. - [3.6 Atespaces and names](https://aiengineeringfromscratch.com/manual-agent-substrate-101/atespaces): An atespace groups actors, templates, and tags in the Substrate API, and it is not a Kubernetes namespace, although the two often share a name. - [4.1 WorkerPool](https://aiengineeringfromscratch.com/manual-agent-substrate-101/workerpool): A WorkerPool is a set of worker pods that you size, and each pod reports a capacity taken from its own CPU and memory limits. - [4.2 Sandbox classes: gVisor and microVM](https://aiengineeringfromscratch.com/manual-agent-substrate-101/sandbox-classes): A pool runs one sandbox class, and an actor stays on the class of its first snapshot for the rest of its life. - [4.3 Placement: which worker gets the actor](https://aiengineeringfromscratch.com/manual-agent-substrate-101/placement): ate-api-server picks a worker at every resume: it filters the workers, takes two at random, and binds the actor to the less loaded one. - [4.4 Request parking](https://aiengineeringfromscratch.com/manual-agent-substrate-101/request-parking): When no worker has room, the router holds a request for up to 5 seconds and retries the resume before it answers 503. - [4.5 Sizing a pool](https://aiengineeringfromscratch.com/manual-agent-substrate-101/sizing-a-pool): The limits that you declare decide how many actors run at one time, and disk decides how many suspended actors you can keep. - [5.1 Client authentication](https://aiengineeringfromscratch.com/manual-agent-substrate-101/client-authentication): Substrate checks a credential at two places, the API and the router, and the default install gives every kubectl ate user one shared owner identity. - [5.2 Access policies per atespace](https://aiengineeringfromscratch.com/manual-agent-substrate-101/access-policies): An access policy grants one of three roles on one atespace, and the atespace is the smallest unit that Substrate can protect. - [5.3 Actor JWTs](https://aiengineeringfromscratch.com/manual-agent-substrate-101/actor-jwts): An actor does not store its own identity token: the egress gateway mints an actor JWT and puts it in a header that an egress rule names. - [6.1 The router and ingress](https://aiengineeringfromscratch.com/manual-agent-substrate-101/the-router-and-ingress): Every request to an actor passes through atenet-router, which demands a client certificate with an allowed SPIFFE ID and calls ResumeActor before it forwards… - [6.2 EgressPolicy and default deny](https://aiengineeringfromscratch.com/manual-agent-substrate-101/egresspolicy-and-default-deny): An actor with no EgressPolicy reaches nothing, and a policy opens named hosts and ports only, through three rule kinds and no CIDR rule. - [6.3 The DNS relay](https://aiengineeringfromscratch.com/manual-agent-substrate-101/the-dns-relay): The DNS relay answers only for names in the policy of the actor, so a denied host fails as NXDOMAIN before the actor opens a connection. - [6.4 TLS interception and the trust bundle](https://aiengineeringfromscratch.com/manual-agent-substrate-101/tls-interception): An https rule makes the gateway end the TLS session with a certificate that it mints, so the actor must trust the projected bundle, and tlsPassthrough leaves… - [6.5 Credential injection](https://aiengineeringfromscratch.com/manual-agent-substrate-101/credential-injection): The gateway replaces a placeholder header with a secret that the actor never holds, and an upstream that returns its request headers gives that secret back to… - [6.6 The dataplane choice: Envoy or agentgateway](https://aiengineeringfromscratch.com/manual-agent-substrate-101/the-dataplane-choice): agentgateway does the work of the Envoy dataplane in 38 MB and two containers, but it holds the interception CA key in the process that actors talk to. - [7.1 kagent 1.0 on Substrate](https://aiengineeringfromscratch.com/manual-agent-substrate-101/kagent-on-substrate): kagent makes each Session one actor, resumes it for every turn, and suspends it after, so a turn pays half a second beside the model and keeps only files. - [7.2 agentgateway with Substrate](https://aiengineeringfromscratch.com/manual-agent-substrate-101/agentgateway): agentgateway can be the dataplane of Substrate, the dataplane inside the kagent distribution, or a gateway behind an egress rule, and only the third selects… - [7.3 Substrate on GKE](https://aiengineeringfromscratch.com/manual-agent-substrate-101/substrate-on-gke): Agent Substrate on GKE is an installer and its documentation for a system that you operate in your own GKE Standard cluster, and Google does not run its… - [7.4 When to choose Substrate](https://aiengineeringfromscratch.com/manual-agent-substrate-101/when-to-choose-substrate): Choose Substrate when many CPU-only agents are idle most of the time and must keep state, and when you can operate Postgres and call suspend yourself. - [7.5 Agent Executor on Substrate](https://aiengineeringfromscratch.com/manual-agent-substrate-101/agent-executor): Agent Executor runs each task as one files-only actor on Substrate v1.0.0, never suspends it, and opens no egress, so you set the rule on the actor. - [8.1 Postgres and the object store](https://aiengineeringfromscratch.com/manual-agent-substrate-101/postgres-and-the-object-store): Every actor, template, and worker is a row in Postgres, every durable snapshot is an object in a bucket, and you must protect both to keep one actor. - [8.2 When a dependency is down](https://aiengineeringfromscratch.com/manual-agent-substrate-101/when-a-dependency-is-down): A request to a running actor needs Postgres and ate-api-server and never needs the Kubernetes API server, and each loss has its own error text. - [8.3 Symptom, cause, fix](https://aiengineeringfromscratch.com/manual-agent-substrate-101/symptom-cause-fix): Each Substrate failure that we recorded has a fixed text, and the text, the status code, and the delay together name one cause and one fix. - [8.4 Upgrade, and advice that no longer works](https://aiengineeringfromscratch.com/manual-agent-substrate-101/upgrade-and-stale-advice): No release before 1.0.0 upgrades in place, and most instructions written for those releases fail at v1.0.0 in a way that this section names. - [8.5 Limits at v1.0.0](https://aiengineeringfromscratch.com/manual-agent-substrate-101/limits-at-v1-0-0): At v1.0.0 Substrate runs, suspends, and resumes actors on request, and it leaves the suspend decision, pool size, failover, and key rotation to you. - [9.1 An idle suspender](https://aiengineeringfromscratch.com/manual-agent-substrate-101/an-idle-suspender): A small proxy that records the last request for each actor and calls SuspendActor after 30 quiet seconds ran three actors in room for two. - [9.2 A stateful agent actor](https://aiengineeringfromscratch.com/manual-agent-substrate-101/a-stateful-agent-actor): An agent that writes each turn to a durable directory keeps its conversation under both snapshot fidelities, and the fidelity decides what else it keeps and… - [9.3 A tool sandbox](https://aiengineeringfromscratch.com/manual-agent-substrate-101/a-tool-sandbox): An actor with one egress rule, two resource limits, and a revert after each task runs commands that you do not trust, and returns clean in half a second. - [9.4 A failure drill](https://aiengineeringfromscratch.com/manual-agent-substrate-101/a-failure-drill): One script causes six failures on a test cluster and prints the symptom, the state, the fix, and the recovery time for each. - [R.1 API methods](https://aiengineeringfromscratch.com/manual-agent-substrate-101/ref-api-methods): The Substrate API at v1.0.0 is two gRPC services with 50 methods, and four plugin services that a third party can implement. - [R.2 Objects and fields](https://aiengineeringfromscratch.com/manual-agent-substrate-101/ref-objects-and-fields): Three kinds are Kubernetes objects that describe worker capacity, and every other Substrate object is a record that only the Substrate API returns. - [R.3 States](https://aiengineeringfromscratch.com/manual-agent-substrate-101/ref-states): An actor has seven states, a snapshot has two storage states, and a worker has three, and each one changes what a request returns. - [R.4 kubectl ate commands](https://aiengineeringfromscratch.com/manual-agent-substrate-101/ref-kubectl-ate): The kubectl ate plugin at v1.0.0 has 11 verbs over seven resources, and most commands are one call to the Substrate API. - [R.5 Flags and preview features](https://aiengineeringfromscratch.com/manual-agent-substrate-101/ref-flags-and-gates): The flags that change what an actor does are few: two snapshot timers on atelet, the parking budget on the router, and the dataplane and image choice in the… - [R.6 Errors](https://aiengineeringfromscratch.com/manual-agent-substrate-101/ref-errors): Every error text that our runs recorded, in alphabetical order, with where it appears, what it means, and the section that explains it. - [R.7 Glossary](https://aiengineeringfromscratch.com/manual-agent-substrate-101/ref-glossary): Each term below has one meaning across the manual, and the last column names the section that explains it. - [R.8 Sources](https://aiengineeringfromscratch.com/manual-agent-substrate-101/ref-sources): The manual ranks its sources by authority, with our own recorded runs first, and this page lists each kind and what the sections take from it. - [R.9 Index of figures](https://aiengineeringfromscratch.com/manual-agent-substrate-101/ref-figure-index): Every figure of this manual, in order, by the one claim that its caption makes. - [R.10 How this manual was made](https://aiengineeringfromscratch.com/manual-agent-substrate-101/ref-how-this-manual-was-made): This page records the version, the machines, the lab method, and the capture kit behind every fact in the manual, and the runs that come next. ### [Docker Sandboxes and Docker Agent 101](https://aiengineeringfromscratch.com/manual-docker-sandboxes-101): Isolated microVMs for coding agents, and the agent runtime that runs inside them, command by command How to run an agent you do not trust on files you do. Every listing in this manual comes from a recorded run of sbx and docker-agent on one Mac. Pinned to Docker Sandboxes (sbx) and Docker Agent (docker-agent) sbx 0.47.0, docker-agent 1.149.0. - [How to read this manual](https://aiengineeringfromscratch.com/manual-docker-sandboxes-101/front): Every command output in this manual comes from one recorded run of sbx and docker-agent on one Mac, and every rule traces to a ranked source. - [1.1 sbx and docker-agent](https://aiengineeringfromscratch.com/manual-docker-sandboxes-101/sbx-and-docker-agent): Each binary owns one thing: sbx owns the microVM, its proxy, and its secret store, and docker-agent owns the loop between a model, tools, and sub-agents. - [1.2 docker-agent run --sandbox, one run end to end](https://aiengineeringfromscratch.com/manual-docker-sandboxes-101/docker-agent-run-sandbox-end-to-end): One recorded docker-agent run --sandbox shows the kit, the sandbox, and the allowlist, and one sbx exec into the same VM shows the model call through the proxy. - [2.1 sbx run, sbx create, sbx stop, and sbx rm](https://aiengineeringfromscratch.com/manual-docker-sandboxes-101/sbx-run-create-stop-and-rm): sbx run creates a sandbox when none exists and attaches to it, sbx create only creates, and stop, rm, and prune end a sandbox in three different ways. - [2.2 sbx exec, sbx cp, and sbx ports](https://aiengineeringfromscratch.com/manual-docker-sandboxes-101/sbx-exec-cp-and-ports): Three verbs reach into a sandbox: exec runs a command and starts a stopped sandbox, cp moves files across the boundary, and ports binds tcp4 unless told… - [2.3 sbx template save and sbx template load](https://aiengineeringfromscratch.com/manual-docker-sandboxes-101/sbx-template-save-and-load): A template is a snapshot in the sandbox runtime's image store, reused with --pull never -t TAG, exported as a tar, and loaded on another host. - [2.4 sandboxd, sbx diagnose, and sbx reset](https://aiengineeringfromscratch.com/manual-docker-sandboxes-101/sandboxd-diagnose-and-reset): One daemon owns every sandbox, its socket and log live under one state directory, and two commands check that daemon and wipe it. - [2.5 sbx settings list](https://aiengineeringfromscratch.com/manual-docker-sandboxes-101/sbx-settings-list): Every setting has a default, a source, a user override, and a restart flag, some have an environment alias, and sbx settings list --json is the only complete… - [3.1 sbx diagnose and the microVM boundary](https://aiengineeringfromscratch.com/manual-docker-sandboxes-101/sbx-diagnose-and-the-microvm-boundary): The agent runs as a container inside a guest kernel on the host hypervisor, with a private Docker Engine, and nothing it does reaches the host daemon. - [3.2 --clone and /run/sandbox/source](https://aiengineeringfromscratch.com/manual-docker-sandboxes-101/clone-and-run-sandbox-source): Bind mode gives the agent your files, :ro and mountless modes give it less, and --clone gives it a private clone whose commits come back through a git remote. - [3.3 sbx policy init, allow network, deny network, and check network](https://aiengineeringfromscratch.com/manual-docker-sandboxes-101/sbx-policy-init-allow-deny-and-check-network): A global preset plus allow and deny rules in two scopes decide every connection, deny wins, and check network asks the same authorizer without sending anything. - [3.4 sbx policy log and the proxy](https://aiengineeringfromscratch.com/manual-docker-sandboxes-101/sbx-policy-log-and-the-proxy): Every connection leaves through a host proxy, which answers a blocked HTTPS request with its own certificate and writes one policy log row per host with the… - [3.5 sbx secret set, sbx secret import, and sbx secret set-custom](https://aiengineeringfromscratch.com/manual-docker-sandboxes-101/sbx-secret-set-import-and-set-custom): A secret never enters the VM: the agent sees a sentinel, the host keychain holds the value, and the proxy swaps it into requests to the bound host. - [3.6 sbx mcp add, sbx mcp load, and --static-mcp](https://aiengineeringfromscratch.com/manual-docker-sandboxes-101/sbx-mcp-add-load-and-static-mcp): MCP servers are registered on the host, served to the sandbox through one gateway endpoint, and either fixed at creation or loaded live with a… - [4.1 `# syntax=docker/sandbox-kit:3` and kit.yaml](https://aiengineeringfromscratch.com/manual-docker-sandboxes-101/syntax-docker-sandbox-kit-3-and-kit-yaml): A v3 kit is an ordinary OCI image whose manifest annotation carries a strict YAML descriptor, which sbx resolves when it creates the sandbox. - [4.2 `com.docker.sandbox/*` capabilities](https://aiengineeringfromscratch.com/manual-docker-sandboxes-101/com-docker-sandbox-capabilities): A kit grants itself nothing: each capability is typed and versioned, the resolver unions one workload with its mixins, and any widening on update stops for… - [4.3 `sbx kit pack`, `sbx kit push --sign`, and `sbx kit verify`](https://aiengineeringfromscratch.com/manual-docker-sandboxes-101/sbx-kit-pack-push-sign-and-verify): The sbx kit commands package, sign, push, verify, and show provenance for v1 and v2 artifacts, and kit add appends a mixin to a running sandbox. - [4.4 sbxenv.yaml and `sbx env plan`](https://aiengineeringfromscratch.com/manual-docker-sandboxes-101/sbxenv-yaml-and-sbx-env-plan): An environment file declares the agent, kits, workspace, secrets, ports, MCP servers, and host commands, and sbx env plan prints every change before create or… - [4.5 `sbx skills add` and `skills: true`](https://aiengineeringfromscratch.com/manual-docker-sandboxes-101/sbx-skills-add-and-skills-true): One shared skills store serves every sandbox of a supported agent read-only by default, and docker-agent reads its own skill directories, not the store, with… - [5.1 docker-agent run, new, and doctor](https://aiengineeringfromscratch.com/manual-docker-sandboxes-101/docker-agent-run-new-and-doctor): docker-agent run loads an agent file and drives the loop with or without a terminal, doctor says which model auto would pick, and new needs a terminal. - [5.2 agents, models, and providers](https://aiengineeringfromscratch.com/manual-docker-sandboxes-101/agents-models-and-providers): agents is the only required block, a model reference is provider/model or a name from models, and providers sets a reusable endpoint such as Docker Model… - [5.3 toolsets and mcps](https://aiengineeringfromscratch.com/manual-docker-sandboxes-101/toolsets-and-mcps): A toolset is one type from a fixed list of 27 that gives an agent tools, and mcp reaches a server by Docker reference, command, or URL. - [5.4 sub_agents, transfer_task, and background_agents](https://aiengineeringfromscratch.com/manual-docker-sandboxes-101/sub-agents-transfer-task-and-background-agents): transfer_task runs a sub-agent in a clean sub-session and returns its answer, handoff moves the whole session to another agent, and background agents need… - [5.5 permissions, --safety, and hooks](https://aiengineeringfromscratch.com/manual-docker-sandboxes-101/permissions-safety-and-hooks): Deny, allow, and ask patterns, then a safety mode, then hooks decide whether a tool call runs, and the docs say none of them is a security boundary. - [5.6 session.db, sessions diff, and eval](https://aiengineeringfromscratch.com/manual-docker-sandboxes-101/session-db-sessions-diff-and-eval): Every run is rows in one SQLite file, a cassette replays its model calls, sessions diff finds the first different tool call, and eval scores saved sessions in… - [6.1 serve api and serve chat](https://aiengineeringfromscratch.com/manual-docker-sandboxes-101/serve-api-and-serve-chat): serve api is the native control plane, with sessions and an SSE run stream on port 8080, and serve chat is the OpenAI-compatible subset on port 8083. - [6.2 serve mcp and serve acp](https://aiengineeringfromscratch.com/manual-docker-sandboxes-101/serve-mcp-and-serve-acp): serve mcp exposes each agent as one MCP tool over stdio or streaming HTTP on port 8081, and serve acp speaks the Agent Client Protocol to an editor over stdio. - [6.3 serve a2a](https://aiengineeringfromscratch.com/manual-docker-sandboxes-101/serve-a2a): serve a2a publishes an A2A 1.0 agent card on port 8082 and answers SendMessage with a completed task, and its card breaks three REQUIRED rules of A2A 1.0.1. - [6.4 share push and share pull](https://aiengineeringfromscratch.com/manual-docker-sandboxes-101/share-push-and-share-pull): share push stores an agent file as an OCI artifact with docker-agent annotations, and share pull or run with the same reference reads it back from any registry. - [6.5 DMR, Compose models, and the docker/mcp-gateway service](https://aiengineeringfromscratch.com/manual-docker-sandboxes-101/dmr-compose-models-and-the-mcp-gateway-service): A local model is an unauthenticated OpenAI-compatible endpoint on port 12434, Compose binds it to a service as two variables, and four things named gateway… - [7.1 sbx --cloud run, sbx move, and sbx ttl](https://aiengineeringfromscratch.com/manual-docker-sandboxes-101/sbx-cloud-run-move-and-ttl): A cloud sandbox is the same microVM on Docker's compute, billed by the second in five shapes, with a 24 hour TTL ceiling and its own secrets and policies. - [7.2 sbx policy ls --source org, --profile, and the audit JSONL](https://aiengineeringfromscratch.com/manual-docker-sandboxes-101/org-policies-profiles-and-the-audit-log): An organization writes policies in Docker Home, the daemon pulls them within five minutes, local rules can only narrow, and every decision is written to a… - [7.3 From docker sandbox and cagent to sbx and docker-agent](https://aiengineeringfromscratch.com/manual-docker-sandboxes-101/from-docker-sandbox-and-cagent-to-sbx-and-docker-agent): Two renames and one CLI restructure changed every command in the 2025 and early 2026 material, and this section maps each old line to its current form. - [7.4 kit-tck, sbx diagnose, and the claims this manual checked](https://aiengineeringfromscratch.com/manual-docker-sandboxes-101/kit-tck-diagnose-and-the-claims-this-manual-checked): Every claim this manual repeats from Docker's pages or the community was checked against a capture or marked unverified, and this section is the ledger. - [R.1 sbx commands](https://aiengineeringfromscratch.com/manual-docker-sandboxes-101/ref-sbx-commands): Every verb of sbx 0.47.0 in the four groups of sbx --help, with its purpose, the flags that matter, its scope, and the section that explains it. - [R.2 docker-agent commands](https://aiengineeringfromscratch.com/manual-docker-sandboxes-101/ref-docker-agent-commands): Every command of docker-agent 1.149.0 in the four groups of its root help, every global flag, and every serve subcommand with its default listen address. - [R.3 Settings keys, environment variables, and paths](https://aiengineeringfromscratch.com/manual-docker-sandboxes-101/ref-settings-keys-environment-variables-and-paths): Every key that sbx settings list printed on 2026-10-08, every environment variable both tools read, and every path they use on macOS, each with its source. - [R.4 Agent file keys](https://aiengineeringfromscratch.com/manual-docker-sandboxes-101/ref-agent-file-keys): Every key of the agent file at schema version 16, grouped by block, with its type, default, requirement, and meaning from agent-schema.json at v1.149.0. - [R.5 Toolsets](https://aiengineeringfromscratch.com/manual-docker-sandboxes-101/ref-toolsets): The 27 toolset types of docker-agent 1.149.0, each with the tools it exposes, its options, and what it needs outside the agent file. - [R.6 Providers and models](https://aiengineeringfromscratch.com/manual-docker-sandboxes-101/ref-providers-and-models): Every provider id docker-agent 1.149.0 knows, the credential it reads, the provider/model reference form, the DMR endpoint order, the auto rule, and the keys… - [R.7 Sources and the conflicts register](https://aiengineeringfromscratch.com/manual-docker-sandboxes-101/ref-sources-and-the-conflicts-register): Two help trees, one schema, one kit specification, the vendored docs, the release notes, and one capture kit, with a ruling for every conflict a section… - [R.8 Glossary and index of figures](https://aiengineeringfromscratch.com/manual-docker-sandboxes-101/ref-glossary-and-index-of-figures): Each term below has one meaning across the manual and names the section that defines it, and the index lists every figure by the claim it makes. ### [LangChain 101](https://aiengineeringfromscratch.com/manual-langchain-101): Build, run, persist, and debug agents with LangChain 1.5, LangGraph 1.2, and Deep Agents 0.7, with a recorded answer for each decision How the LangChain Python stack turns a model, tools, and a prompt into an agent, and when you need it at all. A task suite with state checkers sets the plain loop, create_agent, LangGraph, and Deep Agents side by side on local and Claude models. Traces of real runs show the runtime inside, and a FastAPI service with Postgres and approvals runs it in production. Every listing comes from a capture of a real run with langchain 1.5.0, langchain-core 1.8.0, langgraph 1.2.22, and deepagents 0.7.38. Every measured number comes from a recorded run on a real model. Pinned to LangChain (Python): langchain, langchain-core, langgraph, deepagents, langsmith 1.5.0. - [How to read this manual](https://aiengineeringfromscratch.com/manual-langchain-101/front): This manual explains the LangChain Python stack at one pin, and every listing in it comes from a capture of a real run that you can check yourself. - [1.1 LangChain, LangGraph, LangSmith, and Deep Agents](https://aiengineeringfromscratch.com/manual-langchain-101/langchain-langgraph-langsmith-and-deep-agents): LangChain builds the agent, LangGraph runs it as a graph with checkpoints, LangSmith records it, and Deep Agents adds a harness, each in packages with their… - [1.2 Do you need LangChain? Four harnesses on one task suite](https://aiengineeringfromscratch.com/manual-langchain-101/do-you-need-langchain): Three harnesses gave identical runs on 60 of 60 local tasks, Claude passed every task it ran, and only the deep agent on small local models lost tasks. - [1.3 One create_agent run, from invoke to the last checkpoint](https://aiengineeringfromscratch.com/manual-langchain-101/one-create-agent-run): One invoke of a create_agent agent runs four graph steps, makes two model calls and one tool call, and with a checkpointer saves five checkpoints. - [2.1 The superstep loop: plan, execute, update](https://aiengineeringfromscratch.com/manual-langchain-101/the-superstep-loop-plan-execute-update): Treat each superstep as one transaction: parallel writes become visible together, in task-path order, so never let your state depend on which node finished… - [2.2 Channels and colliding writes](https://aiengineeringfromscratch.com/manual-langchain-101/channels-and-colliding-writes): Give every key that two nodes write in one superstep a reducer before you deploy: a conflict breaks every later read of the thread, and only a reducer repairs… - [2.3 The checkpoint write path: put, put_writes, and durability](https://aiengineeringfromscratch.com/manual-langchain-101/the-checkpoint-write-path-and-durability): A crash right after a node returned reran it in 97 of 100 sync and 95 of 100 async trials, so key node side effects on the task namespace. - [2.4 interrupt() and Command(resume): the resume index and interrupt ids](https://aiengineeringfromscratch.com/manual-langchain-101/interrupt-and-resume-in-the-code): A resume reruns the node from its first line, model calls too, and matches answers by position, so keep model calls out of interrupting nodes and resume by id… - [2.5 Stream modes at their source, and the v3 projection buffer](https://aiengineeringfromscratch.com/manual-langchain-101/where-each-stream-mode-comes-from): Read one v3 projection per message, or the raw events, because a loop that reads reasoning first showed a reasoning model's answer 8.8 to 9.0 s late. - [2.6 Checkpoint size, DeltaChannel, and the cost of a superstep](https://aiengineeringfromscratch.com/manual-langchain-101/checkpoint-growth-and-the-cost-of-a-superstep): The framework took under half a percent of a real agent's time, while its checkpoints grew to 10 MB in 100 tool calls, so spend your effort on bytes. - [3.1 Install and the package map](https://aiengineeringfromscratch.com/manual-langchain-101/install-and-the-package-map): Install langchain 1.5.0 on Python 3.11 or later from a lockfile, because the stack is many packages with separate versions, and a minor release can change… - [3.2 init_chat_model and model profiles](https://aiengineeringfromscratch.com/manual-langchain-101/init-chat-model-and-model-profiles): init_chat_model turns a provider:model string into a chat model of the provider package, and that package, not LangChain, decides how often a failed call is… - [3.3 Messages and content blocks](https://aiengineeringfromscratch.com/manual-langchain-101/messages-and-content-blocks): Every model input and output is a list of four message types, and content_blocks reads any provider's content as the same typed blocks. - [3.4 Tools, ToolRuntime, and tool errors](https://aiengineeringfromscratch.com/manual-langchain-101/tools-toolruntime-and-tool-errors): A tool is a typed function with a schema, ToolRuntime hides the run from the model, and by default only bad arguments become an error message. - [3.5 The system prompt](https://aiengineeringfromscratch.com/manual-langchain-101/the-system-prompt): create_agent puts the system prompt first in every model request and never stores it in the state, so a new prompt applies to the next call of every thread. - [4.1 create_agent and the graph it builds](https://aiengineeringfromscratch.com/manual-langchain-101/create-agent-and-the-graph-it-builds): create_agent compiles a LangGraph graph with a model node, a tools node when tools exist, and one node for each middleware hook, with a recursion limit of 9999. - [4.2 Structured output: AutoStrategy, ProviderStrategy, ToolStrategy](https://aiengineeringfromscratch.com/manual-langchain-101/structured-output-autostrategy-providerstrategy-toolstrategy): ToolStrategy asks for a tool call and retries without a limit, ProviderStrategy asks the provider for JSON and never retries, and AutoStrategy picks one… - [4.3 Structured output: which strategy, on which provider](https://aiengineeringfromscratch.com/manual-langchain-101/structured-output-which-strategy-on-which-provider): On Qwen3 4B, ToolStrategy gave no object in 39 of 39 tasks and ProviderStrategy raised in 10 of 10, while an extraction call matched the best score on each… - [4.4 Many tools and the tool selector](https://aiengineeringfromscratch.com/manual-langchain-101/many-tools-and-the-tool-selector): Claude Haiku 5.5 passed 10 of 10 at 100 tools, LLMToolSelectorMiddleware doubled its calls and cost, and the selector cut Qwen3 4B to 1 of 10 at every size. - [4.5 Middleware: hooks and their order](https://aiengineeringfromscratch.com/manual-langchain-101/middleware-hooks-and-their-order): A middleware has six hooks, the four node hooks become graph nodes, and before_* hooks run in list order while after_* hooks run in reverse. - [4.6 The built-in middleware](https://aiengineeringfromscratch.com/manual-langchain-101/the-built-in-middleware): langchain 1.5.0 has 19 middleware classes, each built on one or two of the six hooks, and the documentation lists three more that come from Deep Agents. - [4.7 Retries, backup models, rate limits, and caching](https://aiengineeringfromscratch.com/manual-langchain-101/retries-backup-models-rate-limits-and-caching): Retry layers multiply, ToolRetryMiddleware repeats a tool after a timeout whose request already reached the service, and a backup model takes any exception. - [4.8 Guardrails, PII, and the decision middleware (beta)](https://aiengineeringfromscratch.com/manual-langchain-101/guardrails-pii-and-the-decision-middleware-beta): PIIMiddleware rewrites or blocks one kind of personal data by a fixed rule, and two beta middlewares ask a decision model to pick a model or block a call. - [4.9 A SQL agent over a local SQLite database](https://aiengineeringfromscratch.com/manual-langchain-101/a-sql-agent-over-a-local-sqlite-database): A SQL agent cannot change data alone when its read connection refuses writes and each write needs approval, but it can show every row it reads. - [5.1 Streaming: v1, v2, stream_events v3, and the tools mode](https://aiengineeringfromscratch.com/manual-langchain-101/streaming-v1-v2-stream-events-v3-and-the-tools-mode): One agent run can stream as v1 chunks whose shape follows your options, as v2 StreamPart dicts with one shape, or as v3 events, which are beta. - [5.2 Checkpointers and threads: short-term memory](https://aiengineeringfromscratch.com/manual-langchain-101/checkpointers-and-threads): A checkpointer saves the state of a thread after each step, so the next turn on the same thread_id starts from the last checkpoint, also after a restart. - [5.3 Durability modes, and a crash between two steps](https://aiengineeringfromscratch.com/manual-langchain-101/durability-modes-and-a-crash-between-two-steps): No durability mode protects a task that just returned, and a model can ask for one charge twice, so key each side effect and check your records first. - [5.4 Stores and long-term memory, and namespace isolation](https://aiengineeringfromscratch.com/manual-langchain-101/stores-and-long-term-memory): A store keeps JSON items under namespaces that every thread can read, and it isolates one user from another only as well as the namespace prefix that your… - [5.5 Context engineering and summarization](https://aiengineeringfromscratch.com/manual-langchain-101/context-engineering-and-summarization): A thread grows on every turn, so each model call gets longer and each checkpoint larger, until you trim or summarize the messages and store them as deltas. - [5.6 Serialization of state, and what does not round-trip](https://aiengineeringfromscratch.com/manual-langchain-101/serialization-of-state-and-what-does-not-round-trip): A checkpointer stores state with msgpack, so most Python values come back as they went in, and tuples, sets of tuples, dict subclasses, and time zones come… - [5.7 An assistant with memory and approvals that survives a restart](https://aiengineeringfromscratch.com/manual-langchain-101/an-assistant-with-memory-and-approvals-that-survives-a-restart): An assistant that must survive a restart needs a durable checkpointer, a store, per-call review, a summary trigger, and an idempotency key, and a crash still… - [6.1 StateGraph, state, and reducers](https://aiengineeringfromscratch.com/manual-langchain-101/stategraph-state-and-reducers): A StateGraph node returns a partial update, and each state key merges that update with its reducer, or replaces the old value when the key has no reducer. - [6.2 Edges, Send, and Command](https://aiengineeringfromscratch.com/manual-langchain-101/edges-send-and-command): A plain edge always runs, a conditional edge picks from the state, Send starts one task per item, and Command updates and routes in one return. - [6.3 The functional API: @entrypoint and @task](https://aiengineeringfromscratch.com/manual-langchain-101/the-functional-api-entrypoint-and-task): An @entrypoint function runs again from its top on every resume, and each @task that finished before the pause returns its saved result instead of running… - [6.4 interrupt and resume](https://aiengineeringfromscratch.com/manual-langchain-101/interrupt-and-resume): interrupt saves the run and returns the question to the caller, and Command(resume=...) runs the paused node again from its first line with the answer. - [6.5 Human in the loop: HumanInTheLoopMiddleware, batched and per call](https://aiengineeringfromscratch.com/manual-langchain-101/human-in-the-loop-batched-and-per-call): HumanInTheLoopMiddleware pauses tool calls for review, and per_call mode is the safe choice, because batched mode lets an edit switch tools and a jumping… - [6.6 Time travel: replay, update_state, and forks](https://aiengineeringfromscratch.com/manual-langchain-101/time-travel-replay-update-state-and-forks): A replay from a past checkpoint runs every later node again, and update_state adds a new branch next to the old one, so neither reads saved results or erases… - [6.7 Subgraphs and multi-agent patterns](https://aiengineeringfromscratch.com/manual-langchain-101/subgraphs-and-multi-agent-patterns): A subgraph shares the keys of its parent and runs in its own namespace, and its whole output passes through the parent reducers, which can add old entries… - [6.8 Error handlers, node timeouts, and the recursion limit](https://aiengineeringfromscratch.com/manual-langchain-101/error-handlers-node-timeouts-and-the-recursion-limit): A failed node attempt goes to its RetryPolicy and then to its error_handler, a timeout counts as one failure, and the recursion limit stops an endless run. - [7.1 Embeddings, splitters, vector stores, and retrievers](https://aiengineeringfromscratch.com/manual-langchain-101/embeddings-splitters-vector-stores-and-retrievers): The retrieval interfaces live in langchain-core, the splitters in langchain-text-splitters, and each store in a partner package, and an agent reaches a… - [7.2 A retrieval agent over a local corpus](https://aiengineeringfromscratch.com/manual-langchain-101/a-retrieval-agent-over-a-local-corpus): A retrieval agent has two parts that fail apart: the retriever finds the right passage or not, and the model calls the retriever or not, so test each one. - [7.3 MCP with langchain.mcp](https://aiengineeringfromscratch.com/manual-langchain-101/mcp-with-langchain-mcp): MCPAdapter turns the tools of an MCP server into LangChain tools, refuses a string that is not a URL, and lets a server crash end the run. - [7.4 Deep Agents: when the harness helps](https://aiengineeringfromscratch.com/manual-langchain-101/deep-agents-0-7): A deep agent matched the plain loop on Claude at 1.16 to 1.24 times the dollars, and lost on small local models, mostly to its in-state default filesystem. - [7.5 A deep agent with a subagent and files](https://aiengineeringfromscratch.com/manual-langchain-101/a-deep-agent-with-a-subagent-and-files): A deep agent on a local model plans, writes, and delegates a review in seven model calls, and its first call sends 3,651 prompt tokens for a short task. - [7.6 LangSmith tracing](https://aiengineeringfromscratch.com/manual-langchain-101/langsmith-tracing): On the hosted LangSmith API, tracing added about 6 ms to a real agent run, and enabled="local" still sent every LangChain run there. - [7.7 Evaluation with LangSmith](https://aiengineeringfromscratch.com/manual-langchain-101/evaluation-with-langsmith): evaluate from langsmith 0.14.17 builds an experiment from a dataset and your evaluators, and with upload_results=False it still sends every agent run. - [8.1 Agent Server: langgraph dev, up, and deploy](https://aiengineeringfromscratch.com/manual-langchain-101/agent-server-langgraph-dev-up-and-deploy): Under langgraph dev, the server runs one job at a time and adds 0.6 to 1 s to each run, and langgraph up will not start without a key. - [8.2 Agent Chat UI in front of langgraph dev](https://aiengineeringfromscratch.com/manual-langchain-101/agent-chat-ui-in-front-of-langgraph-dev): Agent Chat UI answers batched approvals only, and a typed message closes a pending approval, so the model said the tool ran in 2 of 2 trials. - [8.3 Cost: the framework against a plain SDK loop](https://aiengineeringfromscratch.com/manual-langchain-101/cost-the-framework-against-a-plain-sdk-loop): create_agent adds about 5 ms per model call and no tokens to a plain loop, while Deep Agents, long plain threads, and a failing trace endpoint cost far more. - [8.4 Security: deserialization, store isolation, approvals, and MCP subprocesses](https://aiengineeringfromscratch.com/manual-langchain-101/security-deserialization-store-isolation-approvals-and-mcp-subprocesses): At the pin, the fixed advisories hold, and the open risks sit in defaults you must change: msgpack checkpoints, store prefixes, dotfile rules, batched… - [8.5 Migration from 0.x, and stale advice](https://aiengineeringfromscratch.com/manual-langchain-101/migration-from-0-x-and-stale-advice): Most 0.x code moved to langchain-classic or changed its name, and old advice survives in tutorials, notebooks, and some docs pages, so check each import… - [8.6 Symptom, cause, fix](https://aiengineeringfromscratch.com/manual-langchain-101/symptom-cause-fix): Each error message in this manual names its cause once you know which layer raised it, and a few failures raise nothing, so look those up by their symptom. - [8.7 A failure drill](https://aiengineeringfromscratch.com/manual-langchain-101/a-failure-drill): One script causes seven failures with Qwen3 4B on a local Ollama and prints the symptom, the state, the fix, and the time for each, in about 100 seconds. - [8.8 Limits at the pin, and what comes in the next edition](https://aiengineeringfromscratch.com/manual-langchain-101/limits-at-the-pin-and-what-comes-in-the-next-edition): This edition tested the stack offline, on two machines, and on one free LangSmith account, without an Agent Server license, so the items below have no… - [9.1 The run endpoint: StreamingResponse and one task per run](https://aiengineeringfromscratch.com/manual-langchain-101/the-run-endpoint-and-its-stream): Start each run as its own asyncio task that writes events to a queue, so the HTTP response only reads, and a client that leaves cannot cancel the run. - [9.2 AsyncPostgresSaver, AsyncPostgresStore, and the owner check](https://aiengineeringfromscratch.com/manual-langchain-101/postgres-checkpointer-store-and-owner-check): Neither the checkpointer nor the store knows users, so check thread ownership in your route and take the user id from the run context, never from the model. - [9.3 HumanInTheLoopMiddleware and the idempotency key](https://aiengineeringfromscratch.com/manual-langchain-101/approvals-and-the-idempotency-key): After a crash that follows the side effect, the approval was pending again in 20 of 20 trials, so only a key at the tool stops a second refund. - [9.4 OpenTelemetry spans, with LangSmith off](https://aiengineeringfromscratch.com/manual-langchain-101/opentelemetry-spans-with-langsmith-off): Trace model and tool calls with your own OpenTelemetry spans, count tokens from provider usage, and confirm that LangSmith receives nothing unless its flag is… - [9.5 ToolRetryMiddleware, ModelFallbackMiddleware, and shutdown](https://aiengineeringfromscratch.com/manual-langchain-101/timeouts-retries-backup-model-and-shutdown): Time-limit every tool, retry only the tools that are safe to repeat, and expect the model to decide what the customer hears about a fault. - [9.6 Evals in CI: tool calls, rows, and state](https://aiengineeringfromscratch.com/manual-langchain-101/evals-that-check-state): Assert on tool calls, database rows, and thread state, and run the suite on each model you deploy, because three real models failed different cases of one… - [9.7 Workers, the advisory lock, and the cost of a conversation](https://aiengineeringfromscratch.com/manual-langchain-101/workers-the-advisory-lock-and-cost): With a real model the ceiling is the model server, so add workers for availability, take the thread lock in Postgres, and price a conversation from measured… - [R.1 create_agent parameters](https://aiengineeringfromscratch.com/manual-langchain-101/ref-create-agent-parameters): create_agent in langchain 1.5.0 takes a model, tools, and 13 keyword parameters, and returns a compiled LangGraph graph with a recursion limit of 9999. - [R.2 Middleware hooks and classes](https://aiengineeringfromscratch.com/manual-langchain-101/ref-middleware-hooks-and-classes): AgentMiddleware has six hooks with a sync and an async form each, and langchain 1.5.0 builds 19 middleware classes on them. - [R.3 Stream modes and event types](https://aiengineeringfromscratch.com/manual-langchain-101/ref-stream-modes-and-event-types): A LangGraph run streams in eight modes, in two chunk versions, and through one beta event protocol, and each one has a fixed shape at langgraph 1.2.22. - [R.4 Checkpointer and store API](https://aiengineeringfromscratch.com/manual-langchain-101/ref-checkpointer-and-store-api): A checkpointer saves one thread step by step under thread_id, a store saves JSON items by namespace across threads, and each has three backends at the pin. - [R.5 Environment variables](https://aiengineeringfromscratch.com/manual-langchain-101/ref-environment-variables): This page lists the 23 environment variables that the stack or its docs name at the pin, with the file and line that reads each one. - [R.6 Errors](https://aiengineeringfromscratch.com/manual-langchain-101/ref-errors): Each error and warning in this manual has one class, one package that raises it, and one line at the pin, and the text below is copied from a capture. - [R.7 Glossary](https://aiengineeringfromscratch.com/manual-langchain-101/ref-glossary): Each term below has one meaning in this manual, and a term that two sections use in two senses lists both, each with its own context. - [R.8 Sources and conflicts](https://aiengineeringfromscratch.com/manual-langchain-101/ref-sources-and-conflicts): The manual ranks the code at the tags above the documentation, uses its own recorded runs for every listing and measured number, and records 32 conflicts… - [R.9 Index of figures](https://aiengineeringfromscratch.com/manual-langchain-101/ref-figure-index): Every figure of this manual, in order, by the one claim that its caption makes. - [R.10 How this manual was made](https://aiengineeringfromscratch.com/manual-langchain-101/ref-how-this-manual-was-made): This page records the pin, the two machines, the lab method, each experiment with its machine and its count, and what the lab folder holds. - [R.11 The bench method](https://aiengineeringfromscratch.com/manual-langchain-101/ref-the-bench-method): The bench ran 99 tasks with state checkers on five local and two Claude models, one run per task, with Wilson intervals and a list of rows to skip. ### [Miles 101](https://aiengineeringfromscratch.com/manual-miles-101): Reinforcement learning on language models with Miles, from one GPU to a run you can trust How to run GRPO with Miles on one GPU, choose a model that fits, and check that the run is correct. Every measured line comes from recorded runs on a DGX Spark. Pinned to Miles radixark/miles:latest, Miles main of 2026-10-15. - [How to read this manual](https://aiengineeringfromscratch.com/manual-miles-101/front): This manual gets a GRPO run going on one GPU first, then shows how to size it, check it, and fix it. - [1.1 Run GRPO on one GPU with the radixark/miles image](https://aiengineeringfromscratch.com/manual-miles-101/run-grpo-on-one-gpu): One container, one small model, and one launcher script give you a logged GRPO step on a single GPU in about ten minutes. - [1.2 Add a watchdog before you leave a run alone](https://aiengineeringfromscratch.com/manual-miles-101/add-a-watchdog): When the rollout engine dies, a Miles run does not fail, so a small script must stop it for you. - [1.3 Read your first ten steps](https://aiengineeringfromscratch.com/manual-miles-101/read-your-first-ten-steps): Ten steps are enough to tell a healthy GRPO run from a broken one, if you read five numbers and not only the reward. - [2.1 Pick a model size for one GPU](https://aiengineeringfromscratch.com/manual-miles-101/pick-a-model-size): The largest model you can train on one GPU is the one whose trainer copy and engine copy fit together. - [2.2 Choose what to offload between phases](https://aiengineeringfromscratch.com/manual-miles-101/choose-what-to-offload): On one GPU the trainer and the engine take turns, and the offload settings decide what each side gives back. - [2.3 Stop Ray from killing the job on unified memory](https://aiengineeringfromscratch.com/manual-miles-101/stop-ray-killing-the-job): On a GB10, the GPU allocations and the host share one memory, so a Ray memory kill there means the machine really was close to full. - [2.4 Size the weight update](https://aiengineeringfromscratch.com/manual-miles-101/size-the-weight-update): On one GPU the weight update is a small fixed cost, so it is not the step to tune first. - [3.1 Train math reasoning on GSM8K](https://aiengineeringfromscratch.com/manual-miles-101/train-math-on-gsm8k): GSM8K with a binary reward is the smallest recipe that shows GRPO learning, and its group size decides how much each step teaches. - [3.2 Train with the DAPO filter](https://aiengineeringfromscratch.com/manual-miles-101/train-with-the-dapo-filter): The DAPO filter drops groups where every answer scored the same, so each step trains only on groups that teach something. - [3.3 Train an agent with tool calls and many turns](https://aiengineeringfromscratch.com/manual-miles-101/train-an-agent): An agent rollout has many turns and tool calls, and Miles runs them through a generate function that you choose by name. - [3.4 Train a mixture-of-experts model with routing replay](https://aiengineeringfromscratch.com/manual-miles-101/train-a-moe-model): Routing replay makes the trainer use the same experts that the engine chose, so the two sides agree on which weights each token used. - [3.5 Write a custom reward function](https://aiengineeringfromscratch.com/manual-miles-101/write-a-custom-reward): A custom reward plugs in with one flag, and a reward with fractions needs a check on how the advantage is centered. - [4.1 Run rollout and training at the same time](https://aiengineeringfromscratch.com/manual-miles-101/run-rollout-and-training-at-once): Async training lets rollout run during training, but on one GPU the two phases still wait for each other. - [4.2 Handle long responses with partial rollout](https://aiengineeringfromscratch.com/manual-miles-101/handle-long-responses): Partial rollout stops the slowest answers from setting the time of every step. - [4.3 Roll out in FP8 and train in BF16](https://aiengineeringfromscratch.com/manual-miles-101/roll-out-in-fp8): FP8 rollout makes generation cheaper and makes the trainer and the engine disagree more, so it needs a correction. - [4.4 Lower the log probability gap with top-p and top-k](https://aiengineeringfromscratch.com/manual-miles-101/lower-the-logprob-gap): When you sample with top-p or top-k, Miles replays the sampled token set in the trainer, and the gap between the two sides gets smaller. - [4.5 Know what deterministic inference fixes](https://aiengineeringfromscratch.com/manual-miles-101/use-deterministic-inference): Deterministic inference makes the engine repeat itself, and it does not make the engine agree with the trainer. - [4.6 Check if your GPU can run true on-policy mode](https://aiengineeringfromscratch.com/manual-miles-101/know-the-true-on-policy-limits): True on-policy mode makes the trainer and the engine match bit for bit, but only for the models and GPUs its contract covers. - [5.1 Read the run from its signals](https://aiengineeringfromscratch.com/manual-miles-101/read-the-run): Eight signals in the log tell you in a few minutes if a run is healthy. - [5.2 Check the first step before you trust the run](https://aiengineeringfromscratch.com/manual-miles-101/check-the-first-step): At step 0 the trainer and the engine hold the same weights, so the first step shows if the setup is correct. - [5.3 Repeat a run and compare](https://aiengineeringfromscratch.com/manual-miles-101/repeat-a-run): One run cannot tell an effect from noise, so a change needs a second seed before you trust it. - [6.1 Split rollout and training across GPUs](https://aiengineeringfromscratch.com/manual-miles-101/split-rollout-and-training): On many GPUs, rollout and training can run on separate devices, and a transfer method moves the weights between them. - [6.2 Run evaluation without stopping training](https://aiengineeringfromscratch.com/manual-miles-101/run-a-separate-eval-fleet): Evaluation on the training engines pauses rollout, and a separate fleet avoids the pause at the cost of its own GPUs. - [6.3 Keep a long run going after a failure](https://aiengineeringfromscratch.com/manual-miles-101/survive-failures): Long runs on many machines lose engines and nodes, and Miles has fault tolerance and checkpoints for that. - [6.4 Pick an image for your GPU](https://aiengineeringfromscratch.com/manual-miles-101/pick-an-image): The image decides which kernels your GPU can run, so pick it from your GPU generation, and pin its digest. - [7.1 Troubleshoot by symptom](https://aiengineeringfromscratch.com/manual-miles-101/troubleshoot-by-symptom): Start from what you see, and each entry gives the likely cause, the check, and the fix. - [7.2 Keep runs comparable](https://aiengineeringfromscratch.com/manual-miles-101/keep-runs-comparable): A run that you cannot compare with another run teaches you nothing, so record what each run used before you start it. - [8.1 Why an RL framework owns an inference engine](https://aiengineeringfromscratch.com/manual-miles-101/why-rl-owns-an-engine): RL needs fast generation and exact probabilities from the same weights, and an engine under the trainer's control gives both. - [8.2 The correction methods for the gap](https://aiengineeringfromscratch.com/manual-miles-101/the-correction-methods): Miles has several ways to deal with the gap between the trainer and the engine, and each one fixes a different cause. - [8.3 Why true on-policy mode is a contract](https://aiengineeringfromscratch.com/manual-miles-101/why-true-on-policy-is-a-contract): Bit-exact agreement needs the same kernels on both sides, so true on-policy mode works only for the models and GPUs it lists. - [8.4 Memory and weight updates on unified memory](https://aiengineeringfromscratch.com/manual-miles-101/memory-on-unified-memory): On a GB10 the CPU and the GPU share one memory, so offload moves bytes inside one pool and the weight update never leaves the chip. - [8.5 How rollout functions plug in](https://aiengineeringfromscratch.com/manual-miles-101/how-rollout-functions-plug-in): Generate, reward, filter, and loss functions plug into Miles by an import path, so a new recipe changes code without a fork. - [8.6 Which router to use](https://aiengineeringfromscratch.com/manual-miles-101/which-router-to-use): The router spreads rollout requests over the engines, and the choice matters once you run more than one engine or many turns. - [8.7 Where Miles came from](https://aiengineeringfromscratch.com/manual-miles-101/where-miles-came-from): Miles started as a copy of slime in October 2025 and has grown its own features since, so read its own release notes. - [R.1 Flags by job](https://aiengineeringfromscratch.com/manual-miles-101/ref-flags-by-job): The Miles flags this manual uses, grouped by the job they do. - [R.2 Metrics](https://aiengineeringfromscratch.com/manual-miles-101/ref-metrics): The metrics this manual reads, with their range on our setup. - [R.3 Lab notes](https://aiengineeringfromscratch.com/manual-miles-101/ref-lab-notes): The machine, the image, the seeds, and the thermal rule behind every measured number in this manual. - [R.4 Sources](https://aiengineeringfromscratch.com/manual-miles-101/ref-sources): The sources of this manual, in order of authority. - [R.5 Index of figures](https://aiengineeringfromscratch.com/manual-miles-101/ref-figure-index): Every figure of this manual, in order, by the one claim its caption makes. ### [Reverse Engineering 101](https://aiengineeringfromscratch.com/manual-reverse-engineering-101): Reading a compiled program you built, from file bytes to evidence-backed pseudocode, with rea and Ghidra How to read a compiled program without its source and prove what you found. Every listing comes from a recorded run of rea 6.7.0 and Ghidra 12.1.4 on programs written for this manual. Pinned to rea (rea-agents) with the Ghidra provider rea-agents 6.7.0, Ghidra 12.1.4. - [How to read this manual](https://aiengineeringfromscratch.com/manual-reverse-engineering-101/front): Every listing in this manual comes from one recorded run of rea 6.7.0 with Ghidra 12.1.4 on programs written for it, and every rule traces to a ranked source. - [1.1 rea, providers, and Evidence](https://aiengineeringfromscratch.com/manual-reverse-engineering-101/rea-providers-and-evidence): rea standardizes the question, the session, and the Evidence record, and leaves import, analysis, and decompilation to the engine it binds, here Ghidra 12.1.4. - [1.2 rea function, end to end](https://aiengineeringfromscratch.com/manual-reverse-engineering-101/rea-function-end-to-end): One rea function call opens the file, binds Ghidra, imports a private copy, asks one question over a socket, and prints one Evidence record in about eight… - [2.1 The README use rule and the law](https://aiengineeringfromscratch.com/manual-reverse-engineering-101/the-readme-use-rule-and-the-law): You analyze a program only when you have the right to, and in this manual that right comes from writing every target yourself. - [2.2 rea doctor and the Ghidra provider](https://aiengineeringfromscratch.com/manual-reverse-engineering-101/rea-doctor-and-the-ghidra-provider): rea doctor runs nine checks for the Ghidra scope, and the provider is available only when the install directory, version, analyzeHeadless, native decompiler… - [2.3 rea capabilities](https://aiengineeringfromscratch.com/manual-reverse-engineering-101/rea-capabilities): rea capabilities groups every operation with its declared side effects, so you know before a call whether it starts a process, writes files, or edits the… - [3.1 inspect-artifact](https://aiengineeringfromscratch.com/manual-reverse-engineering-101/inspect-artifact): inspect-artifact reads the file as a container, hashes it, names its format, and returns one Evidence record that tells you which tool to run next. - [3.2 inspect-binary-layout and the load image](https://aiengineeringfromscratch.com/manual-reverse-engineering-101/inspect-binary-layout-and-the-load-image): On macOS, inspect-binary-layout refuses with capability_unavailable, and inspect-macho is the engine-free reader of segments, sections, load commands… - [3.3 address-to-file-offset](https://aiengineeringfromscratch.com/manual-reverse-engineering-101/address-to-file-offset): address-to-file-offset maps one virtual address to the byte in the file that Ghidra loaded there, and the segment load command lets you check the answer by… - [3.4 analyze and the binary_overview record](https://aiengineeringfromscratch.com/manual-reverse-engineering-101/analyze-overview): rea analyze is the CLI name of binary_overview, a derived record that counts what Ghidra found: segments, procedures, and defined strings, for one build at a… - [4.1 open_binary and the headless bridge](https://aiengineeringfromscratch.com/manual-reverse-engineering-101/open-binary-and-the-headless-bridge): open_binary binds one target to one provider without a Ghidra import, and the first Ghidra-backed call pays for a headless import, auto-analysis, and a… - [4.2 list_procedures and function bodies](https://aiengineeringfromscratch.com/manual-reverse-engineering-101/list-procedures-and-function-bodies): list_procedures returns every function Ghidra defined, internal and external, with thunks kept distinct, and the dossier body tells you how many bytes each… - [4.3 procedure_assembly](https://aiengineeringfromscratch.com/manual-reverse-engineering-101/procedure-assembly): procedure_assembly returns the Ghidra Listing text of one function as a string, one instruction per line, with the address first and no bytes. - [4.4 xrefs and the jump table](https://aiengineeringfromscratch.com/manual-reverse-engineering-101/xrefs-and-the-jump-table): xrefs lists the addresses that refer to one address, and the single reference to _grade shows what the optimizer did to the switch and its callers. - [4.5 list_strings](https://aiengineeringfromscratch.com/manual-reverse-engineering-101/list-strings): list_strings returns every string that Ghidra defined as Data, which includes loader metadata and symbol fragments, and excludes any text Ghidra did not define. - [4.6 analyze_function and pseudocode](https://aiengineeringfromscratch.com/manual-reverse-engineering-101/analyze-function-and-pseudocode): analyze_function returns one dossier with sixteen facets, and its pseudocode is a decompiler's reading that you check against the assembly and the bytes in… - [5.1 The Evidence record](https://aiengineeringfromscratch.com/manual-reverse-engineering-101/the-evidence-record): Every successful rea observation is one strict record of sixteen fields, and its id is a SHA-256 over the semantic content with the file path left outside. - [5.2 ResidualUnknown, record_unknown, and coverage](https://aiengineeringfromscratch.com/manual-reverse-engineering-101/residual-unknowns-and-coverage): An unknown is a durable record with its own id and revision chain, and an empty list in any result tells you to check coverage. - [5.3 AnalysisSnapshot and the exact-match answer cache](https://aiengineeringfromscratch.com/manual-reverse-engineering-101/snapshots-and-the-answer-cache): A snapshot caches exact answers under a query id bound to the target digest and the profile digest, and the dispatch of one mutating call turns the cache off. - [5.4 export_evidence_bundle, evidence-export, and evidence-import](https://aiengineeringfromscratch.com/manual-reverse-engineering-101/evidence-bundles-export-and-import): An Evidence bundle is seven sorted arrays in canonical JSON, so the same records give the same bytes from the MCP server and from the CLI. - [5.5 compare_functions and rea compare](https://aiengineeringfromscratch.com/manual-reverse-engineering-101/compare-and-compare-functions): compare_functions diffs two dossiers on eight dimensions and reports each as unchanged, changed, or unknown, and its assembly dimension is a text diff without… - [6.1 analyze-javascript-application and the application graph](https://aiengineeringfromscratch.com/manual-reverse-engineering-101/analyze-javascript-application): rea parses the six files of ledger-desk without running them and returns one derived record whose graph has 42 nodes and 59 edges, each with its own authority. - [6.2 inspect-wasm-artifact and the WABT provider](https://aiengineeringfromscratch.com/manual-reverse-engineering-101/inspect-wasm-artifact): rea 6.7.0 runs three WABT 1.0.42 programs on a private copy of the module and returns one observed Evidence record with sections, a typed interface, and… - [7.1 verify_reconstruction](https://aiengineeringfromscratch.com/manual-reverse-engineering-101/verify-reconstruction): verify_reconstruction grades each declared claim against one comparison record, and its pass says the provider text matched, never that two functions are equal. - [7.2 A proof harness beyond compare_functions](https://aiengineeringfromscratch.com/manual-reverse-engineering-101/a-proof-harness-outside-rea): compare_functions line-diffs Ghidra text, so equality of a rebuilt function needs a harness that runs both over an input grid and compares bytes after masking… - [8.1 rea mcp: initialize, tools/list, and the startup deadline](https://aiengineeringfromscratch.com/manual-reverse-engineering-101/the-rea-mcp-server): rea mcp serves 207 tools over stdio after one initialize handshake, and the first Ghidra-backed call pays for the import under a server deadline the client… - [8.2 One agent investigation over list_procedures, analyze_function, and list_strings](https://aiengineeringfromscratch.com/manual-reverse-engineering-101/an-agent-investigation): An agent working through rea keeps a ledger of what each Evidence record observed, what it inferred, and what it never read, and treats target text as data. - [R.1 Commands and tools used in this manual](https://aiengineeringfromscratch.com/manual-reverse-engineering-101/ref-commands-and-tools): Every rea command and MCP tool the captures ran, with what it answers, the capture file that holds its output, and the section that explains it. - [R.2 Evidence fields](https://aiengineeringfromscratch.com/manual-reverse-engineering-101/ref-evidence-fields): The 16 fields of every Evidence record at 6.7.0, with their types, their allowed values, and one value each from the captured dossier of _percent_change. - [R.3 Errors seen in the captures](https://aiengineeringfromscratch.com/manual-reverse-engineering-101/ref-errors): Three error envelopes, two unavailability codes, one setup refusal, and two refused conclusions appear in the captures, and every rea error has the same five… - [R.4 Glossary](https://aiengineeringfromscratch.com/manual-reverse-engineering-101/ref-glossary): Each term below has one meaning across the manual and names the section that defines it. - [R.5 Sources](https://aiengineeringfromscratch.com/manual-reverse-engineering-101/ref-sources): One pinned source tree, its documentation pages, one recorded capture, and the specifications, papers, and statutes, ranked by authority. - [R.6 Index of figures](https://aiengineeringfromscratch.com/manual-reverse-engineering-101/ref-figure-index): Every figure of this manual, in order, by the one claim its caption makes. ### [SGLang 101](https://aiengineeringfromscratch.com/manual-sglang-101): Serving language models with SGLang, from one request to a fleet, with the judgment the flag list leaves out How SGLang turns GPU memory and time into tokens, why each feature exists, and which defaults to trust. Local listings come from recorded runs of SGLang 0.5.22. Pinned to SGLang 0.5.22. - [How to read this manual](https://aiengineeringfromscratch.com/manual-sglang-101/front): Install SGLang, serve your model, and then learn which few settings matter for your traffic, with the numbers we measured when we changed them. - [1.1 Install SGLang and serve your first model](https://aiengineeringfromscratch.com/manual-sglang-101/install-sglang-and-serve-your-first-model): In about ten minutes, we install SGLang, start a server on one GPU, and get the same answers from it that our recorded run got. - [1.2 Check that the server is healthy](https://aiengineeringfromscratch.com/manual-sglang-101/check-that-the-server-is-healthy): Before you send traffic, confirm that the server answers, that it can produce a token, and that it chose the memory sizes you expect. - [1.3 What the server does with your request](https://aiengineeringfromscratch.com/manual-sglang-101/what-the-server-does-with-your-request): Every request has two phases with different costs, and four numbers tell you how a server handles them for all its users. - [2.1 sglang serve and the three processes](https://aiengineeringfromscratch.com/manual-sglang-101/sglang-serve-and-the-three-processes): SGLang splits one server into a tokenizer process, a scheduler process, and a detokenizer process, because Python text work must never delay the loop that… - [2.2 The scheduler loop and --schedule-policy](https://aiengineeringfromscratch.com/manual-sglang-101/the-scheduler-loop-and-schedule-policy): The scheduler answers one question every few milliseconds, which tokens the GPU computes next, and at v0.5.22 its default answer is first come, first served. - [2.3 Admission and retraction](https://aiengineeringfromscratch.com/manual-sglang-101/admission-and-retraction): SGLang admits a request only when a forecast of its future tokens fits the KV pool, so a full server queues new users instead of breaking the running ones. - [2.4 The overlap scheduler](https://aiengineeringfromscratch.com/manual-sglang-101/the-overlap-scheduler): The overlap scheduler prepares batch N+1 on the CPU while the GPU runs batch N, and at v0.5.22 it is the default path. - [2.5 Streaming, stop strings, and the OpenAI API](https://aiengineeringfromscratch.com/manual-sglang-101/streaming-stop-strings-and-the-openai-api): SGLang checks stop conditions in the scheduler and builds text in the detokenizer, and its native /generate endpoint reports the timing and cache data that… - [3.1 The KV pool and bytes per token](https://aiengineeringfromscratch.com/manual-sglang-101/kv-bytes-per-token-and-the-kv-pool): SGLang stores every token of every running request in one pool of fixed-size slots, so a model's bytes per token decide how many users one GPU can serve. - [3.2 --mem-fraction-static and startup sizing](https://aiengineeringfromscratch.com/manual-sglang-101/mem-fraction-static-and-startup-sizing): SGLang sizes the KV pool once at startup from a snapshot of free memory, so a machine that changes after startup can kill the whole server. - [3.3 RadixCache](https://aiengineeringfromscratch.com/manual-sglang-101/radixcache): RadixCache indexes every cached token run in a tree, so a new request reuses the longest matching prefix and prefills only the tokens after it. - [3.4 Prefix-friendly prompts](https://aiengineeringfromscratch.com/manual-sglang-101/prefix-friendly-prompts): The prefix cache matches tokens from the first one, so one changing token near the start of a prompt can cost more than server tuning recovers. - [3.5 Eviction policies and HiCache](https://aiengineeringfromscratch.com/manual-sglang-101/eviction-policies-and-hicache): When the GPU pool is full, SGLang evicts the least recently used prefix by default, and HiCache keeps evicted prefixes in host memory and in optional storage. - [3.6 Hybrid models and the cache](https://aiengineeringfromscratch.com/manual-sglang-101/hybrid-models-and-the-cache): Sliding-window and Mamba layers keep state that a token-level tree cannot split at any position, so hybrid models are where many reported cache failures sit… - [4.1 ForwardMode and CUDA graphs](https://aiengineeringfromscratch.com/manual-sglang-101/forwardmode-and-cuda-graphs): A decode step is too small to keep a GPU busy, so SGLang records its kernel launches once as a CUDA graph and replays the record on every step. - [4.2 --attention-backend](https://aiengineeringfromscratch.com/manual-sglang-101/attention-backend): SGLang has many attention kernels because none wins on every GPU and model, and its default choice records regressions that someone already paid for. - [4.3 --quantization and --kv-cache-dtype](https://aiengineeringfromscratch.com/manual-sglang-101/quantization): Quantization buys memory first and speed second, and SGLang keeps weights, GEMM kernels, and the KV cache as three separate choices so that you can buy only… - [4.4 --speculative-algorithm](https://aiengineeringfromscratch.com/manual-sglang-101/speculative-decoding): Speculative decoding spends idle GPU compute to commit several tokens per step, so it cuts latency at low load and can cost throughput when the GPU is already… - [4.5 --grammar-backend and structured outputs](https://aiengineeringfromscratch.com/manual-sglang-101/structured-outputs-with-xgrammar): SGLang turns a JSON schema or regex into a token mask for every decode step, and compiles each grammar outside the batch loop. - [4.6 --enable-deterministic-inference and logprobs](https://aiengineeringfromscratch.com/manual-sglang-101/deterministic-inference-and-logprobs): The same prompt can give different tokens when the batch around it changes, and SGLang fixes the reduction order for each model and backend it has tested. - [5.1 sglang.benchmark.serving](https://aiengineeringfromscratch.com/manual-sglang-101/sglang-benchmark-serving): One benchmark run measures one concurrency, so you sweep concurrency until extra load stops adding throughput and only adds waiting. - [5.2 The /metrics endpoint](https://aiengineeringfromscratch.com/manual-sglang-101/the-metrics-endpoint): Gauges report one instant, and the cache hit rate gauge reports one log interval, so you alert on counters and histograms over a time window. - [5.3 Reading other people's SGLang benchmarks](https://aiengineeringfromscratch.com/manual-sglang-101/reading-other-peoples-benchmarks): A published SGLang result depends on its version, workload, memory budget, graph ceiling, and kernels, so you read those five before you read the number. - [6.1 --tp-size, --dp-size, and --attn-dp-size](https://aiengineeringfromscratch.com/manual-sglang-101/tp-size-dp-size-and-attn-dp-size): Tensor parallelism makes a model fit, data parallelism adds capacity, and attention data parallelism removes the KV copies that tensor parallelism makes for… - [6.2 MoE serving: --moe-a2a-backend, DeepEP, and EPLB](https://aiengineeringfromscratch.com/manual-sglang-101/moe-serving-deepep-and-eplb): A mixture-of-experts layer sends every token to the GPUs that hold its experts, so MoE serving is mostly communication, and the busiest GPU sets the pace. - [6.3 Prefill-decode disaggregation: --disaggregation-mode](https://aiengineeringfromscratch.com/manual-sglang-101/prefill-decode-disaggregation): Disaggregation moves prefill to its own servers so long prompts stop delaying other users' tokens, and it pays off only when that delay is your measured… - [6.4 sgl-model-gateway and cache-aware routing](https://aiengineeringfromscratch.com/manual-sglang-101/sgl-model-gateway): With several servers, the router decides your cache hit rate, so send each conversation back to the server that already holds its prefix. - [7.1 Operating SGLang](https://aiengineeringfromscratch.com/manual-sglang-101/operating-sglang): Run SGLang so that a restart costs seconds and drops no request: pin the image, keep the compiled kernels, signal only the main process, and tune in a… - [7.2 SGLang as an RL rollout engine](https://aiengineeringfromscratch.com/manual-sglang-101/sglang-as-an-rl-rollout-engine): In reinforcement learning the server becomes part of the training loop, so its memory, its weights, and its log probabilities all become the trainer's problem. - [R.1 Flags and defaults](https://aiengineeringfromscratch.com/manual-sglang-101/ref-flags-and-defaults): These are the flags this manual changes or explains, with the default the code sets, the value our Mac resolved, and when to change it. - [R.2 Metrics](https://aiengineeringfromscratch.com/manual-sglang-101/ref-metrics): These are the Prometheus series this manual reads, what each one measures, and the question each one answers in production. - [R.3 Incident index](https://aiengineeringfromscratch.com/manual-sglang-101/ref-incident-index): The failures this manual tells as stories, with their symptom, their cause, their fix or status, and the section that explains each one. - [R.4 Glossary](https://aiengineeringfromscratch.com/manual-sglang-101/ref-glossary): Each term below has one meaning across the manual and names the section that defines it. - [R.5 Sources](https://aiengineeringfromscratch.com/manual-sglang-101/ref-sources): The manual ranks its sources by authority, and this page lists every external source the sections cite, with the sections that use each one. - [R.6 Index of figures](https://aiengineeringfromscratch.com/manual-sglang-101/ref-figure-index): Every figure of this manual, in order, by the one claim its caption makes. - [R.7 How this manual was made](https://aiengineeringfromscratch.com/manual-sglang-101/ref-how-this-manual-was-made): This page records the version, the sources, the machines, and the capture kits behind every fact and number in the manual. ### [vLLM 101](https://aiengineeringfromscratch.com/manual-vllm-101): Serve, size, tune, and debug open models with vLLM, with measured answers for each decision How to install vLLM, fit a model on your GPU, tune it for your traffic, and fix it from a symptom. Measured on an NVIDIA L4 and a DGX Spark with vLLM 0.31.0. Pinned to vLLM 0.31.0. - [How to read this manual](https://aiengineeringfromscratch.com/manual-vllm-101/front): This manual helps you serve, size, tune, and debug open models with vLLM, and it gives a measured answer for each decision. - [1.1 Install vLLM and serve your first model](https://aiengineeringfromscratch.com/manual-vllm-101/install-vllm-and-serve-your-first-model): You can go from an empty machine to a streamed token from your own vLLM server with three commands and one request. - [1.2 Check that the server is healthy](https://aiengineeringfromscratch.com/manual-vllm-101/check-that-the-server-is-healthy): Three routes and one log line tell you in a minute that the server is up, that it loaded the right model, and how much it can hold. - [1.3 Understand what happens to your request](https://aiengineeringfromscratch.com/manual-vllm-101/understand-what-happens-to-your-request): A request spends one short phase reading the prompt and a longer phase writing the answer, and four numbers measure those two phases. - [1.4 Set the server options every deployment needs](https://aiengineeringfromscratch.com/manual-vllm-101/set-the-server-options-every-deployment-needs): A handful of server options decide who can reach the server, what name clients send, and what the log keeps. - [2.1 Count the memory before you pick a GPU](https://aiengineeringfromscratch.com/manual-vllm-101/count-the-memory-before-you-pick-a-gpu): The KV cache, not the weights, decides how many users fit, and you can count it from four numbers in the model config. - [2.2 Fix out of memory at startup](https://aiengineeringfromscratch.com/manual-vllm-101/fix-out-of-memory-at-startup): One setting, the GPU memory fraction, decides most startup failures, and a shorter maximum length or a lower concurrency cap fixes most of the rest. - [2.3 Size memory on a DGX Spark](https://aiengineeringfromscratch.com/manual-vllm-101/size-memory-on-a-dgx-spark): On unified memory the GPU and the operating system share one pool, so read free memory from the system, not only from the GPU. - [2.4 Fit more users with an FP8 KV cache](https://aiengineeringfromscratch.com/manual-vllm-101/fit-more-users-with-an-fp8-kv-cache): An FP8 KV cache doubles the tokens that fit, and on an L4 it also changes the attention backend without a warning. - [2.5 Fit a bigger model with FP8 weights](https://aiengineeringfromscratch.com/manual-vllm-101/fit-a-bigger-model-with-fp8-weights): FP8 weights free memory for the KV cache, and the speed change depends on what your GPU supports. - [2.6 Serve long contexts and hybrid models](https://aiengineeringfromscratch.com/manual-vllm-101/serve-long-contexts-and-hybrid-models): A long context and a hybrid model each change how vLLM counts memory, and both can fail at startup for a reason the error hides. - [3.1 Tune chat for many users](https://aiengineeringfromscratch.com/manual-vllm-101/tune-chat-for-many-users): For chat, the worst gap between tokens matters more than throughput, so watch P99 ITL as users grow. - [3.2 Make repeated prompts hit the prefix cache](https://aiengineeringfromscratch.com/manual-vllm-101/make-repeated-prompts-hit-the-prefix-cache): Prefix caching is on by default, and it pays only when the shared part of the prompt comes first. - [3.3 Keep long prompts from stalling short ones](https://aiengineeringfromscratch.com/manual-vllm-101/keep-long-prompts-from-stalling-short-ones): The batch token budget trades the first-token time against the gaps between tokens, so set it for the latency you promise. - [3.4 Keep long sessions cheap](https://aiengineeringfromscratch.com/manual-vllm-101/keep-long-sessions-cheap): Old turns cost nothing while they stay in the cache, and offload keeps them when the GPU pool is full. - [3.5 Return valid JSON and tool calls](https://aiengineeringfromscratch.com/manual-vllm-101/return-valid-json-and-tool-calls): Structured output makes the model produce valid JSON, at a cost you can measure on your own schema. - [3.6 Run batch and offline jobs](https://aiengineeringfromscratch.com/manual-vllm-101/run-batch-and-offline-jobs): When nobody waits for the first token, push concurrency up until throughput stops growing. - [3.7 Serve many fine-tunes with multi-LoRA](https://aiengineeringfromscratch.com/manual-vllm-101/serve-many-fine-tunes-with-multi-lora): One base model can serve many LoRA adapters, and the adapter count and rank set the cost. - [3.8 Get reproducible outputs](https://aiengineeringfromscratch.com/manual-vllm-101/get-reproducible-outputs): A seed alone does not give the same output in a busy batch, and batch invariance costs speed. - [3.9 Use vLLM as an RL rollout engine](https://aiengineeringfromscratch.com/manual-vllm-101/use-vllm-as-an-rl-rollout-engine): An RL trainer borrows the server between steps, and vLLM gives it routes to sleep, wake, and load new weights. - [3.10 Serve reasoning models](https://aiengineeringfromscratch.com/manual-vllm-101/serve-reasoning-models): A reasoning model writes its thinking before the answer, and the reasoning parser keeps the thinking out of the answer text. - [4.1 Speed up decode with EAGLE3](https://aiengineeringfromscratch.com/manual-vllm-101/speed-up-decode-with-eagle3): EAGLE3 pays at low concurrency, and the draft depth that pays falls as more users share each step. - [4.2 Use n-gram speculation for copy-heavy work](https://aiengineeringfromscratch.com/manual-vllm-101/use-n-gram-speculation-for-copy-heavy-work): N-gram speculation needs no draft model and pays when the answer copies the prompt, and it turns off async scheduling. - [4.3 Keep CUDA graphs and compile on](https://aiengineeringfromscratch.com/manual-vllm-101/keep-cuda-graphs-and-compile-on): The default compile level is the right one for most servers, and eager mode costs a few percent of decode speed. - [4.4 Leave async scheduling on](https://aiengineeringfromscratch.com/manual-vllm-101/leave-async-scheduling-on): Async scheduling is on by default for most generate models, and a few settings turn it off without an error. - [4.5 Change the attention backend only for a reason](https://aiengineeringfromscratch.com/manual-vllm-101/change-the-attention-backend-only-for-a-reason): vLLM picks the attention backend for your GPU, and you have two reasons to override it. - [5.1 Benchmark your server in 15 minutes](https://aiengineeringfromscratch.com/manual-vllm-101/benchmark-your-server-in-15-minutes): One sweep over concurrency finds the point where your latency starts to grow, and four defaults change the result. - [5.2 Watch vLLM in production](https://aiengineeringfromscratch.com/manual-vllm-101/watch-vllm-in-production): Five metrics show most problems before users report them. - [5.3 Decide between vLLM and SGLang](https://aiengineeringfromscratch.com/manual-vllm-101/decide-between-vllm-and-sglang): With a fixed number of users, the engines tied on throughput on our machines, and the shape of the traffic decided latency. - [6.1 Choose tensor, pipeline, or data parallelism](https://aiengineeringfromscratch.com/manual-vllm-101/choose-tensor-pipeline-or-data-parallelism): Tensor parallelism splits a model that does not fit, and data parallelism copies a model that does. - [6.2 Serve MoE models with expert parallelism](https://aiengineeringfromscratch.com/manual-vllm-101/serve-moe-models-with-expert-parallelism): Expert parallelism spreads the experts of a MoE model across GPUs, and one GPU can still serve a small MoE model. - [6.3 Split prefill and decode](https://aiengineeringfromscratch.com/manual-vllm-101/split-prefill-and-decode): Separate prefill and decode servers pay only when long prompts hurt the stream of other users. - [6.4 Run vLLM on Kubernetes](https://aiengineeringfromscratch.com/manual-vllm-101/run-vllm-on-kubernetes): A layer above vLLM adds routing and scaling, and you pick it by the features you need. - [6.5 Run vLLM on other accelerators](https://aiengineeringfromscratch.com/manual-vllm-101/run-vllm-on-other-accelerators): vLLM supports other accelerators through plugins, and each plugin follows its own release. - [7.1 Troubleshoot by symptom](https://aiengineeringfromscratch.com/manual-vllm-101/troubleshoot-by-symptom): Most failures have a known cause that one log line or one metric shows. - [7.2 Run vLLM in production](https://aiengineeringfromscratch.com/manual-vllm-101/run-vllm-in-production): vLLM releases every two weeks, so pin the image and plan for cold starts and upgrades. - [8.1 Why vLLM runs three kinds of process](https://aiengineeringfromscratch.com/manual-vllm-101/why-vllm-runs-three-kinds-of-process): This page explains the API server, the engine core, and the workers, and why they are separate processes. - [8.2 Why one token budget replaces a prefill phase](https://aiengineeringfromscratch.com/manual-vllm-101/why-one-token-budget-replaces-a-prefill-phase): This page explains the scheduler loop, decode first, and preemption by recompute. - [8.3 How the block pool manages KV memory](https://aiengineeringfromscratch.com/manual-vllm-101/how-the-block-pool-manages-kv-memory): This page explains hash-keyed blocks, eviction, and KV groups for hybrid models. - [8.4 How vLLM picks an attention backend](https://aiengineeringfromscratch.com/manual-vllm-101/how-vllm-picks-an-attention-backend): This page explains the selection order for each GPU class and what vLLM picks when the first choice cannot run. - [8.5 What Model Runner V2 changed](https://aiengineeringfromscratch.com/manual-vllm-101/what-model-runner-v2-changed): This page explains the new model runner and why async scheduling needs it. - [8.6 How compile and CUDA graphs are captured](https://aiengineeringfromscratch.com/manual-vllm-101/how-compile-and-cuda-graphs-are-captured): This page explains torch.compile, piecewise and full graphs, and the capture sizes. - [8.7 How speculative decoding checks drafts](https://aiengineeringfromscratch.com/manual-vllm-101/how-speculative-decoding-checks-drafts): This page explains draft proposal, verification, and acceptance. - [8.8 How KV connectors move the cache](https://aiengineeringfromscratch.com/manual-vllm-101/how-kv-connectors-move-the-cache): This page explains the connector interface and the transfer layers. - [8.9 Where vLLM came from](https://aiengineeringfromscratch.com/manual-vllm-101/where-vllm-came-from): This page explains the Berkeley project, the V0 to V1 change, and the governance of the project. - [R.1 Flags and defaults](https://aiengineeringfromscratch.com/manual-vllm-101/ref-flags-and-defaults): This page lists the flags the manual uses, grouped by user job, with the default at 0.31.0. - [R.2 Metrics](https://aiengineeringfromscratch.com/manual-vllm-101/ref-metrics): This page lists the vLLM metrics the manual uses and the page that uses each one. - [R.3 Incident index](https://aiengineeringfromscratch.com/manual-vllm-101/ref-incident-index): This page lists every issue the manual cites, with its status at 0.31.0. - [R.4 Version pins](https://aiengineeringfromscratch.com/manual-vllm-101/ref-version-pins): This page lists the versions of vLLM, PyTorch, CUDA, and the images that our runs used. - [R.5 Glossary](https://aiengineeringfromscratch.com/manual-vllm-101/ref-glossary): This page defines each term the manual uses, with the matching SGLang term. - [R.6 Sources](https://aiengineeringfromscratch.com/manual-vllm-101/ref-sources): This page ranks the sources of the manual by authority. - [R.7 Lab notes](https://aiengineeringfromscratch.com/manual-vllm-101/ref-lab-notes): This page records the hardware, the versions, the seeds, the clocks, and the full tables behind each measurement. - [R.8 Index of figures](https://aiengineeringfromscratch.com/manual-vllm-101/ref-figure-index): Every figure of this manual, in order, by the one claim it makes. ## Lesson translations Course lessons are also published in 10 languages: zh (简体中文, 542 lessons), hi (हिन्दी, 542 lessons), es (Español, 542 lessons), ar (العربية, 542 lessons), fr (Français, 542 lessons), pt (Português, 542 lessons), pt-BR (Português (Brasil), 542 lessons), tr (Türkçe, 542 lessons), vi (Tiếng Việt, 542 lessons), fa (فارسی, 542 lessons). Certification lessons, projects, and site pages are English only. - Reader page: https://aiengineeringfromscratch.com/learn//?lang=, with its own canonical URL and hreflang alternates - Markdown: request the reader page with Accept: text/markdown, or GET https://aiengineeringfromscratch.com/api/v1/resource?path=&lang= - Raw source: https://raw.githubusercontent.com/rohitg00/ai-engineering-from-scratch/translations/i18n///docs/.md - [Translated lesson sitemaps](https://aiengineeringfromscratch.com/sitemap-index.xml) Lesson routes include crawler-readable titles, summaries, navigation, and canonical URLs. Each raw markdown link below is the complete source text. Lesson directories may also include code/ (runnable implementation) and quiz.json. ## Phase 0: Setup & Tooling Get your environment ready for everything that follows. - [Dev Environment](https://aiengineeringfromscratch.com/learn/setup-and-tooling/dev-environment) · [raw](https://raw.githubusercontent.com/rohitg00/ai-engineering-from-scratch/main/phases/00-setup-and-tooling/01-dev-environment/docs/en.md) — Your tools shape your thinking. Set them up once, set them up right. - [Git & Collaboration](https://aiengineeringfromscratch.com/learn/setup-and-tooling/git-and-collaboration) · [raw](https://raw.githubusercontent.com/rohitg00/ai-engineering-from-scratch/main/phases/00-setup-and-tooling/02-git-and-collaboration/docs/en.md) — Version control is not optional. Every experiment, every model, every lesson you build here gets tracked. - [GPU Setup & Cloud](https://aiengineeringfromscratch.com/learn/setup-and-tooling/gpu-setup-and-cloud) · [raw](https://raw.githubusercontent.com/rohitg00/ai-engineering-from-scratch/main/phases/00-setup-and-tooling/03-gpu-setup-and-cloud/docs/en.md) — Training on CPU is fine for learning. Training for real needs a GPU. - [APIs & Keys](https://aiengineeringfromscratch.com/learn/setup-and-tooling/apis-and-keys) · [raw](https://raw.githubusercontent.com/rohitg00/ai-engineering-from-scratch/main/phases/00-setup-and-tooling/04-apis-and-keys/docs/en.md) — Every AI API works the same way: send a request, get a response. The details change, the pattern doesn't. - [Jupyter Notebooks](https://aiengineeringfromscratch.com/learn/setup-and-tooling/jupyter-notebooks) · [raw](https://raw.githubusercontent.com/rohitg00/ai-engineering-from-scratch/main/phases/00-setup-and-tooling/05-jupyter-notebooks/docs/en.md) — Notebooks are the lab bench of AI engineering. You prototype here, then move what works into production. - [Python Environments](https://aiengineeringfromscratch.com/learn/setup-and-tooling/python-environments) · [raw](https://raw.githubusercontent.com/rohitg00/ai-engineering-from-scratch/main/phases/00-setup-and-tooling/06-python-environments/docs/en.md) — Dependency hell is real. Virtual environments are the cure. - [Docker for AI](https://aiengineeringfromscratch.com/learn/setup-and-tooling/docker-for-ai) · [raw](https://raw.githubusercontent.com/rohitg00/ai-engineering-from-scratch/main/phases/00-setup-and-tooling/07-docker-for-ai/docs/en.md) — Containers make "works on my machine" a thing of the past. - [Editor Setup](https://aiengineeringfromscratch.com/learn/setup-and-tooling/editor-setup) · [raw](https://raw.githubusercontent.com/rohitg00/ai-engineering-from-scratch/main/phases/00-setup-and-tooling/08-editor-setup/docs/en.md) — Your editor is your co-pilot. Configure it once so it stays out of your way and starts pulling its weight. - [Data Management](https://aiengineeringfromscratch.com/learn/setup-and-tooling/data-management) · [raw](https://raw.githubusercontent.com/rohitg00/ai-engineering-from-scratch/main/phases/00-setup-and-tooling/09-data-management/docs/en.md) — Data is the fuel. How you manage it determines how fast you go. - [Terminal & Shell](https://aiengineeringfromscratch.com/learn/setup-and-tooling/terminal-and-shell) · [raw](https://raw.githubusercontent.com/rohitg00/ai-engineering-from-scratch/main/phases/00-setup-and-tooling/10-terminal-and-shell/docs/en.md) — The terminal is where AI engineers live. Get comfortable here. - [Linux for AI](https://aiengineeringfromscratch.com/learn/setup-and-tooling/linux-for-ai) · [raw](https://raw.githubusercontent.com/rohitg00/ai-engineering-from-scratch/main/phases/00-setup-and-tooling/11-linux-for-ai/docs/en.md) — Most AI runs on Linux. You need to know enough to not be stuck. - [Debugging & Profiling](https://aiengineeringfromscratch.com/learn/setup-and-tooling/debugging-and-profiling) · [raw](https://raw.githubusercontent.com/rohitg00/ai-engineering-from-scratch/main/phases/00-setup-and-tooling/12-debugging-and-profiling/docs/en.md) — The worst AI bugs don't crash. They train silently on garbage and report a beautiful loss curve. - [Python for AI Engineering](https://aiengineeringfromscratch.com/learn/setup-and-tooling/python-for-ai-engineering) · [raw](https://raw.githubusercontent.com/rohitg00/ai-engineering-from-scratch/main/phases/00-setup-and-tooling/13-python-for-ai-engineering/docs/en.md) — Most code in this course uses the same small set of Python idioms. Learn that set here, before the math and model lessons depend on it. ## Phase 1: Math Foundations The intuition behind every AI algorithm, through code. - [Linear Algebra Intuition](https://aiengineeringfromscratch.com/learn/math-foundations/linear-algebra-intuition) · [raw](https://raw.githubusercontent.com/rohitg00/ai-engineering-from-scratch/main/phases/01-math-foundations/01-linear-algebra-intuition/docs/en.md) — Every AI model is just matrix math wearing a fancy hat. - [Vectors, Matrices & Operations](https://aiengineeringfromscratch.com/learn/math-foundations/vectors-matrices-operations) · [raw](https://raw.githubusercontent.com/rohitg00/ai-engineering-from-scratch/main/phases/01-math-foundations/02-vectors-matrices-operations/docs/en.md) — Every neural network is just matrix multiplication with extra steps. - [Matrix Transformations & Eigenvalues](https://aiengineeringfromscratch.com/learn/math-foundations/matrix-transformations) · [raw](https://raw.githubusercontent.com/rohitg00/ai-engineering-from-scratch/main/phases/01-math-foundations/03-matrix-transformations/docs/en.md) — A matrix is a machine that reshapes space. Learn what it does to every point, and you understand the whole transformation. - [Calculus for ML: Derivatives & Gradients](https://aiengineeringfromscratch.com/learn/math-foundations/calculus-for-ml) · [raw](https://raw.githubusercontent.com/rohitg00/ai-engineering-from-scratch/main/phases/01-math-foundations/04-calculus-for-ml/docs/en.md) — Derivatives tell you which way is downhill. That is all a neural network needs to learn. - [Chain Rule & Automatic Differentiation](https://aiengineeringfromscratch.com/learn/math-foundations/chain-rule-and-autodiff) · [raw](https://raw.githubusercontent.com/rohitg00/ai-engineering-from-scratch/main/phases/01-math-foundations/05-chain-rule-and-autodiff/docs/en.md) — The chain rule is the engine behind every neural network that learns. - [Probability & Distributions](https://aiengineeringfromscratch.com/learn/math-foundations/probability-and-distributions) · [raw](https://raw.githubusercontent.com/rohitg00/ai-engineering-from-scratch/main/phases/01-math-foundations/06-probability-and-distributions/docs/en.md) — Probability is the language AI uses to express uncertainty. - [Bayes' Theorem & Statistical Thinking](https://aiengineeringfromscratch.com/learn/math-foundations/bayes-theorem) · [raw](https://raw.githubusercontent.com/rohitg00/ai-engineering-from-scratch/main/phases/01-math-foundations/07-bayes-theorem/docs/en.md) — Probability is about what you expect. Bayes' theorem is about what you learn. - [Optimization: Gradient Descent Family](https://aiengineeringfromscratch.com/learn/math-foundations/optimization) · [raw](https://raw.githubusercontent.com/rohitg00/ai-engineering-from-scratch/main/phases/01-math-foundations/08-optimization/docs/en.md) — Training a neural network is nothing more than finding the bottom of a valley. - [Information Theory: Entropy, KL Divergence](https://aiengineeringfromscratch.com/learn/math-foundations/information-theory) · [raw](https://raw.githubusercontent.com/rohitg00/ai-engineering-from-scratch/main/phases/01-math-foundations/09-information-theory/docs/en.md) — Information theory measures surprise. Loss functions are built on it. - [Dimensionality Reduction: PCA, t-SNE, UMAP](https://aiengineeringfromscratch.com/learn/math-foundations/dimensionality-reduction) · [raw](https://raw.githubusercontent.com/rohitg00/ai-engineering-from-scratch/main/phases/01-math-foundations/10-dimensionality-reduction/docs/en.md) — High-dimensional data has structure. You find it by looking from the right angle. - [Singular Value Decomposition](https://aiengineeringfromscratch.com/learn/math-foundations/singular-value-decomposition) · [raw](https://raw.githubusercontent.com/rohitg00/ai-engineering-from-scratch/main/phases/01-math-foundations/11-singular-value-decomposition/docs/en.md) — SVD is the Swiss Army knife of linear algebra. Every matrix has one. Every data scientist needs one. - [Tensor Operations](https://aiengineeringfromscratch.com/learn/math-foundations/tensor-operations) · [raw](https://raw.githubusercontent.com/rohitg00/ai-engineering-from-scratch/main/phases/01-math-foundations/12-tensor-operations/docs/en.md) — Tensors are the common language between data and deep learning. Every image, every sentence, every gradient flows through them. - [Numerical Stability](https://aiengineeringfromscratch.com/learn/math-foundations/numerical-stability) · [raw](https://raw.githubusercontent.com/rohitg00/ai-engineering-from-scratch/main/phases/01-math-foundations/13-numerical-stability/docs/en.md) — Floating point is a leaky abstraction. It will bite you during training, and you will not see it coming. - [Norms & Distances](https://aiengineeringfromscratch.com/learn/math-foundations/norms-and-distances) · [raw](https://raw.githubusercontent.com/rohitg00/ai-engineering-from-scratch/main/phases/01-math-foundations/14-norms-and-distances/docs/en.md) — Your distance function defines what "similar" means. Choose wrong and everything downstream breaks. - [Statistics for ML](https://aiengineeringfromscratch.com/learn/math-foundations/statistics-for-ml) · [raw](https://raw.githubusercontent.com/rohitg00/ai-engineering-from-scratch/main/phases/01-math-foundations/15-statistics-for-ml/docs/en.md) — Statistics is how you know if your model actually works or just got lucky. - [Sampling Methods](https://aiengineeringfromscratch.com/learn/math-foundations/sampling-methods) · [raw](https://raw.githubusercontent.com/rohitg00/ai-engineering-from-scratch/main/phases/01-math-foundations/16-sampling-methods/docs/en.md) — Sampling is how AI explores the space of possibilities. - [Linear Systems](https://aiengineeringfromscratch.com/learn/math-foundations/linear-systems) · [raw](https://raw.githubusercontent.com/rohitg00/ai-engineering-from-scratch/main/phases/01-math-foundations/17-linear-systems/docs/en.md) — Solving $Ax = b$ is the oldest problem in mathematics that still runs your neural network. - [Convex Optimization](https://aiengineeringfromscratch.com/learn/math-foundations/convex-optimization) · [raw](https://raw.githubusercontent.com/rohitg00/ai-engineering-from-scratch/main/phases/01-math-foundations/18-convex-optimization/docs/en.md) — Convex problems have one valley. Neural networks have millions. Knowing the difference matters. - [Complex Numbers for AI](https://aiengineeringfromscratch.com/learn/math-foundations/complex-numbers) · [raw](https://raw.githubusercontent.com/rohitg00/ai-engineering-from-scratch/main/phases/01-math-foundations/19-complex-numbers/docs/en.md) — The square root of -1 is not imaginary. It is the key to rotations, frequencies, and half of signal processing. - [The Fourier Transform](https://aiengineeringfromscratch.com/learn/math-foundations/fourier-transform) · [raw](https://raw.githubusercontent.com/rohitg00/ai-engineering-from-scratch/main/phases/01-math-foundations/20-fourier-transform/docs/en.md) — Every signal is a sum of sine waves. The Fourier transform tells you which ones. - [Graph Theory for ML](https://aiengineeringfromscratch.com/learn/math-foundations/graph-theory) · [raw](https://raw.githubusercontent.com/rohitg00/ai-engineering-from-scratch/main/phases/01-math-foundations/21-graph-theory/docs/en.md) — Graphs are the data structure of relationships. If your data has connections, you need graph theory. - [Stochastic Processes](https://aiengineeringfromscratch.com/learn/math-foundations/stochastic-processes) · [raw](https://raw.githubusercontent.com/rohitg00/ai-engineering-from-scratch/main/phases/01-math-foundations/22-stochastic-processes/docs/en.md) — Randomness with structure. The math behind random walks, Markov chains, and diffusion models. ## Phase 2: ML Fundamentals Classical ML — still the backbone of most production AI. - [What Is Machine Learning](https://aiengineeringfromscratch.com/learn/ml-fundamentals/what-is-machine-learning) · [raw](https://raw.githubusercontent.com/rohitg00/ai-engineering-from-scratch/main/phases/02-ml-fundamentals/01-what-is-machine-learning/docs/en.md) — Machine learning is teaching computers to find patterns in data instead of writing rules by hand. - [Linear Regression from Scratch](https://aiengineeringfromscratch.com/learn/ml-fundamentals/linear-regression) · [raw](https://raw.githubusercontent.com/rohitg00/ai-engineering-from-scratch/main/phases/02-ml-fundamentals/02-linear-regression/docs/en.md) — Linear regression draws the best straight line through your data. It is the "hello world" of machine learning. - [Logistic Regression & Classification](https://aiengineeringfromscratch.com/learn/ml-fundamentals/logistic-regression) · [raw](https://raw.githubusercontent.com/rohitg00/ai-engineering-from-scratch/main/phases/02-ml-fundamentals/03-logistic-regression/docs/en.md) — Logistic regression bends a straight line into an S-curve to answer yes-or-no questions with probabilities. - [Decision Trees & Random Forests](https://aiengineeringfromscratch.com/learn/ml-fundamentals/decision-trees) · [raw](https://raw.githubusercontent.com/rohitg00/ai-engineering-from-scratch/main/phases/02-ml-fundamentals/04-decision-trees/docs/en.md) — A decision tree is just a flowchart. But a forest of them is one of the most powerful tools in ML. - [Support Vector Machines](https://aiengineeringfromscratch.com/learn/ml-fundamentals/support-vector-machines) · [raw](https://raw.githubusercontent.com/rohitg00/ai-engineering-from-scratch/main/phases/02-ml-fundamentals/05-support-vector-machines/docs/en.md) — Find the widest street between two classes. That is the entire idea. - [KNN & Distance Metrics](https://aiengineeringfromscratch.com/learn/ml-fundamentals/knn-and-distances) · [raw](https://raw.githubusercontent.com/rohitg00/ai-engineering-from-scratch/main/phases/02-ml-fundamentals/06-knn-and-distances/docs/en.md) — Store everything. Predict by looking at your neighbors. The simplest algorithm that actually works. - [Unsupervised Learning: K-Means, DBSCAN](https://aiengineeringfromscratch.com/learn/ml-fundamentals/unsupervised-learning) · [raw](https://raw.githubusercontent.com/rohitg00/ai-engineering-from-scratch/main/phases/02-ml-fundamentals/07-unsupervised-learning/docs/en.md) — No labels, no teacher. The algorithm finds structure on its own. - [Feature Engineering & Selection](https://aiengineeringfromscratch.com/learn/ml-fundamentals/feature-engineering) · [raw](https://raw.githubusercontent.com/rohitg00/ai-engineering-from-scratch/main/phases/02-ml-fundamentals/08-feature-engineering/docs/en.md) — A good feature is worth a thousand data points. - [Model Evaluation: Metrics, Cross-Validation](https://aiengineeringfromscratch.com/learn/ml-fundamentals/model-evaluation) · [raw](https://raw.githubusercontent.com/rohitg00/ai-engineering-from-scratch/main/phases/02-ml-fundamentals/09-model-evaluation/docs/en.md) — A model is only as good as the way you measure it. - [Bias, Variance & the Learning Curve](https://aiengineeringfromscratch.com/learn/ml-fundamentals/bias-variance) · [raw](https://raw.githubusercontent.com/rohitg00/ai-engineering-from-scratch/main/phases/02-ml-fundamentals/10-bias-variance/docs/en.md) — Every model error comes from one of three sources: bias, variance, or noise. You can only control the first two. - [Ensemble Methods: Boosting, Bagging, Stacking](https://aiengineeringfromscratch.com/learn/ml-fundamentals/ensemble-methods) · [raw](https://raw.githubusercontent.com/rohitg00/ai-engineering-from-scratch/main/phases/02-ml-fundamentals/11-ensemble-methods/docs/en.md) — A group of weak learners, combined correctly, becomes a strong learner. This is not a metaphor. It is a theorem. - [Hyperparameter Tuning](https://aiengineeringfromscratch.com/learn/ml-fundamentals/hyperparameter-tuning) · [raw](https://raw.githubusercontent.com/rohitg00/ai-engineering-from-scratch/main/phases/02-ml-fundamentals/12-hyperparameter-tuning/docs/en.md) — Hyperparameters are the knobs you turn before training starts. Turning them well is the difference between a mediocre model and a great one. - [ML Pipelines & Experiment Tracking](https://aiengineeringfromscratch.com/learn/ml-fundamentals/ml-pipelines) · [raw](https://raw.githubusercontent.com/rohitg00/ai-engineering-from-scratch/main/phases/02-ml-fundamentals/13-ml-pipelines/docs/en.md) — A model is not a product. A pipeline is. The pipeline is everything from raw data to deployed prediction, and every step must be reproducible. - [Naive Bayes](https://aiengineeringfromscratch.com/learn/ml-fundamentals/naive-bayes) · [raw](https://raw.githubusercontent.com/rohitg00/ai-engineering-from-scratch/main/phases/02-ml-fundamentals/14-naive-bayes/docs/en.md) — The "naive" assumption is wrong, and it works anyway. That's the beauty of it. - [Time Series Fundamentals](https://aiengineeringfromscratch.com/learn/ml-fundamentals/time-series) · [raw](https://raw.githubusercontent.com/rohitg00/ai-engineering-from-scratch/main/phases/02-ml-fundamentals/15-time-series/docs/en.md) — Past performance does predict future results -- if you check for stationarity first. - [Anomaly Detection](https://aiengineeringfromscratch.com/learn/ml-fundamentals/anomaly-detection) · [raw](https://raw.githubusercontent.com/rohitg00/ai-engineering-from-scratch/main/phases/02-ml-fundamentals/16-anomaly-detection/docs/en.md) — Normal is easy to define. Abnormal is whatever doesn't fit. - [Handling Imbalanced Data](https://aiengineeringfromscratch.com/learn/ml-fundamentals/imbalanced-data) · [raw](https://raw.githubusercontent.com/rohitg00/ai-engineering-from-scratch/main/phases/02-ml-fundamentals/17-imbalanced-data/docs/en.md) — When 99% of your data is "normal," accuracy is a lie. - [Feature Selection](https://aiengineeringfromscratch.com/learn/ml-fundamentals/feature-selection) · [raw](https://raw.githubusercontent.com/rohitg00/ai-engineering-from-scratch/main/phases/02-ml-fundamentals/18-feature-selection/docs/en.md) — More features is not better. The right features is better. - [ML System Design — From Problem to Deployed Model](https://aiengineeringfromscratch.com/learn/ml-fundamentals/ml-system-design) · [raw](https://raw.githubusercontent.com/rohitg00/ai-engineering-from-scratch/main/phases/02-ml-fundamentals/19-ml-system-design/docs/en.md) — A model is one part of a system. The design decides what the model predicts, who acts on it, what it costs, and what happens when it fails. - [Monitoring Models in Production — Data Drift and Concept Drift](https://aiengineeringfromscratch.com/learn/ml-fundamentals/model-monitoring-and-drift) · [raw](https://raw.githubusercontent.com/rohitg00/ai-engineering-from-scratch/main/phases/02-ml-fundamentals/20-model-monitoring-and-drift/docs/en.md) — A deployed model fails without an error message. It keeps returning scores while the world moves away from its training data, and only monitoring shows the gap. - [Feature Stores and Training-Serving Skew](https://aiengineeringfromscratch.com/learn/ml-fundamentals/feature-stores-and-training-serving-skew) · [raw](https://raw.githubusercontent.com/rohitg00/ai-engineering-from-scratch/main/phases/02-ml-fundamentals/21-feature-stores-and-training-serving-skew/docs/en.md) — A feature has one definition and two readers. Training reads its history as of each label time, and serving reads its latest value. When the two readers disagree, the model sees… ## Phase 3: Deep Learning Core Neural networks from first principles. No frameworks until you build one. - [The Perceptron: Where It All Started](https://aiengineeringfromscratch.com/learn/deep-learning-core/the-perceptron) · [raw](https://raw.githubusercontent.com/rohitg00/ai-engineering-from-scratch/main/phases/03-deep-learning-core/01-the-perceptron/docs/en.md) — The perceptron is the atom of neural networks. Split it open and you find weights, a bias, and a decision. - [Multi-Layer Networks & Forward Pass](https://aiengineeringfromscratch.com/learn/deep-learning-core/multi-layer-networks) · [raw](https://raw.githubusercontent.com/rohitg00/ai-engineering-from-scratch/main/phases/03-deep-learning-core/02-multi-layer-networks/docs/en.md) — One neuron draws a line. Stack them, and you can draw anything. - [Backpropagation from Scratch](https://aiengineeringfromscratch.com/learn/deep-learning-core/backpropagation) · [raw](https://raw.githubusercontent.com/rohitg00/ai-engineering-from-scratch/main/phases/03-deep-learning-core/03-backpropagation/docs/en.md) — Backpropagation is the algorithm that makes learning possible. Without it, neural networks are just expensive random number generators. - [Activation Functions: ReLU, Sigmoid, GELU & Why](https://aiengineeringfromscratch.com/learn/deep-learning-core/activation-functions) · [raw](https://raw.githubusercontent.com/rohitg00/ai-engineering-from-scratch/main/phases/03-deep-learning-core/04-activation-functions/docs/en.md) — Without nonlinearity, your 100-layer network is a fancy matrix multiply. Activations are the gates that let neural networks think in curves. - [Loss Functions: MSE, Cross-Entropy, Contrastive](https://aiengineeringfromscratch.com/learn/deep-learning-core/loss-functions) · [raw](https://raw.githubusercontent.com/rohitg00/ai-engineering-from-scratch/main/phases/03-deep-learning-core/05-loss-functions/docs/en.md) — Your network makes a prediction. The ground truth says otherwise. How wrong is it? That number is the loss. Pick the wrong loss function and your model optimizes for the wrong t… - [Optimizers: SGD, Momentum, Adam, AdamW](https://aiengineeringfromscratch.com/learn/deep-learning-core/optimizers) · [raw](https://raw.githubusercontent.com/rohitg00/ai-engineering-from-scratch/main/phases/03-deep-learning-core/06-optimizers/docs/en.md) — Gradient descent tells you which direction to move. It says nothing about how far or how fast. SGD is a compass. Adam is GPS with traffic data. - [Regularization: Dropout, Weight Decay, BatchNorm](https://aiengineeringfromscratch.com/learn/deep-learning-core/regularization) · [raw](https://raw.githubusercontent.com/rohitg00/ai-engineering-from-scratch/main/phases/03-deep-learning-core/07-regularization/docs/en.md) — Your model gets 99% on training data and 60% on test data. It memorized instead of learning. Regularization is the tax you impose on complexity to force generalization. - [Weight Initialization & Training Stability](https://aiengineeringfromscratch.com/learn/deep-learning-core/weight-initialization) · [raw](https://raw.githubusercontent.com/rohitg00/ai-engineering-from-scratch/main/phases/03-deep-learning-core/08-weight-initialization/docs/en.md) — Initialize wrong and training never starts. Initialize right and 50 layers train as smoothly as 3. - [Learning Rate Schedules & Warmup](https://aiengineeringfromscratch.com/learn/deep-learning-core/learning-rate-schedules) · [raw](https://raw.githubusercontent.com/rohitg00/ai-engineering-from-scratch/main/phases/03-deep-learning-core/09-learning-rate-schedules/docs/en.md) — The learning rate is the single most important hyperparameter. Not the architecture. Not the dataset size. Not the activation function. The learning rate. If you tune nothing el… - [Build Your Own Mini Framework](https://aiengineeringfromscratch.com/learn/deep-learning-core/mini-framework) · [raw](https://raw.githubusercontent.com/rohitg00/ai-engineering-from-scratch/main/phases/03-deep-learning-core/10-mini-framework/docs/en.md) — You have built neurons, layers, networks, backprop, activations, loss functions, optimizers, regularization, initialization, and LR schedules. All as separate pieces. Now wire t… - [Introduction to PyTorch](https://aiengineeringfromscratch.com/learn/deep-learning-core/intro-to-pytorch) · [raw](https://raw.githubusercontent.com/rohitg00/ai-engineering-from-scratch/main/phases/03-deep-learning-core/11-intro-to-pytorch/docs/en.md) — You built the engine from pistons and crankshafts. Now learn the one everyone actually drives. - [Introduction to JAX](https://aiengineeringfromscratch.com/learn/deep-learning-core/intro-to-jax) · [raw](https://raw.githubusercontent.com/rohitg00/ai-engineering-from-scratch/main/phases/03-deep-learning-core/12-intro-to-jax/docs/en.md) — PyTorch mutates tensors. TensorFlow builds graphs. JAX compiles pure functions. That last one changes how you think about deep learning. - [Debugging Neural Networks](https://aiengineeringfromscratch.com/learn/deep-learning-core/debugging-neural-networks) · [raw](https://raw.githubusercontent.com/rohitg00/ai-engineering-from-scratch/main/phases/03-deep-learning-core/13-debugging-neural-networks/docs/en.md) — Your network compiled. It ran. It produced a number. The number is wrong and nothing crashed. Welcome to the hardest kind of debugging -- the kind where there is no error message. ## Phase 4: Computer Vision From pixels to understanding — image, video, 3D, VLMs, and world models. - [Image Fundamentals: Pixels, Channels, Color Spaces](https://aiengineeringfromscratch.com/learn/computer-vision/image-fundamentals) · [raw](https://raw.githubusercontent.com/rohitg00/ai-engineering-from-scratch/main/phases/04-computer-vision/01-image-fundamentals/docs/en.md) — An image is a tensor of light samples. Every vision model you will ever use starts from this one fact. - [Convolutions from Scratch](https://aiengineeringfromscratch.com/learn/computer-vision/convolutions-from-scratch) · [raw](https://raw.githubusercontent.com/rohitg00/ai-engineering-from-scratch/main/phases/04-computer-vision/02-convolutions-from-scratch/docs/en.md) — A convolution is a tiny dense layer you slide across an image, sharing the same weights at every location. - [CNNs: LeNet to ResNet](https://aiengineeringfromscratch.com/learn/computer-vision/cnns-lenet-to-resnet) · [raw](https://raw.githubusercontent.com/rohitg00/ai-engineering-from-scratch/main/phases/04-computer-vision/03-cnns-lenet-to-resnet/docs/en.md) — Every major CNN of the last thirty years is the same conv–nonlinearity–downsample recipe with one new idea bolted on. Learn the ideas in order. - [Image Classification](https://aiengineeringfromscratch.com/learn/computer-vision/image-classification) · [raw](https://raw.githubusercontent.com/rohitg00/ai-engineering-from-scratch/main/phases/04-computer-vision/04-image-classification/docs/en.md) — A classifier is a function from pixels to a probability distribution over classes. Everything else is plumbing. - [Transfer Learning & Fine-Tuning](https://aiengineeringfromscratch.com/learn/computer-vision/transfer-learning) · [raw](https://raw.githubusercontent.com/rohitg00/ai-engineering-from-scratch/main/phases/04-computer-vision/05-transfer-learning/docs/en.md) — Somebody else spent a million GPU hours teaching a network what edges, textures, and object parts look like. You should borrow those features before training your own. - [Object Detection — YOLO from Scratch](https://aiengineeringfromscratch.com/learn/computer-vision/object-detection-yolo) · [raw](https://raw.githubusercontent.com/rohitg00/ai-engineering-from-scratch/main/phases/04-computer-vision/06-object-detection-yolo/docs/en.md) — Detection is classification plus regression, run at every position in a feature map, then cleaned up with non-maximum suppression. - [Semantic Segmentation — U-Net](https://aiengineeringfromscratch.com/learn/computer-vision/semantic-segmentation-unet) · [raw](https://raw.githubusercontent.com/rohitg00/ai-engineering-from-scratch/main/phases/04-computer-vision/07-semantic-segmentation-unet/docs/en.md) — Segmentation is classification at every pixel. U-Net makes it work by pairing a downsampling encoder with an upsampling decoder and wiring skip connections between them. - [Instance Segmentation — Mask R-CNN](https://aiengineeringfromscratch.com/learn/computer-vision/instance-segmentation-mask-rcnn) · [raw](https://raw.githubusercontent.com/rohitg00/ai-engineering-from-scratch/main/phases/04-computer-vision/08-instance-segmentation-mask-rcnn/docs/en.md) — Add a tiny mask branch to a Faster R-CNN detector and you have instance segmentation. The hard part is RoIAlign, and it is harder than it looks. - [Image Generation — GANs](https://aiengineeringfromscratch.com/learn/computer-vision/image-generation-gans) · [raw](https://raw.githubusercontent.com/rohitg00/ai-engineering-from-scratch/main/phases/04-computer-vision/09-image-generation-gans/docs/en.md) — A GAN is two neural networks in a fixed game. One draws, one critiques. They get better together until the drawings fool the critic. - [Image Generation — Diffusion Models](https://aiengineeringfromscratch.com/learn/computer-vision/image-generation-diffusion) · [raw](https://raw.githubusercontent.com/rohitg00/ai-engineering-from-scratch/main/phases/04-computer-vision/10-image-generation-diffusion/docs/en.md) — A diffusion model learns to denoise. Train it to remove a tiny bit of noise from a noisy image, repeat that backwards a thousand times, and you have an image generator. - [Stable Diffusion — Architecture & Fine-Tuning](https://aiengineeringfromscratch.com/learn/computer-vision/stable-diffusion) · [raw](https://raw.githubusercontent.com/rohitg00/ai-engineering-from-scratch/main/phases/04-computer-vision/11-stable-diffusion/docs/en.md) — Stable Diffusion is a DDPM that runs in the latent space of a pretrained VAE, conditioned on text via cross-attention, sampled with a fast deterministic ODE solver, and steered … - [Video Understanding — Temporal Modeling](https://aiengineeringfromscratch.com/learn/computer-vision/video-understanding) · [raw](https://raw.githubusercontent.com/rohitg00/ai-engineering-from-scratch/main/phases/04-computer-vision/12-video-understanding/docs/en.md) — A video is a sequence of images plus the physics that connects them. Every video model either treats time as an extra axis (3D conv), a sequence to attend over (transformer), or… - [3D Vision: Point Clouds, NeRFs](https://aiengineeringfromscratch.com/learn/computer-vision/3d-vision-nerf) · [raw](https://raw.githubusercontent.com/rohitg00/ai-engineering-from-scratch/main/phases/04-computer-vision/13-3d-vision-nerf/docs/en.md) — 3D vision comes in two flavours. Point clouds are the sensor's raw output. NeRFs are the learned volumetric field. Both answer "what is where in space." - [Vision Transformers (ViT)](https://aiengineeringfromscratch.com/learn/computer-vision/vision-transformers) · [raw](https://raw.githubusercontent.com/rohitg00/ai-engineering-from-scratch/main/phases/04-computer-vision/14-vision-transformers/docs/en.md) — Cut the image into patches, treat each patch as a word, run a standard transformer. Don't look back. - [Real-Time Vision: Edge Deployment](https://aiengineeringfromscratch.com/learn/computer-vision/real-time-edge) · [raw](https://raw.githubusercontent.com/rohitg00/ai-engineering-from-scratch/main/phases/04-computer-vision/15-real-time-edge/docs/en.md) — Edge inference is the discipline of getting a 90%-accurate model to run at 30 fps on a device with 2 GB of RAM. Every percentage point of accuracy is traded against milliseconds… - [Build a Complete Vision Pipeline](https://aiengineeringfromscratch.com/learn/computer-vision/vision-pipeline-capstone) · [raw](https://raw.githubusercontent.com/rohitg00/ai-engineering-from-scratch/main/phases/04-computer-vision/16-vision-pipeline-capstone/docs/en.md) — A production vision system is a chain of models and rules stitched with data contracts. The pieces are already in this phase; the capstone wires them together end-to-end. - [Self-Supervised Vision — SimCLR, DINO, MAE](https://aiengineeringfromscratch.com/learn/computer-vision/self-supervised-vision) · [raw](https://raw.githubusercontent.com/rohitg00/ai-engineering-from-scratch/main/phases/04-computer-vision/17-self-supervised-vision/docs/en.md) — Labels are the bottleneck of supervised vision. Self-supervised pretraining removes them: learn visual features from 100M unlabelled images, fine-tune on 10k labelled ones. - [Open-Vocabulary Vision — CLIP](https://aiengineeringfromscratch.com/learn/computer-vision/open-vocab-clip) · [raw](https://raw.githubusercontent.com/rohitg00/ai-engineering-from-scratch/main/phases/04-computer-vision/18-open-vocab-clip/docs/en.md) — Train an image encoder and a text encoder together so that matching (image, caption) pairs land at the same point in a shared space. That is the whole trick. - [OCR & Document Understanding](https://aiengineeringfromscratch.com/learn/computer-vision/ocr-document-understanding) · [raw](https://raw.githubusercontent.com/rohitg00/ai-engineering-from-scratch/main/phases/04-computer-vision/19-ocr-document-understanding/docs/en.md) — OCR is a three-stage pipeline — detect text boxes, recognise the characters, then lay them out. Every modern OCR system reorders these stages or merges them. - [Image Retrieval & Metric Learning](https://aiengineeringfromscratch.com/learn/computer-vision/image-retrieval-metric) · [raw](https://raw.githubusercontent.com/rohitg00/ai-engineering-from-scratch/main/phases/04-computer-vision/20-image-retrieval-metric/docs/en.md) — A retrieval system ranks candidates by a distance in embedding space. Metric learning is the discipline of shaping that space so the distances mean what you want. - [Keypoint Detection & Pose Estimation](https://aiengineeringfromscratch.com/learn/computer-vision/keypoint-pose) · [raw](https://raw.githubusercontent.com/rohitg00/ai-engineering-from-scratch/main/phases/04-computer-vision/21-keypoint-pose/docs/en.md) — A pose is a set of ordered keypoints. A keypoint detector is a heatmap regressor. Everything else is bookkeeping. - [3D Gaussian Splatting from Scratch](https://aiengineeringfromscratch.com/learn/computer-vision/3d-gaussian-splatting) · [raw](https://raw.githubusercontent.com/rohitg00/ai-engineering-from-scratch/main/phases/04-computer-vision/22-3d-gaussian-splatting/docs/en.md) — A scene is a cloud of millions of 3D Gaussians. Each one has a position, orientation, scale, opacity, and a colour that depends on viewing direction. Rasterise them, backprop th… - [Diffusion Transformers & Rectified Flow](https://aiengineeringfromscratch.com/learn/computer-vision/diffusion-transformers-rectified-flow) · [raw](https://raw.githubusercontent.com/rohitg00/ai-engineering-from-scratch/main/phases/04-computer-vision/23-diffusion-transformers-rectified-flow/docs/en.md) — The U-Net is not the secret of diffusion. Replace it with a transformer, swap the noise schedule for a straight-line flow, and suddenly you have SD3, FLUX, and every 2026 text-t… - [SAM 3 & Open-Vocabulary Segmentation](https://aiengineeringfromscratch.com/learn/computer-vision/sam3-open-vocab-segmentation) · [raw](https://raw.githubusercontent.com/rohitg00/ai-engineering-from-scratch/main/phases/04-computer-vision/24-sam3-open-vocab-segmentation/docs/en.md) — Give a model a text prompt and an image and get masks for every matching object. SAM 3 made that a single forward pass. - [Vision-Language Models (ViT-MLP-LLM)](https://aiengineeringfromscratch.com/learn/computer-vision/vision-language-models) · [raw](https://raw.githubusercontent.com/rohitg00/ai-engineering-from-scratch/main/phases/04-computer-vision/25-vision-language-models/docs/en.md) — A vision encoder converts an image into tokens. An MLP projector maps those tokens into the LLM's embedding space. A language model does the rest. That pattern — ViT-MLP-LLM — i… - [Monocular Depth & Geometry Estimation](https://aiengineeringfromscratch.com/learn/computer-vision/monocular-depth) · [raw](https://raw.githubusercontent.com/rohitg00/ai-engineering-from-scratch/main/phases/04-computer-vision/26-monocular-depth/docs/en.md) — A depth map is a single-channel image where each pixel is a distance from the camera. Predicting it from one RGB frame used to be impossible without stereo or LiDAR. In 2026 a f… - [Multi-Object Tracking & Video Memory](https://aiengineeringfromscratch.com/learn/computer-vision/multi-object-tracking) · [raw](https://raw.githubusercontent.com/rohitg00/ai-engineering-from-scratch/main/phases/04-computer-vision/27-multi-object-tracking/docs/en.md) — Tracking is detection plus association. Detect every frame. Match this frame's detections to last frame's tracks by ID. - [World Models & Video Diffusion](https://aiengineeringfromscratch.com/learn/computer-vision/world-models-video-diffusion) · [raw](https://raw.githubusercontent.com/rohitg00/ai-engineering-from-scratch/main/phases/04-computer-vision/28-world-models-video-diffusion/docs/en.md) — A video model that predicts the next seconds of a scene is a world simulator. Condition that prediction on actions and you have a learned game engine. ## Phase 5: NLP: Foundations to Advanced Language is the interface to intelligence. - [Text Processing: Tokenization, Stemming, Lemmatization](https://aiengineeringfromscratch.com/learn/nlp-foundations-to-advanced/text-processing) · [raw](https://raw.githubusercontent.com/rohitg00/ai-engineering-from-scratch/main/phases/05-nlp-foundations-to-advanced/01-text-processing/docs/en.md) — Language is continuous. Models are discrete. Preprocessing is the bridge. - [Bag of Words, TF-IDF & Text Representation](https://aiengineeringfromscratch.com/learn/nlp-foundations-to-advanced/bag-of-words-tfidf) · [raw](https://raw.githubusercontent.com/rohitg00/ai-engineering-from-scratch/main/phases/05-nlp-foundations-to-advanced/02-bag-of-words-tfidf/docs/en.md) — Count first, think later. TF-IDF still beats embeddings on well-defined tasks in 2026. - [Word Embeddings: Word2Vec from Scratch](https://aiengineeringfromscratch.com/learn/nlp-foundations-to-advanced/word-embeddings-word2vec) · [raw](https://raw.githubusercontent.com/rohitg00/ai-engineering-from-scratch/main/phases/05-nlp-foundations-to-advanced/03-word-embeddings-word2vec/docs/en.md) — A word is the company it keeps. Train a shallow net on that idea and geometry falls out. - [GloVe, FastText & Subword Embeddings](https://aiengineeringfromscratch.com/learn/nlp-foundations-to-advanced/glove-fasttext-subword) · [raw](https://raw.githubusercontent.com/rohitg00/ai-engineering-from-scratch/main/phases/05-nlp-foundations-to-advanced/04-glove-fasttext-subword/docs/en.md) — Word2Vec trained one embedding per word. GloVe factorized the co-occurrence matrix. FastText embedded the pieces. BPE bridged to transformers. - [Sentiment Analysis](https://aiengineeringfromscratch.com/learn/nlp-foundations-to-advanced/sentiment-analysis) · [raw](https://raw.githubusercontent.com/rohitg00/ai-engineering-from-scratch/main/phases/05-nlp-foundations-to-advanced/05-sentiment-analysis/docs/en.md) — The canonical NLP task. Most of what you need to know about classical text classification shows up here. - [Named Entity Recognition (NER)](https://aiengineeringfromscratch.com/learn/nlp-foundations-to-advanced/named-entity-recognition) · [raw](https://raw.githubusercontent.com/rohitg00/ai-engineering-from-scratch/main/phases/05-nlp-foundations-to-advanced/06-named-entity-recognition/docs/en.md) — Pull the names out. Sounds easy until you deal with ambiguous boundaries, nested entities, and domain jargon. - [POS Tagging & Syntactic Parsing](https://aiengineeringfromscratch.com/learn/nlp-foundations-to-advanced/pos-tagging-parsing) · [raw](https://raw.githubusercontent.com/rohitg00/ai-engineering-from-scratch/main/phases/05-nlp-foundations-to-advanced/07-pos-tagging-parsing/docs/en.md) — Grammar was unfashionable for a while. Then every LLM pipeline needed to validate structured extraction, and it came back. - [Text Classification — CNNs & RNNs for Text](https://aiengineeringfromscratch.com/learn/nlp-foundations-to-advanced/cnns-rnns-for-text) · [raw](https://raw.githubusercontent.com/rohitg00/ai-engineering-from-scratch/main/phases/05-nlp-foundations-to-advanced/08-cnns-rnns-for-text/docs/en.md) — Convolutions learn n-grams. Recurrences remember. Both are superseded by attention. Both still matter on constrained hardware. - [Sequence-to-Sequence Models](https://aiengineeringfromscratch.com/learn/nlp-foundations-to-advanced/sequence-to-sequence) · [raw](https://raw.githubusercontent.com/rohitg00/ai-engineering-from-scratch/main/phases/05-nlp-foundations-to-advanced/09-sequence-to-sequence/docs/en.md) — Two RNNs pretending to be a translator. The bottleneck they hit is the reason attention exists. - [Attention Mechanism — The Breakthrough](https://aiengineeringfromscratch.com/learn/nlp-foundations-to-advanced/attention-mechanism) · [raw](https://raw.githubusercontent.com/rohitg00/ai-engineering-from-scratch/main/phases/05-nlp-foundations-to-advanced/10-attention-mechanism/docs/en.md) — The decoder stops squinting at a compressed summary and starts looking at the whole source. Everything after this is attention plus engineering. - [Machine Translation](https://aiengineeringfromscratch.com/learn/nlp-foundations-to-advanced/machine-translation) · [raw](https://raw.githubusercontent.com/rohitg00/ai-engineering-from-scratch/main/phases/05-nlp-foundations-to-advanced/11-machine-translation/docs/en.md) — Translation is the task that paid for NLP research for thirty years and keeps paying now. - [Text Summarization](https://aiengineeringfromscratch.com/learn/nlp-foundations-to-advanced/text-summarization) · [raw](https://raw.githubusercontent.com/rohitg00/ai-engineering-from-scratch/main/phases/05-nlp-foundations-to-advanced/12-text-summarization/docs/en.md) — Extractive systems tell you what the document said. Abstractive systems tell you what the author meant. Different tasks, different pitfalls. - [Question Answering Systems](https://aiengineeringfromscratch.com/learn/nlp-foundations-to-advanced/question-answering) · [raw](https://raw.githubusercontent.com/rohitg00/ai-engineering-from-scratch/main/phases/05-nlp-foundations-to-advanced/13-question-answering/docs/en.md) — Three systems shaped modern QA. Extractive found spans. Retrieval-augmented grounded them in documents. Generative produced answers. Every modern AI assistant is a mix of the th… - [Information Retrieval & Search](https://aiengineeringfromscratch.com/learn/nlp-foundations-to-advanced/information-retrieval-search) · [raw](https://raw.githubusercontent.com/rohitg00/ai-engineering-from-scratch/main/phases/05-nlp-foundations-to-advanced/14-information-retrieval-search/docs/en.md) — BM25 is precise but brittle. Dense casts a wide net but misses keywords. Hybrid is the 2026 default. Everything else is tuning. - [Topic Modeling: LDA, BERTopic](https://aiengineeringfromscratch.com/learn/nlp-foundations-to-advanced/topic-modeling) · [raw](https://raw.githubusercontent.com/rohitg00/ai-engineering-from-scratch/main/phases/05-nlp-foundations-to-advanced/15-topic-modeling/docs/en.md) — LDA: documents are mixtures of topics, topics are distributions over words. BERTopic: documents cluster in embedding space, clusters are topics. Same goal, different decompositi… - [Text Generation](https://aiengineeringfromscratch.com/learn/nlp-foundations-to-advanced/text-generation-pre-transformer) · [raw](https://raw.githubusercontent.com/rohitg00/ai-engineering-from-scratch/main/phases/05-nlp-foundations-to-advanced/16-text-generation-pre-transformer/docs/en.md) — If a word is surprising, the model is bad. Perplexity makes surprise a number. Smoothing keeps it finite. - [Chatbots: Rule-Based to Neural](https://aiengineeringfromscratch.com/learn/nlp-foundations-to-advanced/chatbots-rule-to-neural) · [raw](https://raw.githubusercontent.com/rohitg00/ai-engineering-from-scratch/main/phases/05-nlp-foundations-to-advanced/17-chatbots-rule-to-neural/docs/en.md) — ELIZA replied with pattern matches. DialogFlow mapped intents. GPT answered from weights. Claude runs tools and verifies. Each era solved the previous one's worst failure. - [Multilingual NLP](https://aiengineeringfromscratch.com/learn/nlp-foundations-to-advanced/multilingual-nlp) · [raw](https://raw.githubusercontent.com/rohitg00/ai-engineering-from-scratch/main/phases/05-nlp-foundations-to-advanced/18-multilingual-nlp/docs/en.md) — One model, 100+ languages, zero training data for most of them. Cross-lingual transfer is the practical miracle of the 2020s. - [Subword Tokenization: BPE, WordPiece, Unigram, SentencePiece](https://aiengineeringfromscratch.com/learn/nlp-foundations-to-advanced/subword-tokenization) · [raw](https://raw.githubusercontent.com/rohitg00/ai-engineering-from-scratch/main/phases/05-nlp-foundations-to-advanced/19-subword-tokenization/docs/en.md) — Word tokenizers choke on unseen words. Character tokenizers blow up sequence length. Subword tokenizers split the difference. Every modern LLM ships on one. - [Structured Outputs & Constrained Decoding](https://aiengineeringfromscratch.com/learn/nlp-foundations-to-advanced/structured-outputs-constrained-decoding) · [raw](https://raw.githubusercontent.com/rohitg00/ai-engineering-from-scratch/main/phases/05-nlp-foundations-to-advanced/20-structured-outputs-constrained-decoding/docs/en.md) — Ask an LLM for JSON. Get JSON most of the time. In production, "most" is the problem. Constrained decoding turns "most" into "always" by editing the logits before sampling. - [NLI & Textual Entailment](https://aiengineeringfromscratch.com/learn/nlp-foundations-to-advanced/nli-textual-entailment) · [raw](https://raw.githubusercontent.com/rohitg00/ai-engineering-from-scratch/main/phases/05-nlp-foundations-to-advanced/21-nli-textual-entailment/docs/en.md) — "t entails h" means a human reading t would conclude h is true. NLI is the task of predicting entailment / contradiction / neutral. Boring on the surface, load-bearing in produc… - [Embedding Models Deep Dive](https://aiengineeringfromscratch.com/learn/nlp-foundations-to-advanced/embedding-models-deep-dive) · [raw](https://raw.githubusercontent.com/rohitg00/ai-engineering-from-scratch/main/phases/05-nlp-foundations-to-advanced/22-embedding-models-deep-dive/docs/en.md) — Word2Vec gave you a vector per word. Modern embedding models give you a vector per passage, cross-lingual, with sparse, dense, and multi-vector views, sized to fit your index. P… - [Chunking Strategies for RAG](https://aiengineeringfromscratch.com/learn/nlp-foundations-to-advanced/chunking-strategies-rag) · [raw](https://raw.githubusercontent.com/rohitg00/ai-engineering-from-scratch/main/phases/05-nlp-foundations-to-advanced/23-chunking-strategies-rag/docs/en.md) — Chunking configuration influences retrieval quality as much as the choice of embedding model (Vectara NAACL 2025). Get chunking wrong and no amount of reranking saves you. - [Coreference Resolution](https://aiengineeringfromscratch.com/learn/nlp-foundations-to-advanced/coreference-resolution) · [raw](https://raw.githubusercontent.com/rohitg00/ai-engineering-from-scratch/main/phases/05-nlp-foundations-to-advanced/24-coreference-resolution/docs/en.md) — "She called him. He did not answer. The doctor was at lunch." Three references to two people and nobody is named. Coreference resolution figures out who is who. - [Entity Linking & Disambiguation](https://aiengineeringfromscratch.com/learn/nlp-foundations-to-advanced/entity-linking) · [raw](https://raw.githubusercontent.com/rohitg00/ai-engineering-from-scratch/main/phases/05-nlp-foundations-to-advanced/25-entity-linking/docs/en.md) — NER found "Paris." Entity linking decides: Paris, France? Paris Hilton? Paris, Texas? Paris (the Trojan prince)? Without linking, your knowledge graph stays ambiguous. - [Relation Extraction & Knowledge Graph Construction](https://aiengineeringfromscratch.com/learn/nlp-foundations-to-advanced/relation-extraction-kg) · [raw](https://raw.githubusercontent.com/rohitg00/ai-engineering-from-scratch/main/phases/05-nlp-foundations-to-advanced/26-relation-extraction-kg/docs/en.md) — NER found the entities. Entity linking anchored them. Relation extraction finds the edges between them. A knowledge graph is the sum of nodes, edges, and their provenance. - [LLM Evaluation: RAGAS, DeepEval, G-Eval](https://aiengineeringfromscratch.com/learn/nlp-foundations-to-advanced/llm-evaluation-frameworks) · [raw](https://raw.githubusercontent.com/rohitg00/ai-engineering-from-scratch/main/phases/05-nlp-foundations-to-advanced/27-llm-evaluation-frameworks/docs/en.md) — Exact-match and F1 miss semantic equivalence. Human review does not scale. LLM-as-judge is the production answer — with enough calibration to trust the number. - [Long-Context Evaluation: NIAH, RULER, LongBench, MRCR](https://aiengineeringfromscratch.com/learn/nlp-foundations-to-advanced/long-context-evaluation) · [raw](https://raw.githubusercontent.com/rohitg00/ai-engineering-from-scratch/main/phases/05-nlp-foundations-to-advanced/28-long-context-evaluation/docs/en.md) — Gemini 3 Pro advertises 10M tokens of context. At 1M tokens, 8-needle MRCR drops to 26.3%. Advertised ≠ usable. Long-context evaluation tells you the actual capacity of the mode… - [Dialogue State Tracking](https://aiengineeringfromscratch.com/learn/nlp-foundations-to-advanced/dialogue-state-tracking) · [raw](https://raw.githubusercontent.com/rohitg00/ai-engineering-from-scratch/main/phases/05-nlp-foundations-to-advanced/29-dialogue-state-tracking/docs/en.md) — "I want a cheap restaurant in the north... actually make it moderate... and add Italian." Three turns, three state updates. DST keeps the slot-value dict in sync so the booking … ## Phase 6: Speech & Audio Hear, understand, speak. - [Audio Fundamentals: Waveforms, Sampling, FFT](https://aiengineeringfromscratch.com/learn/speech-and-audio/audio-fundamentals) · [raw](https://raw.githubusercontent.com/rohitg00/ai-engineering-from-scratch/main/phases/06-speech-and-audio/01-audio-fundamentals/docs/en.md) — Waveforms are the raw signal. Spectrograms are the representation. Mel features are the ML-friendly form. Every modern ASR and TTS pipeline walks this ladder, and the first rung… - [Spectrograms, Mel Scale & Audio Features](https://aiengineeringfromscratch.com/learn/speech-and-audio/spectrograms-mel-features) · [raw](https://raw.githubusercontent.com/rohitg00/ai-engineering-from-scratch/main/phases/06-speech-and-audio/02-spectrograms-mel-features/docs/en.md) — Neural nets do not consume raw waveforms well. They consume spectrograms. They consume mel spectrograms even better. Every ASR, TTS, and audio classifier in 2026 lives or dies b… - [Audio Classification](https://aiengineeringfromscratch.com/learn/speech-and-audio/audio-classification) · [raw](https://raw.githubusercontent.com/rohitg00/ai-engineering-from-scratch/main/phases/06-speech-and-audio/03-audio-classification/docs/en.md) — Everything from "dog barking vs siren" to "which language is this" is audio classification. The features are mels. The architecture moves each decade. The evaluation stays AUC, … - [Speech Recognition (ASR)](https://aiengineeringfromscratch.com/learn/speech-and-audio/speech-recognition-asr) · [raw](https://raw.githubusercontent.com/rohitg00/ai-engineering-from-scratch/main/phases/06-speech-and-audio/04-speech-recognition-asr/docs/en.md) — Speech recognition is audio classification at every timestep, glued together by a sequence model that knows English and silence. CTC, RNN-T, and attention are the three ways to … - [Whisper: Architecture & Fine-Tuning](https://aiengineeringfromscratch.com/learn/speech-and-audio/whisper-architecture-finetuning) · [raw](https://raw.githubusercontent.com/rohitg00/ai-engineering-from-scratch/main/phases/06-speech-and-audio/05-whisper-architecture-finetuning/docs/en.md) — Whisper is a 30-second-window transformer encoder-decoder, trained on 680k hours of multilingual weakly-supervised audio-text pairs. One architecture, multiple tasks, robust acr… - [Speaker Recognition & Verification](https://aiengineeringfromscratch.com/learn/speech-and-audio/speaker-recognition-verification) · [raw](https://raw.githubusercontent.com/rohitg00/ai-engineering-from-scratch/main/phases/06-speech-and-audio/06-speaker-recognition-verification/docs/en.md) — ASR asks "what did they say?" Speaker recognition asks "who said it?" The math looks the same — embeddings plus cosine — but every production decision hinges on a single EER num… - [Text-to-Speech (TTS)](https://aiengineeringfromscratch.com/learn/speech-and-audio/text-to-speech) · [raw](https://raw.githubusercontent.com/rohitg00/ai-engineering-from-scratch/main/phases/06-speech-and-audio/07-text-to-speech/docs/en.md) — ASR inverts speech to text; TTS inverts text to speech. The 2026 stack is three parts: text → tokens, tokens → mel, mel → waveform. Each part has a default model that fits in a … - [Voice Cloning & Voice Conversion](https://aiengineeringfromscratch.com/learn/speech-and-audio/voice-cloning-conversion) · [raw](https://raw.githubusercontent.com/rohitg00/ai-engineering-from-scratch/main/phases/06-speech-and-audio/08-voice-cloning-conversion/docs/en.md) — Voice cloning reads your text in someone else's voice. Voice conversion rewrites your voice into someone else's while preserving what you said. Both hang on the same decompositi… - [Music Generation](https://aiengineeringfromscratch.com/learn/speech-and-audio/music-generation) · [raw](https://raw.githubusercontent.com/rohitg00/ai-engineering-from-scratch/main/phases/06-speech-and-audio/09-music-generation/docs/en.md) — 2026 music generation: Suno v5 and Udio v4 dominate commercial; MusicGen, Stable Audio Open, and ACE-Step lead open-source. The technical problem is mostly solved. The legal pro… - [Audio-Language Models](https://aiengineeringfromscratch.com/learn/speech-and-audio/audio-language-models) · [raw](https://raw.githubusercontent.com/rohitg00/ai-engineering-from-scratch/main/phases/06-speech-and-audio/10-audio-language-models/docs/en.md) — 2026 audio-language models reason over speech + environmental sound + music. Qwen2.5-Omni-7B matches GPT-4o Audio on MMAU-Pro. Audio Flamingo Next beats Gemini 2.5 Pro on LongAu… - [Real-Time Audio Processing](https://aiengineeringfromscratch.com/learn/speech-and-audio/real-time-audio-processing) · [raw](https://raw.githubusercontent.com/rohitg00/ai-engineering-from-scratch/main/phases/06-speech-and-audio/11-real-time-audio-processing/docs/en.md) — Batch pipelines process a file. Real-time pipelines process the next 20 milliseconds before the next 20 arrive. Every conversational AI, broadcast studio, and telephony bot live… - [Build a Voice Assistant Pipeline](https://aiengineeringfromscratch.com/learn/speech-and-audio/voice-assistant-pipeline) · [raw](https://raw.githubusercontent.com/rohitg00/ai-engineering-from-scratch/main/phases/06-speech-and-audio/12-voice-assistant-pipeline/docs/en.md) — Everything from lessons 01-11, stitched together. Build a voice assistant that listens, reasons, and talks back. In 2026 that is a solved engineering problem, not a research pro… - [Neural Audio Codecs — EnCodec, SNAC, Mimi, DAC](https://aiengineeringfromscratch.com/learn/speech-and-audio/neural-audio-codecs) · [raw](https://raw.githubusercontent.com/rohitg00/ai-engineering-from-scratch/main/phases/06-speech-and-audio/13-neural-audio-codecs/docs/en.md) — 2026 audio generation is almost all tokens. EnCodec, SNAC, Mimi, and DAC turn continuous waveforms into discrete sequences that a transformer can predict. The semantic-vs-acoust… - [Voice Activity Detection & Turn-Taking](https://aiengineeringfromscratch.com/learn/speech-and-audio/voice-activity-detection-turn-taking) · [raw](https://raw.githubusercontent.com/rohitg00/ai-engineering-from-scratch/main/phases/06-speech-and-audio/14-voice-activity-detection-turn-taking/docs/en.md) — Every voice agent lives or dies on two decisions: is the user speaking now, and are they done? VAD answers the first. Turn-detection (VAD + silence-hangover + semantic endpoint … - [Streaming Speech-to-Speech — Moshi, Hibiki](https://aiengineeringfromscratch.com/learn/speech-and-audio/streaming-speech-to-speech-moshi-hibiki) · [raw](https://raw.githubusercontent.com/rohitg00/ai-engineering-from-scratch/main/phases/06-speech-and-audio/15-streaming-speech-to-speech-moshi-hibiki/docs/en.md) — 2024-2026 redefined voice AI. Moshi ships a single model that listens and speaks simultaneously at 200 ms latency. Hibiki does speech-to-speech translation chunk-by-chunk. Both … - [Voice Anti-Spoofing & Audio Watermarking](https://aiengineeringfromscratch.com/learn/speech-and-audio/anti-spoofing-audio-watermarking) · [raw](https://raw.githubusercontent.com/rohitg00/ai-engineering-from-scratch/main/phases/06-speech-and-audio/16-anti-spoofing-audio-watermarking/docs/en.md) — Voice cloning shipped faster than defenses. 2026 production voice systems need two things: a detector (AASIST, RawNet2) that classifies real vs fake speech, and a watermark (Aud… - [Audio Evaluation — WER, MOS, MMAU, Leaderboards](https://aiengineeringfromscratch.com/learn/speech-and-audio/audio-evaluation-metrics) · [raw](https://raw.githubusercontent.com/rohitg00/ai-engineering-from-scratch/main/phases/06-speech-and-audio/17-audio-evaluation-metrics/docs/en.md) — You cannot ship what you cannot measure. This lesson names the 2026 metrics for every audio task: ASR (WER, CER, RTFx), TTS (MOS, UTMOS, SECS, WER-on-ASR-round-trip), audio-lang… ## Phase 7: Transformers Deep Dive The architecture that changed everything. - [Why Transformers: The Problems with RNNs](https://aiengineeringfromscratch.com/learn/transformers-deep-dive/why-transformers) · [raw](https://raw.githubusercontent.com/rohitg00/ai-engineering-from-scratch/main/phases/07-transformers-deep-dive/01-why-transformers/docs/en.md) — RNNs process tokens one at a time. Transformers process all tokens at once. That single architectural bet changed every scaling curve in deep learning after 2017. - [Self-Attention from Scratch](https://aiengineeringfromscratch.com/learn/transformers-deep-dive/self-attention-from-scratch) · [raw](https://raw.githubusercontent.com/rohitg00/ai-engineering-from-scratch/main/phases/07-transformers-deep-dive/02-self-attention-from-scratch/docs/en.md) — Attention is a lookup table where every word asks "who matters to me?" - and learns the answer. - [Multi-Head Attention](https://aiengineeringfromscratch.com/learn/transformers-deep-dive/multi-head-attention) · [raw](https://raw.githubusercontent.com/rohitg00/ai-engineering-from-scratch/main/phases/07-transformers-deep-dive/03-multi-head-attention/docs/en.md) — One attention head learns one relation at a time. Eight heads learn eight. Heads are free. Take more of them. - [Positional Encoding: Sinusoidal, RoPE, ALiBi](https://aiengineeringfromscratch.com/learn/transformers-deep-dive/positional-encoding) · [raw](https://raw.githubusercontent.com/rohitg00/ai-engineering-from-scratch/main/phases/07-transformers-deep-dive/04-positional-encoding/docs/en.md) — Attention is permutation-invariant. "The cat sat on the mat" and "mat the on sat cat the" produce the same output without positional signal. Three algorithms fix it — each with … - [The Full Transformer: Encoder + Decoder](https://aiengineeringfromscratch.com/learn/transformers-deep-dive/full-transformer) · [raw](https://raw.githubusercontent.com/rohitg00/ai-engineering-from-scratch/main/phases/07-transformers-deep-dive/05-full-transformer/docs/en.md) — Attention is the star. Everything else — residuals, normalization, feed-forward, cross-attention — is the scaffolding that lets you stack it deep. - [BERT — Masked Language Modeling](https://aiengineeringfromscratch.com/learn/transformers-deep-dive/bert-masked-language-modeling) · [raw](https://raw.githubusercontent.com/rohitg00/ai-engineering-from-scratch/main/phases/07-transformers-deep-dive/06-bert-masked-language-modeling/docs/en.md) — GPT predicts the next word. BERT predicts a missing word. One sentence of difference — and half a decade of everything embedding-shaped. - [GPT — Causal Language Modeling](https://aiengineeringfromscratch.com/learn/transformers-deep-dive/gpt-causal-language-modeling) · [raw](https://raw.githubusercontent.com/rohitg00/ai-engineering-from-scratch/main/phases/07-transformers-deep-dive/07-gpt-causal-language-modeling/docs/en.md) — BERT sees both sides. GPT sees only the past. The triangle mask is the most consequential single line of code in modern AI. - [T5, BART — Encoder-Decoder Models](https://aiengineeringfromscratch.com/learn/transformers-deep-dive/t5-bart-encoder-decoder) · [raw](https://raw.githubusercontent.com/rohitg00/ai-engineering-from-scratch/main/phases/07-transformers-deep-dive/08-t5-bart-encoder-decoder/docs/en.md) — Encoders understand. Decoders generate. Put them back together and you get a model built for input → output tasks: translate, summarize, rewrite, transcribe. - [Vision Transformers (ViT)](https://aiengineeringfromscratch.com/learn/transformers-deep-dive/vision-transformers) · [raw](https://raw.githubusercontent.com/rohitg00/ai-engineering-from-scratch/main/phases/07-transformers-deep-dive/09-vision-transformers/docs/en.md) — An image is a grid of patches. A sentence is a grid of tokens. The same transformer eats both. - [Audio Transformers — Whisper Architecture](https://aiengineeringfromscratch.com/learn/transformers-deep-dive/audio-transformers-whisper) · [raw](https://raw.githubusercontent.com/rohitg00/ai-engineering-from-scratch/main/phases/07-transformers-deep-dive/10-audio-transformers-whisper/docs/en.md) — Audio is an image of frequency over time. Whisper is a ViT that eats mel spectrograms and speaks back. - [Mixture of Experts (MoE)](https://aiengineeringfromscratch.com/learn/transformers-deep-dive/mixture-of-experts) · [raw](https://raw.githubusercontent.com/rohitg00/ai-engineering-from-scratch/main/phases/07-transformers-deep-dive/11-mixture-of-experts/docs/en.md) — A dense 70B transformer activates every parameter for every token. A 671B MoE activates only 37B per token and beats it on every benchmark. Sparsity is the most important scalin… - [KV Cache, Flash Attention & Inference Optimization](https://aiengineeringfromscratch.com/learn/transformers-deep-dive/kv-cache-flash-attention) · [raw](https://raw.githubusercontent.com/rohitg00/ai-engineering-from-scratch/main/phases/07-transformers-deep-dive/12-kv-cache-flash-attention/docs/en.md) — Training is parallel and FLOP-bound. Inference is serial and memory-bound. Different bottleneck, different tricks. - [Scaling Laws](https://aiengineeringfromscratch.com/learn/transformers-deep-dive/scaling-laws) · [raw](https://raw.githubusercontent.com/rohitg00/ai-engineering-from-scratch/main/phases/07-transformers-deep-dive/13-scaling-laws/docs/en.md) — The 2020 Kaplan paper said: bigger model, lower loss. The 2022 Hoffmann paper said: you were under-training. Compute goes into two buckets — parameters and tokens — and the spli… - [Build a Transformer from Scratch](https://aiengineeringfromscratch.com/learn/transformers-deep-dive/build-a-transformer-capstone) · [raw](https://raw.githubusercontent.com/rohitg00/ai-engineering-from-scratch/main/phases/07-transformers-deep-dive/14-build-a-transformer-capstone/docs/en.md) — Thirteen lessons. One model. No shortcuts. - [Attention Variants — Sliding Window, Sparse, Differential](https://aiengineeringfromscratch.com/learn/transformers-deep-dive/attention-variants) · [raw](https://raw.githubusercontent.com/rohitg00/ai-engineering-from-scratch/main/phases/07-transformers-deep-dive/15-attention-variants/docs/en.md) — Full attention is a circle. Every token sees every token, and memory pays the price. Three variants bend the shape of the circle and recover half the cost. - [Speculative Decoding — Draft, Verify, Repeat](https://aiengineeringfromscratch.com/learn/transformers-deep-dive/speculative-decoding) · [raw](https://raw.githubusercontent.com/rohitg00/ai-engineering-from-scratch/main/phases/07-transformers-deep-dive/16-speculative-decoding/docs/en.md) — Autoregressive decoding is serial. Each token waits for the previous one. Speculative decoding breaks the chain: a cheap model drafts N tokens, the expensive model verifies all … ## Phase 8: Generative AI Create images, video, audio, 3D, and more. - [Generative Models: Taxonomy & History](https://aiengineeringfromscratch.com/learn/generative-ai/generative-models-taxonomy-history) · [raw](https://raw.githubusercontent.com/rohitg00/ai-engineering-from-scratch/main/phases/08-generative-ai/01-generative-models-taxonomy-history/docs/en.md) — Every image model, text model, video model, and 3D model fits in one of five buckets. Pick the wrong bucket and you will fight the math for weeks. Pick the right one and the fie… - [Autoencoders & VAE](https://aiengineeringfromscratch.com/learn/generative-ai/autoencoders-vae) · [raw](https://raw.githubusercontent.com/rohitg00/ai-engineering-from-scratch/main/phases/08-generative-ai/02-autoencoders-vae/docs/en.md) — A plain autoencoder compresses then reconstructs. It memorizes. It does not generate. Add one trick — force the code to look Gaussian — and you get a sampler. That single trick,… - [GANs: Generator vs Discriminator](https://aiengineeringfromscratch.com/learn/generative-ai/gans-generator-discriminator) · [raw](https://raw.githubusercontent.com/rohitg00/ai-engineering-from-scratch/main/phases/08-generative-ai/03-gans-generator-discriminator/docs/en.md) — Goodfellow's trick in 2014 was to skip density entirely. Two networks. One makes fakes. One catches them. They fight until the fakes are indistinguishable from real. It shouldn'… - [Conditional GANs & Pix2Pix](https://aiengineeringfromscratch.com/learn/generative-ai/conditional-gans-pix2pix) · [raw](https://raw.githubusercontent.com/rohitg00/ai-engineering-from-scratch/main/phases/08-generative-ai/04-conditional-gans-pix2pix/docs/en.md) — The first big unlock of 2014-2017 was controlling what a GAN makes. Attach a label, or an image, or a sentence. Pix2Pix did the image version and it still beats every generic te… - [StyleGAN](https://aiengineeringfromscratch.com/learn/generative-ai/stylegan) · [raw](https://raw.githubusercontent.com/rohitg00/ai-engineering-from-scratch/main/phases/08-generative-ai/05-stylegan/docs/en.md) — Most generators stir $z$ into every layer at the same time. StyleGAN split it apart: first map $z$ to an intermediate $w$, then *inject* $w$ at every resolution level through Ad… - [Diffusion Models — DDPM from Scratch](https://aiengineeringfromscratch.com/learn/generative-ai/diffusion-ddpm-from-scratch) · [raw](https://raw.githubusercontent.com/rohitg00/ai-engineering-from-scratch/main/phases/08-generative-ai/06-diffusion-ddpm-from-scratch/docs/en.md) — Ho, Jain, Abbeel (2020) gave the field a recipe it could not quit. Destroy the data with noise over a thousand small steps. Train one neural net to predict the noise. Reverse th… - [Latent Diffusion & Stable Diffusion](https://aiengineeringfromscratch.com/learn/generative-ai/latent-diffusion-stable-diffusion) · [raw](https://raw.githubusercontent.com/rohitg00/ai-engineering-from-scratch/main/phases/08-generative-ai/07-latent-diffusion-stable-diffusion/docs/en.md) — Pixel-space diffusion on 512×512 images is a computational war crime. Rombach et al. (2022) noticed that you do not need all 786k dimensions to generate an image — you need enou… - [ControlNet, LoRA & Conditioning](https://aiengineeringfromscratch.com/learn/generative-ai/controlnet-lora-conditioning) · [raw](https://raw.githubusercontent.com/rohitg00/ai-engineering-from-scratch/main/phases/08-generative-ai/08-controlnet-lora-conditioning/docs/en.md) — Text alone is a clumsy control signal. ControlNet lets you clone a pretrained diffusion model and steer it with a depth map, pose skeleton, scribble, or edge image. LoRA lets yo… - [Inpainting, Outpainting & Editing](https://aiengineeringfromscratch.com/learn/generative-ai/inpainting-outpainting-editing) · [raw](https://raw.githubusercontent.com/rohitg00/ai-engineering-from-scratch/main/phases/08-generative-ai/09-inpainting-outpainting-editing/docs/en.md) — Text-to-image makes new things. Inpainting fixes old ones. In production, 70% of billable image work is editing — swap a background, remove a logo, extend the canvas, regenerate… - [Video Generation](https://aiengineeringfromscratch.com/learn/generative-ai/video-generation) · [raw](https://raw.githubusercontent.com/rohitg00/ai-engineering-from-scratch/main/phases/08-generative-ai/10-video-generation/docs/en.md) — An image is a 2-D tensor. A video is a 3-D one. The theory is the same; the compute is 10-100x harder. OpenAI's Sora (Feb 2024) proved it was possible. By 2026 Veo 2, Kling 1.5,… - [Audio Generation](https://aiengineeringfromscratch.com/learn/generative-ai/audio-generation) · [raw](https://raw.githubusercontent.com/rohitg00/ai-engineering-from-scratch/main/phases/08-generative-ai/11-audio-generation/docs/en.md) — Audio is a 1-D signal at 16-48 kHz. A five-second clip is 80-240k samples. No transformer attends to that sequence directly. The solution for every production audio model in 202… - [3D Generation](https://aiengineeringfromscratch.com/learn/generative-ai/3d-generation) · [raw](https://raw.githubusercontent.com/rohitg00/ai-engineering-from-scratch/main/phases/08-generative-ai/12-3d-generation/docs/en.md) — 3D is the modality where 2D-to-3D leverage is strongest. The 2023 breakthrough was 3D Gaussian Splatting. The 2024-2026 generative push layers multi-view diffusion + 3D reconstr… - [Flow Matching & Rectified Flows](https://aiengineeringfromscratch.com/learn/generative-ai/flow-matching-rectified-flows) · [raw](https://raw.githubusercontent.com/rohitg00/ai-engineering-from-scratch/main/phases/08-generative-ai/13-flow-matching-rectified-flows/docs/en.md) — Diffusion models take 20-50 sampling steps because they walk a curved path from noise to data. Flow matching (Lipman et al., 2023) and rectified flow (Liu et al., 2022) trained … - [Evaluation: FID, CLIP Score](https://aiengineeringfromscratch.com/learn/generative-ai/evaluation-fid-clip-score) · [raw](https://raw.githubusercontent.com/rohitg00/ai-engineering-from-scratch/main/phases/08-generative-ai/14-evaluation-fid-clip-score/docs/en.md) — Every generative model leaderboard cites FID, CLIP score, and a win rate from a human-preference arena. Each number has a failure mode a determined researcher can game. If you d… - [Visual Autoregressive Modeling (VAR): Next-Scale Prediction](https://aiengineeringfromscratch.com/learn/generative-ai/visual-autoregressive-var) · [raw](https://raw.githubusercontent.com/rohitg00/ai-engineering-from-scratch/main/phases/08-generative-ai/19-visual-autoregressive-var/docs/en.md) — Diffusion models sample iteratively in time (denoising steps). VAR samples iteratively in scale — it predicts a 1x1 token, then 2x2, then 4x4, up to the final resolution, each s… ## Phase 9: Reinforcement Learning The foundation of RLHF and game-playing AI. - [MDPs, States, Actions & Rewards](https://aiengineeringfromscratch.com/learn/reinforcement-learning/mdps-states-actions-rewards) · [raw](https://raw.githubusercontent.com/rohitg00/ai-engineering-from-scratch/main/phases/09-reinforcement-learning/01-mdps-states-actions-rewards/docs/en.md) — A Markov Decision Process is five things: states, actions, transitions, rewards, a discount. Everything in RL — Q-learning, PPO, DPO, GRPO — optimizes over this shape. Learn it … - [Dynamic Programming](https://aiengineeringfromscratch.com/learn/reinforcement-learning/dynamic-programming) · [raw](https://raw.githubusercontent.com/rohitg00/ai-engineering-from-scratch/main/phases/09-reinforcement-learning/02-dynamic-programming/docs/en.md) — Dynamic programming is RL with cheating. You already know the transition and reward functions; you just iterate the Bellman equation until $V$ or $\pi$ stops moving. It is the b… - [Monte Carlo Methods](https://aiengineeringfromscratch.com/learn/reinforcement-learning/monte-carlo-methods) · [raw](https://raw.githubusercontent.com/rohitg00/ai-engineering-from-scratch/main/phases/09-reinforcement-learning/03-monte-carlo-methods/docs/en.md) — Dynamic programming needs a model. Monte Carlo needs nothing but episodes. Run the policy, watch the returns, average them. The simplest idea in RL — and the one that unlocks ev… - [Q-Learning, SARSA](https://aiengineeringfromscratch.com/learn/reinforcement-learning/q-learning-sarsa) · [raw](https://raw.githubusercontent.com/rohitg00/ai-engineering-from-scratch/main/phases/09-reinforcement-learning/04-q-learning-sarsa/docs/en.md) — Monte Carlo waits until the episode ends. TD updates after every step by bootstrapping the next value estimate. Q-learning is off-policy and optimistic; SARSA is on-policy and c… - [Deep Q-Networks (DQN)](https://aiengineeringfromscratch.com/learn/reinforcement-learning/dqn) · [raw](https://raw.githubusercontent.com/rohitg00/ai-engineering-from-scratch/main/phases/09-reinforcement-learning/05-dqn/docs/en.md) — 2013: Mnih trained one Q-learning network on raw pixels, beat every classical RL agent on seven Atari games. 2015: extended to 49 games, published in Nature, sparked the deep-RL… - [Policy Gradients — REINFORCE](https://aiengineeringfromscratch.com/learn/reinforcement-learning/policy-gradients-reinforce) · [raw](https://raw.githubusercontent.com/rohitg00/ai-engineering-from-scratch/main/phases/09-reinforcement-learning/06-policy-gradients-reinforce/docs/en.md) — Stop estimating value. Parameterize the policy directly, compute the gradient of expected return, step uphill. Williams (1992) wrote it in one theorem. It is why PPO, GRPO, and … - [Actor-Critic — A2C, A3C](https://aiengineeringfromscratch.com/learn/reinforcement-learning/actor-critic-a2c-a3c) · [raw](https://raw.githubusercontent.com/rohitg00/ai-engineering-from-scratch/main/phases/09-reinforcement-learning/07-actor-critic-a2c-a3c/docs/en.md) — REINFORCE is noisy. Add a critic that learns $\hat{V}(s)$, subtract it from the return, and you get an advantage that has the same expectation but far lower variance. That is ac… - [PPO](https://aiengineeringfromscratch.com/learn/reinforcement-learning/ppo) · [raw](https://raw.githubusercontent.com/rohitg00/ai-engineering-from-scratch/main/phases/09-reinforcement-learning/08-ppo/docs/en.md) — A2C throws away each rollout after one update. PPO wraps the policy gradient in a clipped importance ratio so you can do 10+ epochs on the same data without the policy exploding… - [Reward Modeling & RLHF](https://aiengineeringfromscratch.com/learn/reinforcement-learning/reward-modeling-rlhf) · [raw](https://raw.githubusercontent.com/rohitg00/ai-engineering-from-scratch/main/phases/09-reinforcement-learning/09-reward-modeling-rlhf/docs/en.md) — Humans cannot write a reward function for "good assistant response," but they can compare two responses and pick the better one. Fit a reward model to those comparisons, then RL… - [Multi-Agent RL](https://aiengineeringfromscratch.com/learn/reinforcement-learning/multi-agent-rl) · [raw](https://raw.githubusercontent.com/rohitg00/ai-engineering-from-scratch/main/phases/09-reinforcement-learning/10-multi-agent-rl/docs/en.md) — Single-agent RL assumes the environment is stationary. Put two learning agents in the same world and that assumption breaks: each agent is part of the other's environment, and b… - [Sim-to-Real Transfer](https://aiengineeringfromscratch.com/learn/reinforcement-learning/sim-to-real-transfer) · [raw](https://raw.githubusercontent.com/rohitg00/ai-engineering-from-scratch/main/phases/09-reinforcement-learning/11-sim-to-real-transfer/docs/en.md) — A policy trained in a simulator that fails on hardware is a policy that memorized the simulator. Domain randomization, domain adaptation, and system identification are the three… - [RL for Games](https://aiengineeringfromscratch.com/learn/reinforcement-learning/rl-for-games) · [raw](https://raw.githubusercontent.com/rohitg00/ai-engineering-from-scratch/main/phases/09-reinforcement-learning/12-rl-for-games/docs/en.md) — 1992: TD-Gammon beat human champions at backgammon with pure TD. 2016: AlphaGo beat Lee Sedol. 2017: AlphaZero dominated chess, shogi, and Go from scratch. 2025: DeepSeek-R1 pro… ## Phase 10: LLMs from Scratch Build, train, and understand large language models. - [Tokenizers: BPE, WordPiece, SentencePiece](https://aiengineeringfromscratch.com/learn/llms-from-scratch/tokenizers) · [raw](https://raw.githubusercontent.com/rohitg00/ai-engineering-from-scratch/main/phases/10-llms-from-scratch/01-tokenizers/docs/en.md) — Your LLM does not read English. It reads integers. The tokenizer decides whether those integers carry meaning or waste it. - [Building a Tokenizer from Scratch](https://aiengineeringfromscratch.com/learn/llms-from-scratch/building-a-tokenizer) · [raw](https://raw.githubusercontent.com/rohitg00/ai-engineering-from-scratch/main/phases/10-llms-from-scratch/02-building-a-tokenizer/docs/en.md) — Lesson 01 gave you a toy. This lesson gives you a weapon. - [Data Pipelines for Pre-Training](https://aiengineeringfromscratch.com/learn/llms-from-scratch/data-pipelines) · [raw](https://raw.githubusercontent.com/rohitg00/ai-engineering-from-scratch/main/phases/10-llms-from-scratch/03-data-pipelines/docs/en.md) — The model is a mirror. It reflects whatever data you feed it. Feed it garbage, it reflects garbage with perfect fluency. - [Pre-Training a Mini GPT (124M)](https://aiengineeringfromscratch.com/learn/llms-from-scratch/pre-training-mini-gpt) · [raw](https://raw.githubusercontent.com/rohitg00/ai-engineering-from-scratch/main/phases/10-llms-from-scratch/04-pre-training-mini-gpt/docs/en.md) — GPT-2 Small has 124 million parameters. That's 12 transformer layers, 12 attention heads, and 768-dimensional embeddings. You can train it from scratch on a single GPU in a few … - [Distributed Training, FSDP, DeepSpeed](https://aiengineeringfromscratch.com/learn/llms-from-scratch/scaling-distributed) · [raw](https://raw.githubusercontent.com/rohitg00/ai-engineering-from-scratch/main/phases/10-llms-from-scratch/05-scaling-distributed/docs/en.md) — Your 124M model trained on one GPU. Now try 7 billion parameters. The model doesn't fit in memory. The data takes weeks on a single machine. Distributed training isn't optional … - [Instruction Tuning — SFT](https://aiengineeringfromscratch.com/learn/llms-from-scratch/instruction-tuning-sft) · [raw](https://raw.githubusercontent.com/rohitg00/ai-engineering-from-scratch/main/phases/10-llms-from-scratch/06-instruction-tuning-sft/docs/en.md) — A base model predicts the next token. That's it. It doesn't follow instructions, answer questions, or refuse harmful requests. SFT is the bridge between a token predictor and a … - [RLHF — Reward Model + PPO](https://aiengineeringfromscratch.com/learn/llms-from-scratch/rlhf) · [raw](https://raw.githubusercontent.com/rohitg00/ai-engineering-from-scratch/main/phases/10-llms-from-scratch/07-rlhf/docs/en.md) — SFT teaches the model to follow instructions. But it doesn't teach the model which response is BETTER. Two grammatically correct, factually accurate answers can differ enormousl… - [DPO — Direct Preference Optimization](https://aiengineeringfromscratch.com/learn/llms-from-scratch/dpo) · [raw](https://raw.githubusercontent.com/rohitg00/ai-engineering-from-scratch/main/phases/10-llms-from-scratch/08-dpo/docs/en.md) — RLHF works. It also requires training three models (SFT, reward model, policy), managing PPO's instability, and tuning a KL penalty. DPO asks: what if you could skip all of that… - [Constitutional AI & Self-Improvement](https://aiengineeringfromscratch.com/learn/llms-from-scratch/constitutional-ai-self-improvement) · [raw](https://raw.githubusercontent.com/rohitg00/ai-engineering-from-scratch/main/phases/10-llms-from-scratch/09-constitutional-ai-self-improvement/docs/en.md) — RLHF needs humans in the loop. Constitutional AI replaces most of them with the model itself. Write a list of principles, have the model critique its own outputs against those p… - [Evaluation — Benchmarks, Evals](https://aiengineeringfromscratch.com/learn/llms-from-scratch/evaluation) · [raw](https://raw.githubusercontent.com/rohitg00/ai-engineering-from-scratch/main/phases/10-llms-from-scratch/10-evaluation/docs/en.md) — Goodhart's Law: when a measure becomes a target, it ceases to be a good measure. Every frontier lab games benchmarks. MMLU scores go up while models still can't reliably count t… - [Quantization: INT8, GPTQ, AWQ, GGUF](https://aiengineeringfromscratch.com/learn/llms-from-scratch/quantization) · [raw](https://raw.githubusercontent.com/rohitg00/ai-engineering-from-scratch/main/phases/10-llms-from-scratch/11-quantization/docs/en.md) — A 70B model in FP16 needs 140GB. Two A100s just for weights. Quantize to FP8: one 80GB GPU. INT4: a MacBook. - [Inference Optimization](https://aiengineeringfromscratch.com/learn/llms-from-scratch/inference-optimization) · [raw](https://raw.githubusercontent.com/rohitg00/ai-engineering-from-scratch/main/phases/10-llms-from-scratch/12-inference-optimization/docs/en.md) — Two phases define LLM inference. Prefill processes your prompt in parallel -- compute-bound. Decode generates tokens one at a time -- memory-bound. Every optimization targets on… - [Building a Complete LLM Pipeline](https://aiengineeringfromscratch.com/learn/llms-from-scratch/building-complete-llm-pipeline) · [raw](https://raw.githubusercontent.com/rohitg00/ai-engineering-from-scratch/main/phases/10-llms-from-scratch/13-building-complete-llm-pipeline/docs/en.md) — Everything from Lessons 01 to 12 is one stage of one pipeline. This lesson is the scaffold that turns those stages into a single end-to-end run: tokenize, pre-train, scale, SFT,… - [Open Models: Architecture Walkthroughs](https://aiengineeringfromscratch.com/learn/llms-from-scratch/open-models-architecture-walkthroughs) · [raw](https://raw.githubusercontent.com/rohitg00/ai-engineering-from-scratch/main/phases/10-llms-from-scratch/14-open-models-architecture-walkthroughs/docs/en.md) — You built a GPT-2 Small from scratch in Lesson 04. Frontier open models in 2026 are the same family with five or six concrete changes. RMSNorm instead of LayerNorm. SwiGLU inste… - [Speculative Decoding and EAGLE-3](https://aiengineeringfromscratch.com/learn/llms-from-scratch/speculative-decoding-eagle3) · [raw](https://raw.githubusercontent.com/rohitg00/ai-engineering-from-scratch/main/phases/10-llms-from-scratch/15-speculative-decoding-eagle3/docs/en.md) — Phase 7 · Lesson 16 proved the math: the Leviathan rejection rule preserves the verifier's distribution exactly. This lesson is the training-stack view of 2026 production specul… - [Differential Attention (V2)](https://aiengineeringfromscratch.com/learn/llms-from-scratch/differential-attention-v2) · [raw](https://raw.githubusercontent.com/rohitg00/ai-engineering-from-scratch/main/phases/10-llms-from-scratch/16-differential-attention-v2/docs/en.md) — Softmax attention spreads a small amount of probability over every non-matching token. Over 100k tokens that noise adds up and drowns the signal. Differential Transformer (Ye et… - [Native Sparse Attention (DeepSeek NSA)](https://aiengineeringfromscratch.com/learn/llms-from-scratch/native-sparse-attention) · [raw](https://raw.githubusercontent.com/rohitg00/ai-engineering-from-scratch/main/phases/10-llms-from-scratch/17-native-sparse-attention/docs/en.md) — At 64k tokens, attention eats 70-80% of decode latency. Every open-model lab has a plan to fix it. DeepSeek's NSA (ACL 2025 best paper) is the one that stuck: three parallel att… - [Multi-Token Prediction (MTP)](https://aiengineeringfromscratch.com/learn/llms-from-scratch/multi-token-prediction) · [raw](https://raw.githubusercontent.com/rohitg00/ai-engineering-from-scratch/main/phases/10-llms-from-scratch/18-multi-token-prediction/docs/en.md) — Every autoregressive LLM from GPT-2 to Llama 3 trains on one loss per position: predict the next token. DeepSeek-V3 added a second loss per position: predict the token after tha… - [DualPipe Parallelism](https://aiengineeringfromscratch.com/learn/llms-from-scratch/dualpipe-parallelism) · [raw](https://raw.githubusercontent.com/rohitg00/ai-engineering-from-scratch/main/phases/10-llms-from-scratch/19-dualpipe-parallelism/docs/en.md) — DeepSeek-V3 was trained on 2,048 H800 GPUs with MoE experts scattered across nodes. Cross-node expert all-to-all communication cost 1 GPU-hour of comm for every 1 GPU-hour of co… - [DeepSeek-V3 Architecture Walkthrough](https://aiengineeringfromscratch.com/learn/llms-from-scratch/deepseek-v3-walkthrough) · [raw](https://raw.githubusercontent.com/rohitg00/ai-engineering-from-scratch/main/phases/10-llms-from-scratch/20-deepseek-v3-walkthrough/docs/en.md) — Phase 10 · Lesson 14 named the six architectural knobs every open model turns. DeepSeek-V3 (December 2024, 671B parameters total, 37B active) turns all six and adds four more: M… - [Jamba — Hybrid SSM-Transformer](https://aiengineeringfromscratch.com/learn/llms-from-scratch/jamba-hybrid-ssm-transformer) · [raw](https://raw.githubusercontent.com/rohitg00/ai-engineering-from-scratch/main/phases/10-llms-from-scratch/21-jamba-hybrid-ssm-transformer/docs/en.md) — State space models (SSMs) and transformers want different things. Transformers buy quality via attention at quadratic cost. SSMs buy linear-time inference and constant memory vi… - [Async and Hogwild! Inference](https://aiengineeringfromscratch.com/learn/llms-from-scratch/async-hogwild-inference) · [raw](https://raw.githubusercontent.com/rohitg00/ai-engineering-from-scratch/main/phases/10-llms-from-scratch/22-async-hogwild-inference/docs/en.md) — Speculative decoding (Phase 10 · 15) parallelizes tokens within one sequence. Multi-agent frameworks parallelize across whole sequences but force explicit coordination (voting, … - [Speculative Decoding and EAGLE](https://aiengineeringfromscratch.com/learn/llms-from-scratch/speculative-decoding) · [raw](https://raw.githubusercontent.com/rohitg00/ai-engineering-from-scratch/main/phases/10-llms-from-scratch/25-speculative-decoding/docs/en.md) — A frontier LLM generating one token requires a full forward pass over billions of parameters. That forward pass is massively over-provisioned: most of the time a much smaller mo… - [Gradient Checkpointing and Activation Recomputation](https://aiengineeringfromscratch.com/learn/llms-from-scratch/gradient-checkpointing) · [raw](https://raw.githubusercontent.com/rohitg00/ai-engineering-from-scratch/main/phases/10-llms-from-scratch/34-gradient-checkpointing/docs/en.md) — Backprop keeps every intermediate activation. At 70B parameters and 128K context that is 3 TB of activations per rank. Checkpointing trades FLOPs for memory: recompute instead o… ## Phase 11: LLM Engineering Put LLMs to work in production. - [Prompt Engineering: Techniques & Patterns](https://aiengineeringfromscratch.com/learn/llm-engineering/prompt-engineering) · [raw](https://raw.githubusercontent.com/rohitg00/ai-engineering-from-scratch/main/phases/11-llm-engineering/01-prompt-engineering/docs/en.md) — Most people write prompts like they are texting a friend. Then they wonder why a 200-billion parameter model gives mediocre answers. Prompt engineering is not about tricks. It i… - [Few-Shot, CoT, Tree-of-Thought](https://aiengineeringfromscratch.com/learn/llm-engineering/few-shot-cot) · [raw](https://raw.githubusercontent.com/rohitg00/ai-engineering-from-scratch/main/phases/11-llm-engineering/02-few-shot-cot/docs/en.md) — Telling a model what to do is prompting. Showing it how to think is engineering. The gap between 78% and 91% accuracy on the same model, same task, same data is not a better mod… - [Structured Outputs](https://aiengineeringfromscratch.com/learn/llm-engineering/structured-outputs) · [raw](https://raw.githubusercontent.com/rohitg00/ai-engineering-from-scratch/main/phases/11-llm-engineering/03-structured-outputs/docs/en.md) — Your LLM returns a string. Your application needs JSON. That gap has crashed more production systems than any model hallucination. Structured output is the bridge between natura… - [Embeddings & Vector Representations](https://aiengineeringfromscratch.com/learn/llm-engineering/embeddings) · [raw](https://raw.githubusercontent.com/rohitg00/ai-engineering-from-scratch/main/phases/11-llm-engineering/04-embeddings/docs/en.md) — Text is discrete. Math is continuous. Every time you ask an LLM to find "similar" documents, compare meanings, or search beyond keywords, you're relying on a bridge between thes… - [Context Engineering](https://aiengineeringfromscratch.com/learn/llm-engineering/context-engineering) · [raw](https://raw.githubusercontent.com/rohitg00/ai-engineering-from-scratch/main/phases/11-llm-engineering/05-context-engineering/docs/en.md) — Prompt engineering is a subset. Context engineering is the whole game. A prompt is a string you type. Context is everything that goes into the model's window: system instruction… - [RAG: Retrieval-Augmented Generation](https://aiengineeringfromscratch.com/learn/llm-engineering/rag) · [raw](https://raw.githubusercontent.com/rohitg00/ai-engineering-from-scratch/main/phases/11-llm-engineering/06-rag/docs/en.md) — Your LLM knows everything up to its training cutoff. It knows nothing about your company's docs, your codebase, or last week's meeting notes. RAG solves this by retrieving relev… - [Advanced RAG: Chunking, Reranking](https://aiengineeringfromscratch.com/learn/llm-engineering/advanced-rag) · [raw](https://raw.githubusercontent.com/rohitg00/ai-engineering-from-scratch/main/phases/11-llm-engineering/07-advanced-rag/docs/en.md) — Basic RAG retrieves the top-k most similar chunks. That works for simple questions. It falls apart for multi-hop reasoning, ambiguous queries, and large corpora. Advanced RAG is… - [Fine-Tuning with LoRA & QLoRA](https://aiengineeringfromscratch.com/learn/llm-engineering/fine-tuning-lora) · [raw](https://raw.githubusercontent.com/rohitg00/ai-engineering-from-scratch/main/phases/11-llm-engineering/08-fine-tuning-lora/docs/en.md) — Full fine-tuning a 7B model requires 56GB of VRAM. You don't have that. Neither do most companies. LoRA lets you fine-tune the same model in 6GB by training less than 1% of the … - [Function Calling & Tool Use](https://aiengineeringfromscratch.com/learn/llm-engineering/function-calling) · [raw](https://raw.githubusercontent.com/rohitg00/ai-engineering-from-scratch/main/phases/11-llm-engineering/09-function-calling/docs/en.md) — LLMs cannot do anything. They generate text. That is the entire capability. They cannot check the weather, query a database, send an email, run code, or read a file. Every "AI a… - [Evaluation & Testing](https://aiengineeringfromscratch.com/learn/llm-engineering/evaluation) · [raw](https://raw.githubusercontent.com/rohitg00/ai-engineering-from-scratch/main/phases/11-llm-engineering/10-evaluation/docs/en.md) — You would never deploy a web app without tests. You would never ship a database migration without a rollback plan. But right now, most teams ship LLM applications by reading 10 … - [Caching, Rate Limiting & Cost](https://aiengineeringfromscratch.com/learn/llm-engineering/caching-cost) · [raw](https://raw.githubusercontent.com/rohitg00/ai-engineering-from-scratch/main/phases/11-llm-engineering/11-caching-cost/docs/en.md) — Most AI startups do not die from bad models. They die from bad unit economics. A single GPT-4o call costs fractions of a cent. Ten thousand users making ten calls per day costs … - [Guardrails & Safety](https://aiengineeringfromscratch.com/learn/llm-engineering/guardrails) · [raw](https://raw.githubusercontent.com/rohitg00/ai-engineering-from-scratch/main/phases/11-llm-engineering/12-guardrails/docs/en.md) — Your LLM application will be attacked. Not might. Will. The first prompt injection attempt against your production system will come within 48 hours of launch. The question is no… - [Building a Production LLM App](https://aiengineeringfromscratch.com/learn/llm-engineering/production-app) · [raw](https://raw.githubusercontent.com/rohitg00/ai-engineering-from-scratch/main/phases/11-llm-engineering/13-production-app/docs/en.md) — You have built prompts, embeddings, RAG pipelines, function calling, caching layers, and guardrails. Separately. In isolation. Like practicing guitar scales without ever playing… - [Model Context Protocol (MCP)](https://aiengineeringfromscratch.com/learn/llm-engineering/model-context-protocol) · [raw](https://raw.githubusercontent.com/rohitg00/ai-engineering-from-scratch/main/phases/11-llm-engineering/14-model-context-protocol/docs/en.md) — MCP gives an AI host one protocol for discovering and invoking tools, resources, and prompts. The 2026-07-28 revision makes that protocol stateless: capability and version conte… - [Prompt Caching & Context Caching](https://aiengineeringfromscratch.com/learn/llm-engineering/prompt-caching) · [raw](https://raw.githubusercontent.com/rohitg00/ai-engineering-from-scratch/main/phases/11-llm-engineering/15-prompt-caching/docs/en.md) — Your system prompt is 4,000 tokens. Your RAG context is 20,000 tokens. You send both with every request. You also pay for both — every time. Prompt caching lets the provider kee… - [Agent State Machines — Graphs, Nodes, Checkpoints](https://aiengineeringfromscratch.com/learn/llm-engineering/langgraph-state-machines) · [raw](https://raw.githubusercontent.com/rohitg00/ai-engineering-from-scratch/main/phases/11-llm-engineering/16-langgraph-state-machines/docs/en.md) — A ReAct loop written by hand is a `while True`. The same loop written as an explicit graph is something you can checkpoint, interrupt, branch, and time-travel through. The agent… - [Agent Framework Tradeoffs](https://aiengineeringfromscratch.com/learn/llm-engineering/agent-framework-tradeoffs) · [raw](https://raw.githubusercontent.com/rohitg00/ai-engineering-from-scratch/main/phases/11-llm-engineering/17-agent-framework-tradeoffs/docs/en.md) — Every framework sells the same demo (research agent builds a report) and hides the same bug (state schema fights with the orchestration layer). Pick the framework whose abstract… ## Phase 12: Multimodal AI See, hear, read, and reason across modalities — from ViT patches to computer-use agents. - [Vision Transformers and the Patch-Token Primitive](https://aiengineeringfromscratch.com/learn/multimodal-ai/vision-transformer-patch-tokens) · [raw](https://raw.githubusercontent.com/rohitg00/ai-engineering-from-scratch/main/phases/12-multimodal-ai/01-vision-transformer-patch-tokens/docs/en.md) — Before anything multimodal, an image has to become a sequence of tokens a transformer can eat. The 2020 ViT paper answered this with 16x16 pixel patches, a linear projection, an… - [CLIP and Contrastive Vision-Language Pretraining](https://aiengineeringfromscratch.com/learn/multimodal-ai/clip-contrastive-pretraining) · [raw](https://raw.githubusercontent.com/rohitg00/ai-engineering-from-scratch/main/phases/12-multimodal-ai/02-clip-contrastive-pretraining/docs/en.md) — OpenAI's CLIP (2021) proved a single idea big enough to power the next five years: align an image encoder and a text encoder in the same vector space using only noisy web image-… - [BLIP-2 Q-Former as Modality Bridge](https://aiengineeringfromscratch.com/learn/multimodal-ai/blip2-qformer-bridge) · [raw](https://raw.githubusercontent.com/rohitg00/ai-engineering-from-scratch/main/phases/12-multimodal-ai/03-blip2-qformer-bridge/docs/en.md) — CLIP aligns image and text but cannot generate captions, answer questions, or hold a conversation. BLIP-2 (Salesforce, 2023) solved that with a small trainable bridge: 32 learna… - [Flamingo and Gated Cross-Attention](https://aiengineeringfromscratch.com/learn/multimodal-ai/flamingo-gated-cross-attention) · [raw](https://raw.githubusercontent.com/rohitg00/ai-engineering-from-scratch/main/phases/12-multimodal-ai/04-flamingo-gated-cross-attention/docs/en.md) — DeepMind's Flamingo (2022) did two things before anyone else. It showed a single model could process arbitrarily interleaved sequences of images, videos, and text. And it showed… - [LLaVA and Visual Instruction Tuning](https://aiengineeringfromscratch.com/learn/multimodal-ai/llava-visual-instruction-tuning) · [raw](https://raw.githubusercontent.com/rohitg00/ai-engineering-from-scratch/main/phases/12-multimodal-ai/05-llava-visual-instruction-tuning/docs/en.md) — LLaVA (April 2023) is the most copied multimodal architecture on the planet. It replaced BLIP-2's Q-Former with a 2-layer MLP, replaced Flamingo's gated cross-attention with nai… - [Any-Resolution Vision — Patch-n'-Pack and NaFlex](https://aiengineeringfromscratch.com/learn/multimodal-ai/any-resolution-patch-n-pack) · [raw](https://raw.githubusercontent.com/rohitg00/ai-engineering-from-scratch/main/phases/12-multimodal-ai/06-any-resolution-patch-n-pack/docs/en.md) — Real images are not 224x224 squares. A receipt is 1:3, a chart is 16:9, a medical scan might be 4096x4096, a mobile screenshot is 9:19.5. The pre-2024 VLM answer — resize everyt… - [Open-Weight VLM Recipes: What Actually Matters](https://aiengineeringfromscratch.com/learn/multimodal-ai/open-weight-vlm-recipes) · [raw](https://raw.githubusercontent.com/rohitg00/ai-engineering-from-scratch/main/phases/12-multimodal-ai/07-open-weight-vlm-recipes/docs/en.md) — The 2024-2026 open-weight VLM literature is a forest of ablation tables. Apple's MM1 tested 13 combinations of image encoder, connector, and data mix. Allen AI's Molmo proved de… - [LLaVA-OneVision: Single, Multi, Video](https://aiengineeringfromscratch.com/learn/multimodal-ai/llava-onevision-single-multi-video) · [raw](https://raw.githubusercontent.com/rohitg00/ai-engineering-from-scratch/main/phases/12-multimodal-ai/08-llava-onevision-single-multi-video/docs/en.md) — Before LLaVA-OneVision (Li et al., August 2024) the open-VLM world had separate lineages: LLaVA-1.5 for single images, multi-image models like Mantis and VILA, video models like… - [Qwen-VL Family and Dynamic-FPS Video](https://aiengineeringfromscratch.com/learn/multimodal-ai/qwen-vl-family-dynamic-fps) · [raw](https://raw.githubusercontent.com/rohitg00/ai-engineering-from-scratch/main/phases/12-multimodal-ai/09-qwen-vl-family-dynamic-fps/docs/en.md) — The Qwen-VL family — Qwen-VL (2023), Qwen2-VL (2024), Qwen2.5-VL (2025), Qwen3-VL (2025) — is the most influential open vision-language model lineage in 2026. Each generation ma… - [InternVL3 Native Multimodal Pretraining](https://aiengineeringfromscratch.com/learn/multimodal-ai/internvl3-native-multimodal) · [raw](https://raw.githubusercontent.com/rohitg00/ai-engineering-from-scratch/main/phases/12-multimodal-ai/10-internvl3-native-multimodal/docs/en.md) — Every open VLM before InternVL3 followed the same three-step recipe: take a text LLM trained on trillions of text tokens, bolt on a vision encoder, then fine-tune the seams. Thi… - [Chameleon Early-Fusion Token-Only](https://aiengineeringfromscratch.com/learn/multimodal-ai/chameleon-early-fusion-tokens) · [raw](https://raw.githubusercontent.com/rohitg00/ai-engineering-from-scratch/main/phases/12-multimodal-ai/11-chameleon-early-fusion-tokens/docs/en.md) — Every VLM we have seen so far keeps images and text separate. Visual tokens come from a vision encoder, flow into a projector, then meet text inside the LLM. The vision and text… - [Emu3 Next-Token Prediction for Generation](https://aiengineeringfromscratch.com/learn/multimodal-ai/emu3-next-token-for-generation) · [raw](https://raw.githubusercontent.com/rohitg00/ai-engineering-from-scratch/main/phases/12-multimodal-ai/12-emu3-next-token-for-generation/docs/en.md) — BAAI's Emu3 (Wang et al., September 2024) is the 2024 result that should have ended the diffusion-versus-autoregressive debate. A single Llama-style decoder-only transformer, tr… - [Transfusion Autoregressive + Diffusion](https://aiengineeringfromscratch.com/learn/multimodal-ai/transfusion-autoregressive-diffusion) · [raw](https://raw.githubusercontent.com/rohitg00/ai-engineering-from-scratch/main/phases/12-multimodal-ai/13-transfusion-autoregressive-diffusion/docs/en.md) — Chameleon and Emu3 bet everything on discrete tokens. They work, but the quantization bottleneck is visible — the image quality plateaus below continuous-space diffusion models.… - [Show-o Discrete-Diffusion Unified](https://aiengineeringfromscratch.com/learn/multimodal-ai/show-o-discrete-diffusion-unified) · [raw](https://raw.githubusercontent.com/rohitg00/ai-engineering-from-scratch/main/phases/12-multimodal-ai/14-show-o-discrete-diffusion-unified/docs/en.md) — Transfusion mixes continuous and discrete representations. Show-o (Xie et al., August 2024) goes the other way: text tokens use causal next-token prediction, image tokens use ma… - [Janus-Pro Decoupled Encoders](https://aiengineeringfromscratch.com/learn/multimodal-ai/janus-pro-decoupled-encoders) · [raw](https://raw.githubusercontent.com/rohitg00/ai-engineering-from-scratch/main/phases/12-multimodal-ai/15-janus-pro-decoupled-encoders/docs/en.md) — Unified multimodal models have an unavoidable tension. Understanding wants semantic features — SigLIP or DINOv2 output vectors rich with concept-level information. Generation wa… - [MIO Any-to-Any Streaming](https://aiengineeringfromscratch.com/learn/multimodal-ai/mio-any-to-any-streaming) · [raw](https://raw.githubusercontent.com/rohitg00/ai-engineering-from-scratch/main/phases/12-multimodal-ai/16-mio-any-to-any-streaming/docs/en.md) — GPT-4o ships a product most open models cannot replicate: an agent that hears voice, sees video, and speaks back in real time. The open-ecosystem answer by late 2024 was MIO (Wa… - [Video-Language Temporal Grounding](https://aiengineeringfromscratch.com/learn/multimodal-ai/video-language-temporal-grounding) · [raw](https://raw.githubusercontent.com/rohitg00/ai-engineering-from-scratch/main/phases/12-multimodal-ai/17-video-language-temporal-grounding/docs/en.md) — Video is not a stack of photos. A 5-second clip has causal ordering, action verbs, and event timing that an image model cannot represent. Video-LLaMA (Zhang et al., June 2023) s… - [Long-Video at Million-Token Context](https://aiengineeringfromscratch.com/learn/multimodal-ai/long-video-million-token) · [raw](https://raw.githubusercontent.com/rohitg00/ai-engineering-from-scratch/main/phases/12-multimodal-ai/18-long-video-million-token/docs/en.md) — A 1-hour 4K video at 24 FPS, patched and embedded, produces on the order of 60 million tokens. A 2-hour podcast episode transcribed is 30,000 tokens. A full Blu-ray feature film… - [Audio-Language Models: Whisper to AF3](https://aiengineeringfromscratch.com/learn/multimodal-ai/audio-language-whisper-to-af3) · [raw](https://raw.githubusercontent.com/rohitg00/ai-engineering-from-scratch/main/phases/12-multimodal-ai/19-audio-language-whisper-to-af3/docs/en.md) — Whisper (Radford et al., December 2022) settled speech recognition — 680k hours of weakly-supervised multilingual speech, a simple encoder-decoder transformer, a benchmark that … - [Omni Models: Thinker-Talker Streaming](https://aiengineeringfromscratch.com/learn/multimodal-ai/omni-models-thinker-talker) · [raw](https://raw.githubusercontent.com/rohitg00/ai-engineering-from-scratch/main/phases/12-multimodal-ai/20-omni-models-thinker-talker/docs/en.md) — GPT-4o's product demo in May 2024 was disruptive not because of the underlying model but because of the product shape — a voice interface where you talk, the model sees what the… - [Embodied VLAs: RT-2, OpenVLA, π0, GR00T](https://aiengineeringfromscratch.com/learn/multimodal-ai/embodied-vlas-openvla-pi0-groot) · [raw](https://raw.githubusercontent.com/rohitg00/ai-engineering-from-scratch/main/phases/12-multimodal-ai/21-embodied-vlas-openvla-pi0-groot/docs/en.md) — The first time a model read a recipe off a website and executed it in a kitchen robot was RT-2 (Google DeepMind, July 2023). RT-2 discretized actions as text tokens, co-fine-tun… - [Document and Diagram Understanding](https://aiengineeringfromscratch.com/learn/multimodal-ai/document-diagram-understanding) · [raw](https://raw.githubusercontent.com/rohitg00/ai-engineering-from-scratch/main/phases/12-multimodal-ai/22-document-diagram-understanding/docs/en.md) — Documents are not photos. A PDF, scientific paper, invoice, or handwritten form has layout, tables, diagrams, footnotes, headers, and semantic structure that plain image underst… - [ColPali Vision-Native Document RAG](https://aiengineeringfromscratch.com/learn/multimodal-ai/colpali-vision-native-rag) · [raw](https://raw.githubusercontent.com/rohitg00/ai-engineering-from-scratch/main/phases/12-multimodal-ai/23-colpali-vision-native-rag/docs/en.md) — Traditional RAG parses PDFs into text, splits into chunks, embeds chunks, stores vectors. Every step loses signal: OCR drops chart data, chunking breaks table rows, text embeddi… - [Multimodal RAG and Cross-Modal Retrieval](https://aiengineeringfromscratch.com/learn/multimodal-ai/multimodal-rag-cross-modal) · [raw](https://raw.githubusercontent.com/rohitg00/ai-engineering-from-scratch/main/phases/12-multimodal-ai/24-multimodal-rag-cross-modal/docs/en.md) — Vision-native document RAG is one slice. Production multimodal RAG goes wider — retrieving across text, images, audio, and video for workflows like trip planning ("find me a qui… - [Multimodal Agents and Computer-Use (Capstone)](https://aiengineeringfromscratch.com/learn/multimodal-ai/multimodal-agents-computer-use) · [raw](https://raw.githubusercontent.com/rohitg00/ai-engineering-from-scratch/main/phases/12-multimodal-ai/25-multimodal-agents-computer-use/docs/en.md) — The 2026 frontier product is a multimodal agent that reads screenshots, clicks buttons, navigates web UIs, fills forms, and completes workflows end-to-end. SeeClick and CogAgent… ## Phase 13: Tools & Protocols The interfaces between AI and the real world. - [The Tool Interface](https://aiengineeringfromscratch.com/learn/tools-and-protocols/the-tool-interface) · [raw](https://raw.githubusercontent.com/rohitg00/ai-engineering-from-scratch/main/phases/13-tools-and-protocols/01-the-tool-interface/docs/en.md) — A language model produces tokens. A program takes actions. The gap between those two is the tool interface: a contract that lets the model request an action and the host execute… - [Function Calling Deep Dive](https://aiengineeringfromscratch.com/learn/tools-and-protocols/function-calling-deep-dive) · [raw](https://raw.githubusercontent.com/rohitg00/ai-engineering-from-scratch/main/phases/13-tools-and-protocols/02-function-calling-deep-dive/docs/en.md) — The three frontier providers converged on the same tool-call loop in 2024 and then diverged on everything else. OpenAI uses `tools` and `tool_calls`. Anthropic uses `tool_use` a… - [Parallel and Streaming Tool Calls](https://aiengineeringfromscratch.com/learn/tools-and-protocols/parallel-and-streaming-tool-calls) · [raw](https://raw.githubusercontent.com/rohitg00/ai-engineering-from-scratch/main/phases/13-tools-and-protocols/03-parallel-and-streaming-tool-calls/docs/en.md) — Three independent weather lookups serialized is three round trips. Run them in parallel and total time collapses to the slowest single call. Every frontier provider now emits mu… - [Structured Output](https://aiengineeringfromscratch.com/learn/tools-and-protocols/structured-output) · [raw](https://raw.githubusercontent.com/rohitg00/ai-engineering-from-scratch/main/phases/13-tools-and-protocols/04-structured-output/docs/en.md) — "Ask the model nicely to return JSON" fails 5 to 15 percent of the time, even on frontier models. Structured outputs close that gap with constrained decoding: the model is liter… - [Tool Schema Design](https://aiengineeringfromscratch.com/learn/tools-and-protocols/tool-schema-design) · [raw](https://raw.githubusercontent.com/rohitg00/ai-engineering-from-scratch/main/phases/13-tools-and-protocols/05-tool-schema-design/docs/en.md) — A correct tool fails silently when the model cannot tell when to use it. Naming, descriptions, and parameter shapes drive 10 to 20 percentage-point swings in tool-selection accu… - [MCP Fundamentals: Stateless Requests and JSON-RPC](https://aiengineeringfromscratch.com/learn/tools-and-protocols/mcp-fundamentals) · [raw](https://raw.githubusercontent.com/rohitg00/ai-engineering-from-scratch/main/phases/13-tools-and-protocols/06-mcp-fundamentals/docs/en.md) — Modern MCP has no handshake and no protocol session. Each request must carry enough metadata to be understood, authorized, routed, and retried on its own. - [Building an MCP Server: Stateless Python and TypeScript](https://aiengineeringfromscratch.com/learn/tools-and-protocols/building-an-mcp-server) · [raw](https://raw.githubusercontent.com/rohitg00/ai-engineering-from-scratch/main/phases/13-tools-and-protocols/07-building-an-mcp-server/docs/en.md) — A modern MCP server does not remember a handshake. It validates the metadata on every request, runs one handler, and returns one typed result. - [Building an MCP Client: Discovery, Routing, and Dual-Era Fallback](https://aiengineeringfromscratch.com/learn/tools-and-protocols/building-an-mcp-client) · [raw](https://raw.githubusercontent.com/rohitg00/ai-engineering-from-scratch/main/phases/13-tools-and-protocols/08-building-an-mcp-client/docs/en.md) — A modern MCP client repeats its contract on every request. Its hardest compatibility decision is knowing when an old server is truly old and when a modern server is reporting a … - [MCP Transports: stdio and Stateless Streamable HTTP](https://aiengineeringfromscratch.com/learn/tools-and-protocols/mcp-transports) · [raw](https://raw.githubusercontent.com/rohitg00/ai-engineering-from-scratch/main/phases/13-tools-and-protocols/09-mcp-transports/docs/en.md) — Transport carries MCP messages. It does not supply missing protocol state. In `2026-07-28`, local stdio and remote Streamable HTTP both carry self-describing requests. - [MCP Resources and Prompts: Addressable Context for Stateless Servers](https://aiengineeringfromscratch.com/learn/tools-and-protocols/mcp-resources-and-prompts) · [raw](https://raw.githubusercontent.com/rohitg00/ai-engineering-from-scratch/main/phases/13-tools-and-protocols/10-mcp-resources-and-prompts/docs/en.md) — Tools perform operations. Resources expose addressable content. Prompts package user-selected message templates. A good MCP server keeps those contracts separate and predictable. - [MCP Model Input: Sampling Migration and Stateless MRTR](https://aiengineeringfromscratch.com/learn/tools-and-protocols/mcp-sampling) · [raw](https://raw.githubusercontent.com/rohitg00/ai-engineering-from-scratch/main/phases/13-tools-and-protocols/11-mcp-sampling/docs/en.md) — MCP 2026-07-28 deprecates Sampling for new designs and removes the server-to-client request channel. If an existing workflow still needs the client's model, the server returns a… - [Explicit Scope and Stateless Elicitation](https://aiengineeringfromscratch.com/learn/tools-and-protocols/mcp-roots-and-elicitation) · [raw](https://raw.githubusercontent.com/rohitg00/ai-engineering-from-scratch/main/phases/13-tools-and-protocols/12-mcp-roots-and-elicitation/docs/en.md) — Roots are deprecated in MCP 2026-07-28 and were never a security sandbox. Put scope in visible tool arguments or resource URIs, authorize it on the server, and use MRTR when a t… - [MCP Tasks Extension: Durable Work on a Stateless Core](https://aiengineeringfromscratch.com/learn/tools-and-protocols/mcp-async-tasks) · [raw](https://raw.githubusercontent.com/rohitg00/ai-engineering-from-scratch/main/phases/13-tools-and-protocols/13-mcp-async-tasks/docs/en.md) — Stateless MCP does not mean every operation must finish in one request. The official Tasks extension gives long-running work an explicit durable handle. A server can return that… - [MCP Apps on the Stateless Protocol](https://aiengineeringfromscratch.com/learn/tools-and-protocols/mcp-apps) · [raw](https://raw.githubusercontent.com/rohitg00/ai-engineering-from-scratch/main/phases/13-tools-and-protocols/14-mcp-apps/docs/en.md) — An interactive result is still an MCP tool and resource exchange. The 2026-07-28 core makes that exchange self-contained, while the Apps extension adds the sandboxed browser sur… - [MCP Security: Poisoned Metadata, Routing, and MRTR State](https://aiengineeringfromscratch.com/learn/tools-and-protocols/mcp-security-tool-poisoning) · [raw](https://raw.githubusercontent.com/rohitg00/ai-engineering-from-scratch/main/phases/13-tools-and-protocols/15-mcp-security-tool-poisoning/docs/en.md) — Stateless does not mean trustless. It means every request exposes the evidence a server and gateway need to validate the call independently. - [MCP Authorization: CIMD, Issuer Binding, PKCE, and Step-Up](https://aiengineeringfromscratch.com/learn/tools-and-protocols/mcp-security-oauth-2-1) · [raw](https://raw.githubusercontent.com/rohitg00/ai-engineering-from-scratch/main/phases/13-tools-and-protocols/16-mcp-security-oauth-2-1/docs/en.md) — A remote MCP request is stateless, but its authorization is not anonymous. Bind every credential to the issuer that created it and every token to the resource that receives it. - [Stateless MCP Gateways and Registry Admission](https://aiengineeringfromscratch.com/learn/tools-and-protocols/mcp-gateways-and-registries) · [raw](https://raw.githubusercontent.com/rohitg00/ai-engineering-from-scratch/main/phases/13-tools-and-protocols/17-mcp-gateways-and-registries/docs/en.md) — A gateway should make every route explicit. The 2026-07-28 protocol gives it method, name, version, capability, identity, cache, and trace boundaries without a transport session. - [MCP Auth in Production: Issuer-Bound Enrollment and Tokens](https://aiengineeringfromscratch.com/learn/tools-and-protocols/mcp-auth-production) · [raw](https://raw.githubusercontent.com/rohitg00/ai-engineering-from-scratch/main/phases/13-tools-and-protocols/18-mcp-auth-production/docs/en.md) — Lesson 16 built the OAuth 2.1 state machine. This lesson hardens its production boundaries for MCP 2026-07-28: Client ID Metadata Documents first, deprecated dynamic registratio… - [A2A Protocol](https://aiengineeringfromscratch.com/learn/tools-and-protocols/a2a-protocol) · [raw](https://raw.githubusercontent.com/rohitg00/ai-engineering-from-scratch/main/phases/13-tools-and-protocols/19-a2a-protocol/docs/en.md) — MCP is agent-to-tool. A2A (Agent2Agent) is agent-to-agent — an open protocol for letting opaque agents built on different frameworks collaborate. Released by Google in April 202… - [OpenTelemetry GenAI](https://aiengineeringfromscratch.com/learn/tools-and-protocols/opentelemetry-genai) · [raw](https://raw.githubusercontent.com/rohitg00/ai-engineering-from-scratch/main/phases/13-tools-and-protocols/20-opentelemetry-genai/docs/en.md) — An agent calls five tools, three MCP servers, and two sub-agents. You need one trace across all of it. The OpenTelemetry GenAI semantic conventions (stable attributes in v1.37 a… - [LLM Routing Layer](https://aiengineeringfromscratch.com/learn/tools-and-protocols/llm-routing-layer) · [raw](https://raw.githubusercontent.com/rohitg00/ai-engineering-from-scratch/main/phases/13-tools-and-protocols/21-llm-routing-layer/docs/en.md) — Provider lock-in is expensive. Different tool-calling workloads suit different models. Routing gateways give one API surface, retries, failover, cost tracking, and guardrails. T… - [Agent Skills: Portable Contract and Runtime Boundary](https://aiengineeringfromscratch.com/learn/tools-and-protocols/skills-and-agent-sdks) · [raw](https://raw.githubusercontent.com/rohitg00/ai-engineering-from-scratch/main/phases/13-tools-and-protocols/22-skills-and-agent-sdks/docs/en.md) — A skill is not a long prompt with a better filename. It is a discoverable package of instructions, resources, and executable helpers that enters an agent's context through a run… - [Capstone: Stateless Tool Ecosystem](https://aiengineeringfromscratch.com/learn/tools-and-protocols/capstone-tool-ecosystem) · [raw](https://raw.githubusercontent.com/rohitg00/ai-engineering-from-scratch/main/phases/13-tools-and-protocols/23-capstone-tool-ecosystem/docs/en.md) — A production agent system is a set of boundaries, not a pile of features. This capstone separates a readable in-process simulation from the protocol clients, authorization serve… - [Skill Discovery and Progressive Disclosure](https://aiengineeringfromscratch.com/learn/tools-and-protocols/skill-discovery-and-progressive-disclosure) · [raw](https://raw.githubusercontent.com/rohitg00/ai-engineering-from-scratch/main/phases/13-tools-and-protocols/24-skill-discovery-and-progressive-disclosure/docs/en.md) — A skill becomes useful before its body is loaded. Its name and description earn a place in the catalog; its deeper files earn context only when the task reaches them. - [Skill Invocation and Routing](https://aiengineeringfromscratch.com/learn/tools-and-protocols/skill-invocation-and-routing) · [raw](https://raw.githubusercontent.com/rohitg00/ai-engineering-from-scratch/main/phases/13-tools-and-protocols/25-skill-invocation-and-routing/docs/en.md) — Invocation is an authority decision followed by a relevance decision. A good description helps the model choose; a good policy decides whether that choice is allowed. - [Skill Permissions, Sandboxes, and Trust](https://aiengineeringfromscratch.com/learn/tools-and-protocols/skill-permissions-sandboxes-and-trust) · [raw](https://raw.githubusercontent.com/rohitg00/ai-engineering-from-scratch/main/phases/13-tools-and-protocols/26-skill-permissions-sandboxes-and-trust/docs/en.md) — A skill can suggest an action. Only the host can authorize it, only an isolation boundary can contain it, and only verification can tell you whether it worked. - [Skill Evals, Packaging, and Portability](https://aiengineeringfromscratch.com/learn/tools-and-protocols/skill-evals-packaging-and-portability) · [raw](https://raw.githubusercontent.com/rohitg00/ai-engineering-from-scratch/main/phases/13-tools-and-protocols/27-skill-evals-packaging-and-portability/docs/en.md) — A skill is finished when its package survives linting, routes on the right requests, improves a measured task, stays inside policy, and degrades honestly on another host. - [MCP Tool Contracts and Content](https://aiengineeringfromscratch.com/learn/tools-and-protocols/mcp-tool-contracts-and-content) · [raw](https://raw.githubusercontent.com/rohitg00/ai-engineering-from-scratch/main/phases/13-tools-and-protocols/28-mcp-tool-contracts-and-content/docs/en.md) — A tool is safe to automate only when discovery, arguments, results, pagination, and transport metadata agree on one contract. - [MCP Reliability, Cancellation, and Flow Control](https://aiengineeringfromscratch.com/learn/tools-and-protocols/mcp-reliability-cancellation-and-flow-control) · [raw](https://raw.githubusercontent.com/rohitg00/ai-engineering-from-scratch/main/phases/13-tools-and-protocols/29-mcp-reliability-cancellation-and-flow-control/docs/en.md) — A request ID correlates a message. It does not make a side effect safe, stop a worker, or protect a stream from a slow consumer. - [MCP Registry Supply Chain: Admission, Drift, and Rollback](https://aiengineeringfromscratch.com/learn/tools-and-protocols/mcp-registry-supply-chain-and-drift) · [raw](https://raw.githubusercontent.com/rohitg00/ai-engineering-from-scratch/main/phases/13-tools-and-protocols/30-mcp-registry-supply-chain-and-drift/docs/en.md) — A registry entry tells you what a publisher declared. Production admission proves what you fetched, what you observed, what you approved, and what you can safely restore. - [MCP Conformance Engineering: Versioning, Evidence, and Operations](https://aiengineeringfromscratch.com/learn/tools-and-protocols/mcp-conformance-versioning-and-operations) · [raw](https://raw.githubusercontent.com/rohitg00/ai-engineering-from-scratch/main/phases/13-tools-and-protocols/31-mcp-conformance-versioning-and-operations/docs/en.md) — A server is not conformant because its happy path worked through one SDK. Conformance lives at the wire, at version boundaries, through intermediaries, and during rollback. - [Program Anatomy: An ELF Reader From Scratch](https://aiengineeringfromscratch.com/learn/tools-and-protocols/program-anatomy-elf-from-scratch) · [raw](https://raw.githubusercontent.com/rohitg00/ai-engineering-from-scratch/main/phases/13-tools-and-protocols/32-program-anatomy-elf-from-scratch/docs/en.md) — A compiled program is a set of tables that point at each other. A reader you wrote gives output you can check byte by byte. - [Disassembly and Control Flow: From Bytes to a Graph You Can Check](https://aiengineeringfromscratch.com/learn/tools-and-protocols/disassembly-and-control-flow) · [raw](https://raw.githubusercontent.com/rohitg00/ai-engineering-from-scratch/main/phases/13-tools-and-protocols/33-disassembly-and-control-flow/docs/en.md) — A disassembly listing is a claim about which bytes are instructions, and this lesson builds the decoder and graph that check the claim. - [Lifting to Pseudocode: IR, SSA, and Structuring From Scratch](https://aiengineeringfromscratch.com/learn/tools-and-protocols/lifting-to-pseudocode) · [raw](https://raw.githubusercontent.com/rohitg00/ai-engineering-from-scratch/main/phases/13-tools-and-protocols/34-lifting-to-pseudocode/docs/en.md) — Decompiler output is a claim with a hidden derivation. When you build the derivation yourself, every line of that output becomes a thing you can check. - [Evidence, Confidence, and Unknowns in Binary Analysis](https://aiengineeringfromscratch.com/learn/tools-and-protocols/evidence-confidence-and-unknowns) · [raw](https://raw.githubusercontent.com/rohitg00/ai-engineering-from-scratch/main/phases/13-tools-and-protocols/35-evidence-confidence-and-unknowns/docs/en.md) — A finding about a compiled program is a record with a hash, a confidence, an authority, and a list of what it cannot show. - [Rebuild and Prove Equal: Differential Tests, Byte Comparison, and the Evidence Loop](https://aiengineeringfromscratch.com/learn/tools-and-protocols/rebuild-and-prove-equal) · [raw](https://raw.githubusercontent.com/rohitg00/ai-engineering-from-scratch/main/phases/13-tools-and-protocols/36-rebuild-and-prove-equal/docs/en.md) — Passing your tests proves agreement on your tests, so equality needs a grid that reaches every edge and bytes that match after relocation masking. - [The Reverse Engineering Landscape: History, Tool Families, and How a Decompiler Is Built](https://aiengineeringfromscratch.com/learn/tools-and-protocols/the-reverse-engineering-landscape) · [raw](https://raw.githubusercontent.com/rohitg00/ai-engineering-from-scratch/main/phases/13-tools-and-protocols/37-the-reverse-engineering-landscape/docs/en.md) — Five tools read the same object and give four addresses, three block counts, and two answers for one switch, and this lesson builds the harness that shows which is which. - [Calling Conventions and Stack Frames: System V, Windows x64, and AArch64](https://aiengineeringfromscratch.com/learn/tools-and-protocols/calling-conventions-and-stack-frames) · [raw](https://raw.githubusercontent.com/rohitg00/ai-engineering-from-scratch/main/phases/13-tools-and-protocols/38-calling-conventions-and-stack-frames/docs/en.md) — A disassembly shows which registers a function reads. Only the ABI says what those registers mean, and the ABI is chosen by the object header, so this lesson reads the header fi… - [Compiler Idioms: What Optimization Does to Your Code and How to Read It Back](https://aiengineeringfromscratch.com/learn/tools-and-protocols/compiler-idioms-and-optimization) · [raw](https://raw.githubusercontent.com/rohitg00/ai-engineering-from-scratch/main/phases/13-tools-and-protocols/39-compiler-idioms-and-optimization/docs/en.md) — An optimizing compiler replaces source constructs with cheaper instruction shapes. Each shape has a derivation, and this lesson builds the recognizer that runs the derivation ba… - [Linking, Loading, and Stripped Binaries: PLT, GOT, Imports, Fixups, and Function Identification](https://aiengineeringfromscratch.com/learn/tools-and-protocols/linking-loading-and-stripped-binaries) · [raw](https://raw.githubusercontent.com/rohitg00/ai-engineering-from-scratch/main/phases/13-tools-and-protocols/40-linking-loading-and-stripped-binaries/docs/en.md) — A linked program calls functions it does not contain. This lesson reads the tables the link editor wrote for those calls in three formats, follows one call to the slot the loade… - [Recovering Data and Types: Structs, Arrays, C++ Objects, and DWARF](https://aiengineeringfromscratch.com/learn/tools-and-protocols/recovering-data-and-types) · [raw](https://raw.githubusercontent.com/rohitg00/ai-engineering-from-scratch/main/phases/13-tools-and-protocols/41-recovering-data-and-types/docs/en.md) — A decompiler prints `a->balance` when it has a type table and `*(int *)(param_1 + 4)` when it does not. This lesson builds the table from the accesses, reads the real one from D… - [Dynamic Analysis of Your Own Program: Debuggers, Traces, and Confirming Static Claims](https://aiengineeringfromscratch.com/learn/tools-and-protocols/dynamic-analysis-of-your-own-program) · [raw](https://raw.githubusercontent.com/rohitg00/ai-engineering-from-scratch/main/phases/13-tools-and-protocols/42-dynamic-analysis-of-your-own-program/docs/en.md) — A breakpoint hit is an observation about one run of one build. This lesson builds the harness that turns those observations into confirmed, refuted, and not-observed verdicts on… - [Beyond Native Code: Python, JVM, .NET, and WebAssembly Bytecode](https://aiengineeringfromscratch.com/learn/tools-and-protocols/bytecode-and-managed-formats) · [raw](https://raw.githubusercontent.com/rohitg00/ai-engineering-from-scratch/main/phases/13-tools-and-protocols/43-bytecode-and-managed-formats/docs/en.md) — A bytecode file is a program plus the compiler's notes about it, and this lesson builds the readers that show which notes each container keeps. - [Binary Diffing and Symbolic Execution: Matching Functions and Solving for Inputs](https://aiengineeringfromscratch.com/learn/tools-and-protocols/binary-diffing-and-symbolic-execution) · [raw](https://raw.githubusercontent.com/rohitg00/ai-engineering-from-scratch/main/phases/13-tools-and-protocols/44-binary-diffing-and-symbolic-execution/docs/en.md) — A match between two functions is a claim made by one signature with one quality, and a solved input is one model of one path condition; this lesson builds both and checks them a… - [AI-Assisted Reverse Engineering: LLM Decompilers, Analysis Agents, and Ground Truth](https://aiengineeringfromscratch.com/learn/tools-and-protocols/ai-assisted-reverse-engineering) · [raw](https://raw.githubusercontent.com/rohitg00/ai-engineering-from-scratch/main/phases/13-tools-and-protocols/45-ai-assisted-reverse-engineering/docs/en.md) — A model's reconstruction is a claim with a report attached, and this lesson builds the harness that scores both against bytes, runs, and DWARF you own. ## Phase 14: Agent Engineering Build agents from first principles, use coding agents reliably, and shape the work before implementation. - [The Agent Loop](https://aiengineeringfromscratch.com/learn/agent-engineering/the-agent-loop) · [raw](https://raw.githubusercontent.com/rohitg00/ai-engineering-from-scratch/main/phases/14-agent-engineering/01-the-agent-loop/docs/en.md) — Every agent in 2026 is a variant of the ReAct loop from 2022 — Claude Code, Cursor, Devin, Operator included. Reasoning tokens interleave with tool calls and observations until … - [ReWOO and Plan-and-Execute](https://aiengineeringfromscratch.com/learn/agent-engineering/rewoo-plan-and-execute) · [raw](https://raw.githubusercontent.com/rohitg00/ai-engineering-from-scratch/main/phases/14-agent-engineering/02-rewoo-plan-and-execute/docs/en.md) — ReAct interleaves thought and action in one stream. ReWOO separates them: one big plan up front, then execute. 5x fewer tokens, +4% accuracy on HotpotQA, and you can distill the… - [Reflexion and Verbal Reinforcement Learning](https://aiengineeringfromscratch.com/learn/agent-engineering/reflexion-verbal-rl) · [raw](https://raw.githubusercontent.com/rohitg00/ai-engineering-from-scratch/main/phases/14-agent-engineering/03-reflexion-verbal-rl/docs/en.md) — Gradient-based RL needs thousands of trials and a GPU cluster to fix a failure mode. Reflexion (Shinn et al., NeurIPS 2023) does it in natural language: after each failed trial,… - [Tree of Thoughts and LATS](https://aiengineeringfromscratch.com/learn/agent-engineering/tree-of-thoughts-lats) · [raw](https://raw.githubusercontent.com/rohitg00/ai-engineering-from-scratch/main/phases/14-agent-engineering/04-tree-of-thoughts-lats/docs/en.md) — A single chain-of-thought trajectory has no room to backtrack. ToT (Yao et al., 2023) turns reasoning into a tree with self-evaluation on each node. LATS (Zhou et al., 2024) uni… - [Self-Refine and CRITIC](https://aiengineeringfromscratch.com/learn/agent-engineering/self-refine-and-critic) · [raw](https://raw.githubusercontent.com/rohitg00/ai-engineering-from-scratch/main/phases/14-agent-engineering/05-self-refine-and-critic/docs/en.md) — Self-Refine (Madaan et al., 2023) uses one LLM in three roles — generate, feedback, refine — in a loop. Average gain: +20 absolute on 7 tasks. CRITIC (Gou et al., 2023) hardens … - [Tool Use and Function Calling](https://aiengineeringfromscratch.com/learn/agent-engineering/tool-use-and-function-calling) · [raw](https://raw.githubusercontent.com/rohitg00/ai-engineering-from-scratch/main/phases/14-agent-engineering/06-tool-use-and-function-calling/docs/en.md) — Toolformer (Schick et al., 2023) started self-supervised tool annotation. Berkeley Function Calling Leaderboard V4 (Patil et al., 2025) sets the 2026 bar: 40% agentic, 30% multi… - [Agent Memory — Virtual Context and Memory Paging](https://aiengineeringfromscratch.com/learn/agent-engineering/memory-virtual-context-memgpt) · [raw](https://raw.githubusercontent.com/rohitg00/ai-engineering-from-scratch/main/phases/14-agent-engineering/07-memory-virtual-context-memgpt/docs/en.md) — Context windows are finite. Conversations, documents, and tool traces are not. The fix is OS virtual memory restated — main context is RAM, external store is disk, the agent pag… - [Memory Blocks and Sleep-Time Compute](https://aiengineeringfromscratch.com/learn/agent-engineering/memory-blocks-sleep-time-compute) · [raw](https://raw.githubusercontent.com/rohitg00/ai-engineering-from-scratch/main/phases/14-agent-engineering/08-memory-blocks-sleep-time-compute/docs/en.md) — Discrete functional memory blocks the model can edit directly, and a sleep-time agent that consolidates memory asynchronously while the primary agent is idle. These two ideas ar… - [Hybrid Memory — Vector + Graph + KV](https://aiengineeringfromscratch.com/learn/agent-engineering/hybrid-memory-mem0) · [raw](https://raw.githubusercontent.com/rohitg00/ai-engineering-from-scratch/main/phases/14-agent-engineering/09-hybrid-memory-mem0/docs/en.md) — Hybrid memory runs three stores in parallel — vector for semantic similarity, KV for fast fact lookup, graph for entity-relationship reasoning — with a scoring layer that fuses … - [Skill Libraries and Lifelong Learning (Voyager)](https://aiengineeringfromscratch.com/learn/agent-engineering/skill-libraries-voyager) · [raw](https://raw.githubusercontent.com/rohitg00/ai-engineering-from-scratch/main/phases/14-agent-engineering/10-skill-libraries-voyager/docs/en.md) — Voyager (Wang et al., TMLR 2024) treats executable code as a skill. Skills are named, retrievable, composable, and refined by environment feedback. This is the reference archite… - [Planning with HTN and Evolutionary Search](https://aiengineeringfromscratch.com/learn/agent-engineering/planning-htn-and-evolutionary) · [raw](https://raw.githubusercontent.com/rohitg00/ai-engineering-from-scratch/main/phases/14-agent-engineering/11-planning-htn-and-evolutionary/docs/en.md) — Symbolic planning handles the cases where the plan is provably correct. Evolutionary code search handles the cases where the fitness function is machine-checkable. ChatHTN (2025… - [Anthropic's Workflow Patterns](https://aiengineeringfromscratch.com/learn/agent-engineering/anthropic-workflow-patterns) · [raw](https://raw.githubusercontent.com/rohitg00/ai-engineering-from-scratch/main/phases/14-agent-engineering/12-anthropic-workflow-patterns/docs/en.md) — Schluntz and Zhang (Anthropic, Dec 2024) distinguish workflows (predefined paths) from agents (dynamic tool-use). Five workflow patterns cover most cases. Start with direct API … - [Stateful Graph Orchestration — Durable Execution and Checkpoints](https://aiengineeringfromscratch.com/learn/agent-engineering/langgraph-stateful-graphs) · [raw](https://raw.githubusercontent.com/rohitg00/ai-engineering-from-scratch/main/phases/14-agent-engineering/13-langgraph-stateful-graphs/docs/en.md) — Agent is a state machine; nodes are functions; edges are transitions; state is checkpointed after each node. Resume from any failure at the last successful checkpoint. LangGraph… - [The Actor Model for Agents](https://aiengineeringfromscratch.com/learn/agent-engineering/autogen-actor-model) · [raw](https://raw.githubusercontent.com/rohitg00/ai-engineering-from-scratch/main/phases/14-agent-engineering/14-autogen-actor-model/docs/en.md) — Agents as actors: async message exchange, event-driven handlers, fault isolation, natural concurrency. AutoGen v0.4 (Microsoft Research, Jan 2025) redesigned agent orchestration… - [Role-Based Agent Teams — Roles, Tasks, Processes](https://aiengineeringfromscratch.com/learn/agent-engineering/crewai-role-based-crews) · [raw](https://raw.githubusercontent.com/rohitg00/ai-engineering-from-scratch/main/phases/14-agent-engineering/15-crewai-role-based-crews/docs/en.md) — Four primitives: Agent, Task, Crew, Process. Two top-level shapes: Crews (autonomous, role-based collaboration) and Flows (event-driven, deterministic). CrewAI is the 2026 refer… - [OpenAI Agents SDK — Handoffs, Guardrails, Tracing](https://aiengineeringfromscratch.com/learn/agent-engineering/openai-agents-sdk) · [raw](https://raw.githubusercontent.com/rohitg00/ai-engineering-from-scratch/main/phases/14-agent-engineering/16-openai-agents-sdk/docs/en.md) — OpenAI Agents SDK is the lightweight multi-agent framework built on the Responses API. Five primitives: Agent, Handoff, Guardrail, Session, Tracing. Handoffs are tools named `tr… - [The Harness as a Library — Subagents and Session Store](https://aiengineeringfromscratch.com/learn/agent-engineering/claude-agent-sdk) · [raw](https://raw.githubusercontent.com/rohitg00/ai-engineering-from-scratch/main/phases/14-agent-engineering/17-claude-agent-sdk/docs/en.md) — A harness you can import: built-in tools, subagents for context isolation, hooks, W3C trace propagation, session persistence. The Claude Agent SDK is the reference example — the… - [Production Agent Runtimes](https://aiengineeringfromscratch.com/learn/agent-engineering/agno-and-mastra-runtimes) · [raw](https://raw.githubusercontent.com/rohitg00/ai-engineering-from-scratch/main/phases/14-agent-engineering/18-agno-and-mastra-runtimes/docs/en.md) — A production agent runtime optimizes what prototyping frameworks ignore: instantiation cost, typed workflow surfaces, and a serving-ready backend. The 2026 pairing: Agno (Python… - [Benchmarks — SWE-bench, GAIA, AgentBench](https://aiengineeringfromscratch.com/learn/agent-engineering/benchmarks-swebench-gaia) · [raw](https://raw.githubusercontent.com/rohitg00/ai-engineering-from-scratch/main/phases/14-agent-engineering/19-benchmarks-swebench-gaia/docs/en.md) — Three benchmarks anchor agent evaluation in 2026. SWE-bench tests code patching. GAIA tests generalist tool use. AgentBench tests multi-environment reasoning. Know their composi… - [Benchmarks — WebArena and OSWorld](https://aiengineeringfromscratch.com/learn/agent-engineering/benchmarks-webarena-osworld) · [raw](https://raw.githubusercontent.com/rohitg00/ai-engineering-from-scratch/main/phases/14-agent-engineering/20-benchmarks-webarena-osworld/docs/en.md) — WebArena tests web-agent capability across four self-hosted apps. OSWorld tests desktop-agent capability across Ubuntu, Windows, macOS. At release (2023–2024) both showed a big … - [Computer Use — Claude, OpenAI CUA, Gemini](https://aiengineeringfromscratch.com/learn/agent-engineering/computer-use-agents) · [raw](https://raw.githubusercontent.com/rohitg00/ai-engineering-from-scratch/main/phases/14-agent-engineering/21-computer-use-agents/docs/en.md) — Three production computer-use models in 2026. All three are vision-based. All three treat screenshots, DOM text, and tool outputs as untrusted input. Only direct user instructio… - [Voice Agents — Pipecat and LiveKit](https://aiengineeringfromscratch.com/learn/agent-engineering/voice-agents-pipecat-livekit) · [raw](https://raw.githubusercontent.com/rohitg00/ai-engineering-from-scratch/main/phases/14-agent-engineering/22-voice-agents-pipecat-livekit/docs/en.md) — Voice agents are a first-class production category in 2026. Pipecat gives you a Python frame-based pipeline (VAD → STT → LLM → TTS → transport). LiveKit Agents bridges AI models… - [OpenTelemetry GenAI Semantic Conventions](https://aiengineeringfromscratch.com/learn/agent-engineering/otel-genai-conventions) · [raw](https://raw.githubusercontent.com/rohitg00/ai-engineering-from-scratch/main/phases/14-agent-engineering/23-otel-genai-conventions/docs/en.md) — OpenTelemetry's GenAI SIG (launched April 2024) defines the standard schema for agent telemetry. Span names, attributes, and content-capture rules converge across vendors so age… - [Agent Observability — Langfuse, Phoenix, Opik](https://aiengineeringfromscratch.com/learn/agent-engineering/agent-observability-platforms) · [raw](https://raw.githubusercontent.com/rohitg00/ai-engineering-from-scratch/main/phases/14-agent-engineering/24-agent-observability-platforms/docs/en.md) — Three self-hostable agent observability platforms dominate 2026. Langfuse (MIT) — 6M+ installs/month, tracing + prompt management + evals + session replay. Arize Phoenix (Elasti… - [Multi-Agent Debate and Collaboration](https://aiengineeringfromscratch.com/learn/agent-engineering/multi-agent-debate) · [raw](https://raw.githubusercontent.com/rohitg00/ai-engineering-from-scratch/main/phases/14-agent-engineering/25-multi-agent-debate/docs/en.md) — Du et al. (ICML 2024, "Society of Minds") run N model instances that independently propose answers, then iteratively critique each other over R rounds to converge. Improves fact… - [Failure Modes — Why Agents Break](https://aiengineeringfromscratch.com/learn/agent-engineering/failure-modes-agentic) · [raw](https://raw.githubusercontent.com/rohitg00/ai-engineering-from-scratch/main/phases/14-agent-engineering/26-failure-modes-agentic/docs/en.md) — MASFT (Berkeley, 2025) catalogs 14 multi-agent failure modes in 3 categories. Microsoft's Taxonomy documents how existing AI failures amplify in agentic settings. Industry field… - [Prompt Injection and the PVE Defense](https://aiengineeringfromscratch.com/learn/agent-engineering/prompt-injection-defense) · [raw](https://raw.githubusercontent.com/rohitg00/ai-engineering-from-scratch/main/phases/14-agent-engineering/27-prompt-injection-defense/docs/en.md) — Greshake et al. (AISec 2023) established indirect prompt injection as the defining agent security problem. Attacker plants instructions in data the agent retrieves; on ingest, t… - [Orchestration Patterns — Supervisor, Swarm, Hierarchical](https://aiengineeringfromscratch.com/learn/agent-engineering/orchestration-patterns) · [raw](https://raw.githubusercontent.com/rohitg00/ai-engineering-from-scratch/main/phases/14-agent-engineering/28-orchestration-patterns/docs/en.md) — Four orchestration patterns recur across 2026 frameworks: supervisor-worker, swarm / peer-to-peer, hierarchical, debate. Anthropic's guidance: "It's about building the right sys… - [Production Runtimes — Queue, Event, Cron](https://aiengineeringfromscratch.com/learn/agent-engineering/production-runtimes) · [raw](https://raw.githubusercontent.com/rohitg00/ai-engineering-from-scratch/main/phases/14-agent-engineering/29-production-runtimes/docs/en.md) — Production agents run on six runtime shapes: request-response, streaming, durable execution, queue-based background, event-driven, and scheduled. Pick the shape before you pick … - [Eval-Driven Agent Development](https://aiengineeringfromscratch.com/learn/agent-engineering/eval-driven-agent-development) · [raw](https://raw.githubusercontent.com/rohitg00/ai-engineering-from-scratch/main/phases/14-agent-engineering/30-eval-driven-agent-development/docs/en.md) — Anthropic's guidance: "start with simple prompts, optimize them with comprehensive evaluation, and add multi-step agentic systems only when needed." Evaluation is not the last s… - [Agent Workbench: Why Capable Models Still Fail](https://aiengineeringfromscratch.com/learn/agent-engineering/agent-workbench-why-models-fail) · [raw](https://raw.githubusercontent.com/rohitg00/ai-engineering-from-scratch/main/phases/14-agent-engineering/31-agent-workbench-why-models-fail/docs/en.md) — A capable model is not enough. Reliable agents need a workbench: instructions, state, scope, feedback, verification, review, and handoff. Strip those away and even a frontier mo… - [The Minimal Agent Workbench](https://aiengineeringfromscratch.com/learn/agent-engineering/minimal-agent-workbench) · [raw](https://raw.githubusercontent.com/rohitg00/ai-engineering-from-scratch/main/phases/14-agent-engineering/32-minimal-agent-workbench/docs/en.md) — The smallest useful workbench is three files: a root instructions router, a state file, and a task board. Everything else is layered on top. If a repo cannot carry these three, … - [Agent Instructions as Executable Constraints](https://aiengineeringfromscratch.com/learn/agent-engineering/instructions-as-executable-constraints) · [raw](https://raw.githubusercontent.com/rohitg00/ai-engineering-from-scratch/main/phases/14-agent-engineering/33-instructions-as-executable-constraints/docs/en.md) — Instructions written as prose are wishes. Instructions written as constraints are tests. The workbench turns each rule into something an agent can check at runtime and a reviewe… - [Repo Memory and Durable State](https://aiengineeringfromscratch.com/learn/agent-engineering/repo-memory-and-state) · [raw](https://raw.githubusercontent.com/rohitg00/ai-engineering-from-scratch/main/phases/14-agent-engineering/34-repo-memory-and-state/docs/en.md) — Chat history is volatile. The repo is durable. The workbench stores agent state in versioned files so the next session, the next agent, and the next reviewer all read from the s… - [Initialization Scripts for Agents](https://aiengineeringfromscratch.com/learn/agent-engineering/initialization-scripts) · [raw](https://raw.githubusercontent.com/rohitg00/ai-engineering-from-scratch/main/phases/14-agent-engineering/35-initialization-scripts/docs/en.md) — Every session that starts cold pays a tax. The agent reads the same files, retries the same probes, and rediscovers the same paths. An init script pays the tax once and writes t… - [Scope Contracts and Task Boundaries](https://aiengineeringfromscratch.com/learn/agent-engineering/scope-contracts) · [raw](https://raw.githubusercontent.com/rohitg00/ai-engineering-from-scratch/main/phases/14-agent-engineering/36-scope-contracts/docs/en.md) — The model does not know where the work ends. A scope contract is a per-task file that says where the work begins, where it ends, and how to roll back if it spills. The contract … - [Runtime Feedback Loops](https://aiengineeringfromscratch.com/learn/agent-engineering/runtime-feedback-loops) · [raw](https://raw.githubusercontent.com/rohitg00/ai-engineering-from-scratch/main/phases/14-agent-engineering/37-runtime-feedback-loops/docs/en.md) — Agents that do not see real command output guess. A feedback runner captures stdout, stderr, exit code, and timing into a structured record the next turn can read. Then the agen… - [Verification Gates](https://aiengineeringfromscratch.com/learn/agent-engineering/verification-gates) · [raw](https://raw.githubusercontent.com/rohitg00/ai-engineering-from-scratch/main/phases/14-agent-engineering/38-verification-gates/docs/en.md) — The agent does not get to mark its own work as done. A verification gate reads the scope contract, the feedback log, the rule report, and the diff, and answers a single question… - [Reviewer Agent: Separate Builder from Marker](https://aiengineeringfromscratch.com/learn/agent-engineering/reviewer-agent) · [raw](https://raw.githubusercontent.com/rohitg00/ai-engineering-from-scratch/main/phases/14-agent-engineering/39-reviewer-agent/docs/en.md) — The agent that wrote the code cannot grade it. A reviewer is a second loop with a different system prompt, a different goal, and read-only access to everything the builder produ… - [Multi-Session Handoff](https://aiengineeringfromscratch.com/learn/agent-engineering/multi-session-handoff) · [raw](https://raw.githubusercontent.com/rohitg00/ai-engineering-from-scratch/main/phases/14-agent-engineering/40-multi-session-handoff/docs/en.md) — The session is going to end. The work is not. The handoff packet is the artifact that turns "the agent worked for an hour" into "the next session is productive in the first minu… - [The Workbench on a Real Repo](https://aiengineeringfromscratch.com/learn/agent-engineering/workbench-for-real-repos) · [raw](https://raw.githubusercontent.com/rohitg00/ai-engineering-from-scratch/main/phases/14-agent-engineering/41-workbench-for-real-repos/docs/en.md) — Eleven lessons of workbench surfaces are worth nothing if they do not survive contact with a real codebase. This lesson runs the same task twice on a small sample app: prompt-on… - [Capstone: Ship a Reusable Agent Workbench Pack](https://aiengineeringfromscratch.com/learn/agent-engineering/agent-workbench-capstone) · [raw](https://raw.githubusercontent.com/rohitg00/ai-engineering-from-scratch/main/phases/14-agent-engineering/42-agent-workbench-capstone/docs/en.md) — The mini-track ends with a pack you drop into any repo. Eleven lessons of surfaces compressed into a directory you can `cp -r` and have an agent working reliably the next mornin… - [Frame the Task Before the Agent Writes Code](https://aiengineeringfromscratch.com/learn/agent-engineering/frame-the-task-before-code) · [raw](https://raw.githubusercontent.com/rohitg00/ai-engineering-from-scratch/main/phases/14-agent-engineering/43-frame-the-task-before-code/docs/en.md) — A coding agent can implement a clear task quickly. It can also implement an unclear task quickly. The speed is the same. The cost is not. - [Build an Evidence-Backed Execution Plan](https://aiengineeringfromscratch.com/learn/agent-engineering/plan-from-evidence) · [raw](https://raw.githubusercontent.com/rohitg00/ai-engineering-from-scratch/main/phases/14-agent-engineering/44-plan-from-evidence/docs/en.md) — A plan is not a prettier to-do list. It is a dependency graph in which every change has a reason and every terminal node has proof. - [Delegate Agent Work with Isolation and Merge Contracts](https://aiengineeringfromscratch.com/learn/agent-engineering/delegate-with-isolation) · [raw](https://raw.githubusercontent.com/rohitg00/ai-engineering-from-scratch/main/phases/14-agent-engineering/45-delegate-with-isolation/docs/en.md) — Parallel agents save wall time only when the work is independent. Otherwise they convert one clear task into a coordination problem with a faster failure rate. - [Turn Every Agent Correction into a System Improvement](https://aiengineeringfromscratch.com/learn/agent-engineering/turn-feedback-into-system) · [raw](https://raw.githubusercontent.com/rohitg00/ai-engineering-from-scratch/main/phases/14-agent-engineering/46-turn-feedback-into-system/docs/en.md) — A correction that lives only in chat fixes one run. A correction promoted into a test, boundary, example, or tool improves every later run. - [Define the Outcome Before You Choose the Output](https://aiengineeringfromscratch.com/learn/agent-engineering/outcomes-before-output) · [raw](https://raw.githubusercontent.com/rohitg00/ai-engineering-from-scratch/main/phases/14-agent-engineering/47-outcomes-before-output/docs/en.md) — Fast implementation increases the penalty for choosing the wrong problem. Shape the outcome first so speed points in the right direction. - [Discover the Workflow People Actually Perform](https://aiengineeringfromscratch.com/learn/agent-engineering/discover-the-real-workflow) · [raw](https://raw.githubusercontent.com/rohitg00/ai-engineering-from-scratch/main/phases/14-agent-engineering/48-discover-the-real-workflow/docs/en.md) — Requirements are not waiting in a meeting to be collected. They are scattered across actions, workarounds, records, and disagreements. - [Map Assumptions and Resolve the Riskiest One First](https://aiengineeringfromscratch.com/learn/agent-engineering/map-assumptions-and-risk) · [raw](https://raw.githubusercontent.com/rohitg00/ai-engineering-from-scratch/main/phases/14-agent-engineering/49-map-assumptions-and-risk/docs/en.md) — A roadmap hides uncertainty inside features. An assumption map exposes what must be true before those features deserve to exist. - [Choose the Smallest Slice That Can Change the Decision](https://aiengineeringfromscratch.com/learn/agent-engineering/choose-the-smallest-testable-slice) · [raw](https://raw.githubusercontent.com/rohitg00/ai-engineering-from-scratch/main/phases/14-agent-engineering/50-choose-the-smallest-testable-slice/docs/en.md) — Small is useful only when it proves something important. A tiny build that cannot change the next decision is merely incomplete. - [Write Specifications That Preserve Judgment](https://aiengineeringfromscratch.com/learn/agent-engineering/write-specifications-that-preserve-judgment) · [raw](https://raw.githubusercontent.com/rohitg00/ai-engineering-from-scratch/main/phases/14-agent-engineering/51-write-specifications-that-preserve-judgment/docs/en.md) — A useful specification fixes invariants and evidence while leaving reversible implementation choices open. It is a decision boundary, not a screenplay. - [Design Success Metrics Before the Result Exists](https://aiengineeringfromscratch.com/learn/agent-engineering/design-success-metrics) · [raw](https://raw.githubusercontent.com/rohitg00/ai-engineering-from-scratch/main/phases/14-agent-engineering/52-design-success-metrics/docs/en.md) — Measurement should answer a decision, not decorate a dashboard. Start with the goal, derive questions, then choose the smallest metrics that answer them. - [Choose Prototype, Pilot, or Production Deliberately](https://aiengineeringfromscratch.com/learn/agent-engineering/prototype-pilot-or-production) · [raw](https://raw.githubusercontent.com/rohitg00/ai-engineering-from-scratch/main/phases/14-agent-engineering/53-prototype-pilot-or-production/docs/en.md) — These are different learning environments, not levels of polish. Choose the stage that answers the current unknown with the least unnecessary consequence. - [Build a Feedback Ratchet with Ownership and Retirement](https://aiengineeringfromscratch.com/learn/agent-engineering/build-the-feedback-ratchet) · [raw](https://raw.githubusercontent.com/rohitg00/ai-engineering-from-scratch/main/phases/14-agent-engineering/54-build-the-feedback-ratchet/docs/en.md) — Shipping closes one build loop and opens the learning loop. Evidence must change the system or it becomes telemetry nobody owns. ## Phase 15: Autonomous Systems Long-horizon agents, self-improvement, and the 2026 safety stack. - [From Chatbots to Long-Horizon Agents (METR)](https://aiengineeringfromscratch.com/learn/autonomous-systems/long-horizon-agents) · [raw](https://raw.githubusercontent.com/rohitg00/ai-engineering-from-scratch/main/phases/15-autonomous-systems/01-long-horizon-agents/docs/en.md) — In 2023 a chatbot answered a question in one turn. In 2026 a frontier model routinely runs minutes to hours on a single task. METR's Time Horizon 1.1 benchmark (January 2026) pu… - [STaR, V-STaR, Quiet-STaR: Self-Taught Reasoning](https://aiengineeringfromscratch.com/learn/autonomous-systems/star-family-reasoning) · [raw](https://raw.githubusercontent.com/rohitg00/ai-engineering-from-scratch/main/phases/15-autonomous-systems/02-star-family-reasoning/docs/en.md) — The smallest possible self-improvement loop sits inside the rationale. A model generates a chain of thought, keeps the ones that land on correct answers, and fine-tunes on those… - [AlphaEvolve: Evolutionary Coding Agents](https://aiengineeringfromscratch.com/learn/autonomous-systems/alphaevolve-evolutionary-coding) · [raw](https://raw.githubusercontent.com/rohitg00/ai-engineering-from-scratch/main/phases/15-autonomous-systems/03-alphaevolve-evolutionary-coding/docs/en.md) — Pair a frontier coding model with an evolutionary loop and a machine-checkable evaluator. Let the loop run long enough. It discovers a 4x4 complex-matrix multiplication procedur… - [Darwin Gödel Machine: Self-Modifying Agents](https://aiengineeringfromscratch.com/learn/autonomous-systems/darwin-godel-machine) · [raw](https://raw.githubusercontent.com/rohitg00/ai-engineering-from-scratch/main/phases/15-autonomous-systems/04-darwin-godel-machine/docs/en.md) — Schmidhuber's 2003 Godel Machine required a formal proof that any self-modification was beneficial before accepting it. That proof is impossible in practice. Darwin Godel Machin… - [AI Scientist v2: Workshop-Level Research](https://aiengineeringfromscratch.com/learn/autonomous-systems/ai-scientist-v2) · [raw](https://raw.githubusercontent.com/rohitg00/ai-engineering-from-scratch/main/phases/15-autonomous-systems/05-ai-scientist-v2/docs/en.md) — Sakana's AI Scientist v2 (Yamada et al., arXiv:2504.08066) runs the full research loop: hypothesis, code, experiments, figures, writeup, submission. It is the first system to ha… - [Automated Alignment Research (Anthropic AAR)](https://aiengineeringfromscratch.com/learn/autonomous-systems/automated-alignment-research) · [raw](https://raw.githubusercontent.com/rohitg00/ai-engineering-from-scratch/main/phases/15-autonomous-systems/06-automated-alignment-research/docs/en.md) — Anthropic ran parallel teams of Claude Opus 4.6 Autonomous Alignment Researchers in independent sandboxes, coordinating via a shared forum whose logs live outside any sandbox (s… - [Recursive Self-Improvement: Capability vs Alignment](https://aiengineeringfromscratch.com/learn/autonomous-systems/recursive-self-improvement) · [raw](https://raw.githubusercontent.com/rohitg00/ai-engineering-from-scratch/main/phases/15-autonomous-systems/07-recursive-self-improvement/docs/en.md) — Recursive self-improvement (RSI) is no longer speculation. The ICLR 2026 RSI Workshop in Rio (April 23-27) framed it as an engineering problem with concrete tooling. Demis Hassa… - [Bounded Self-Improvement Designs](https://aiengineeringfromscratch.com/learn/autonomous-systems/bounded-self-improvement) · [raw](https://raw.githubusercontent.com/rohitg00/ai-engineering-from-scratch/main/phases/15-autonomous-systems/08-bounded-self-improvement/docs/en.md) — Research has converged on four primitives for bounding a self-improvement loop. Formal invariants that must hold across every edit. Alignment anchors that cannot be modified. Mu… - [Autonomous Coding Agent Landscape (SWE-bench, CodeAct)](https://aiengineeringfromscratch.com/learn/autonomous-systems/coding-agent-landscape) · [raw](https://raw.githubusercontent.com/rohitg00/ai-engineering-from-scratch/main/phases/15-autonomous-systems/09-coding-agent-landscape/docs/en.md) — SWE-bench Verified went from 4% to 80.9% in under three years. Same Claude Sonnet 4.5 scored 43.2% on SWE-agent v1 and 59.8% on Cline autonomous — the scaffolding around the mod… - [Permission Modes for Autonomous Agents](https://aiengineeringfromscratch.com/learn/autonomous-systems/claude-code-permission-modes) · [raw](https://raw.githubusercontent.com/rohitg00/ai-engineering-from-scratch/main/phases/15-autonomous-systems/10-claude-code-permission-modes/docs/en.md) — A permission ladder — graduated levels of autonomy from review-every-action to approve-everything — is how a harness governs what an autonomous agent may do without asking. Clau… - [Browser Agents and Indirect Prompt Injection](https://aiengineeringfromscratch.com/learn/autonomous-systems/browser-agents) · [raw](https://raw.githubusercontent.com/rohitg00/ai-engineering-from-scratch/main/phases/15-autonomous-systems/11-browser-agents/docs/en.md) — ChatGPT agent (July 2025) merged Operator and deep research into one browser/terminal agent and set BrowseComp SOTA at 68.9%. OpenAI shut Operator down August 31, 2025 — consoli… - [Durable Execution for Long-Running Agents](https://aiengineeringfromscratch.com/learn/autonomous-systems/durable-execution) · [raw](https://raw.githubusercontent.com/rohitg00/ai-engineering-from-scratch/main/phases/15-autonomous-systems/12-durable-execution/docs/en.md) — Production long-horizon agents do not run in `while True`. Every LLM call becomes an activity with checkpoint, retry, and replay. Temporal's OpenAI Agents SDK integration went G… - [Action Budgets, Iteration Caps, Cost Governors](https://aiengineeringfromscratch.com/learn/autonomous-systems/cost-governors) · [raw](https://raw.githubusercontent.com/rohitg00/ai-engineering-from-scratch/main/phases/15-autonomous-systems/13-cost-governors/docs/en.md) — A mid-sized e-commerce agent's monthly LLM cost jumped from $1,200 to $4,800 after its team enabled the "order-tracking" skill. That is not a pricing bug. That is an agent that … - [Kill Switches, Circuit Breakers, Canary Tokens](https://aiengineeringfromscratch.com/learn/autonomous-systems/kill-switches-canaries) · [raw](https://raw.githubusercontent.com/rohitg00/ai-engineering-from-scratch/main/phases/15-autonomous-systems/14-kill-switches-canaries/docs/en.md) — A kill switch is a boolean held outside the agent's edit surface — a Redis key, a feature flag, a signed config — that disables the agent entirely. A circuit breaker is finer-gr… - [HITL: Propose-Then-Commit](https://aiengineeringfromscratch.com/learn/autonomous-systems/propose-then-commit) · [raw](https://raw.githubusercontent.com/rohitg00/ai-engineering-from-scratch/main/phases/15-autonomous-systems/15-propose-then-commit/docs/en.md) — The 2026 consensus on HITL is specific. It is not "the agent asks, the user clicks Approve." It is propose-then-commit: the proposed action is persisted to a durable store with … - [Checkpoints and Rollback](https://aiengineeringfromscratch.com/learn/autonomous-systems/checkpoints-rollback) · [raw](https://raw.githubusercontent.com/rohitg00/ai-engineering-from-scratch/main/phases/15-autonomous-systems/16-checkpoints-rollback/docs/en.md) — Every graph-state transition persists. When a worker crashes, its lease expires and another worker picks up at the latest checkpoint. Cloudflare Durable Objects hold state acros… - [Constitutional AI and Rule Overrides](https://aiengineeringfromscratch.com/learn/autonomous-systems/constitutional-ai) · [raw](https://raw.githubusercontent.com/rohitg00/ai-engineering-from-scratch/main/phases/15-autonomous-systems/17-constitutional-ai/docs/en.md) — Anthropic's January 22, 2026 Claude Constitution runs 79 pages and is CC0. It moves from rule-based to reason-based alignment and establishes a four-tier priority hierarchy: (1)… - [Llama Guard and Input/Output Classification](https://aiengineeringfromscratch.com/learn/autonomous-systems/llama-guard) · [raw](https://raw.githubusercontent.com/rohitg00/ai-engineering-from-scratch/main/phases/15-autonomous-systems/18-llama-guard/docs/en.md) — Llama Guard 3 (Meta, Llama-3.1-8B base, fine-tuned for content safety) classifies both LLM inputs and outputs against an MLCommons 13-hazard taxonomy across 8 languages. A 1B-IN… - [Anthropic Responsible Scaling Policy v3.0](https://aiengineeringfromscratch.com/learn/autonomous-systems/anthropic-rsp) · [raw](https://raw.githubusercontent.com/rohitg00/ai-engineering-from-scratch/main/phases/15-autonomous-systems/19-anthropic-rsp/docs/en.md) — RSP v3.0 went into effect February 24, 2026, replacing the 2023 policy. Two-tier mitigation: what Anthropic will do unilaterally vs what is framed as an industry-wide recommenda… - [OpenAI Preparedness Framework and DeepMind FSF](https://aiengineeringfromscratch.com/learn/autonomous-systems/openai-preparedness-deepmind-fsf) · [raw](https://raw.githubusercontent.com/rohitg00/ai-engineering-from-scratch/main/phases/15-autonomous-systems/20-openai-preparedness-deepmind-fsf/docs/en.md) — OpenAI Preparedness Framework v2 (April 2025) introduces Research Categories — Long-range Autonomy, Sandbagging, Autonomous Replication and Adaptation, Undermining Safeguards — … - [METR Time Horizons and External Evaluation](https://aiengineeringfromscratch.com/learn/autonomous-systems/metr-external-evaluation) · [raw](https://raw.githubusercontent.com/rohitg00/ai-engineering-from-scratch/main/phases/15-autonomous-systems/21-metr-external-evaluation/docs/en.md) — METR (ex-ARC Evals) is an independent 501(c)(3) since December 2023. Their Time Horizon 1.1 benchmark (January 2026) fits a logistic curve to task-success probability vs log(exp… - [CAIS, CAISI, and Societal-Scale Risk](https://aiengineeringfromscratch.com/learn/autonomous-systems/cais-caisi-societal-risk) · [raw](https://raw.githubusercontent.com/rohitg00/ai-engineering-from-scratch/main/phases/15-autonomous-systems/22-cais-caisi-societal-risk/docs/en.md) — The Center for AI Safety (CAIS, San Francisco, founded 2022 by Hendrycks and Zhang) publishes the four-risk framework — malicious use, AI races, organizational risks, rogue AIs … ## Phase 16: Multi-Agent & Swarms Coordination, emergence, and collective intelligence. - [Why Multi-Agent](https://aiengineeringfromscratch.com/learn/multi-agent-and-swarms/why-multi-agent) · [raw](https://raw.githubusercontent.com/rohitg00/ai-engineering-from-scratch/main/phases/16-multi-agent-and-swarms/01-why-multi-agent/docs/en.md) — One agent hits a wall. The smart move is not a bigger agent - it is more agents. - [FIPA-ACL Heritage and Speech Acts](https://aiengineeringfromscratch.com/learn/multi-agent-and-swarms/fipa-acl-heritage) · [raw](https://raw.githubusercontent.com/rohitg00/ai-engineering-from-scratch/main/phases/16-multi-agent-and-swarms/02-fipa-acl-heritage/docs/en.md) — Before MCP, before A2A, there was FIPA-ACL. In 2000 the Foundation for Intelligent Physical Agents (FIPA, which became an IEEE Computer Society standards committee in 2005) rati… - [Communication Protocols](https://aiengineeringfromscratch.com/learn/multi-agent-and-swarms/communication-protocols) · [raw](https://raw.githubusercontent.com/rohitg00/ai-engineering-from-scratch/main/phases/16-multi-agent-and-swarms/03-communication-protocols/docs/en.md) — Agents that can't speak the same language aren't a team. They're strangers shouting into the void. - [The Multi-Agent Primitive Model](https://aiengineeringfromscratch.com/learn/multi-agent-and-swarms/primitive-model) · [raw](https://raw.githubusercontent.com/rohitg00/ai-engineering-from-scratch/main/phases/16-multi-agent-and-swarms/04-primitive-model/docs/en.md) — Four primitives, nothing more — the agent, the handoff, the shared state, the orchestrator — span a four-dimensional design space, and the major multi-agent frameworks shipping … - [Supervisor / Orchestrator-Worker Pattern](https://aiengineeringfromscratch.com/learn/multi-agent-and-swarms/supervisor-orchestrator-pattern) · [raw](https://raw.githubusercontent.com/rohitg00/ai-engineering-from-scratch/main/phases/16-multi-agent-and-swarms/05-supervisor-orchestrator-pattern/docs/en.md) — One lead agent plans and delegates; specialized workers execute in parallel contexts and report back. This is the pattern behind Anthropic's Research system (Claude Opus 4 as le… - [Hierarchical Architecture and Decomposition Drift](https://aiengineeringfromscratch.com/learn/multi-agent-and-swarms/hierarchical-architecture) · [raw](https://raw.githubusercontent.com/rohitg00/ai-engineering-from-scratch/main/phases/16-multi-agent-and-swarms/06-hierarchical-architecture/docs/en.md) — Hierarchical is supervisor nested. Manager agents over sub-managers over workers. CrewAI `Process.hierarchical` is the textbook version: a `manager_llm` dynamically delegates ta… - [Society of Mind and Multi-Agent Debate](https://aiengineeringfromscratch.com/learn/multi-agent-and-swarms/society-of-mind-debate) · [raw](https://raw.githubusercontent.com/rohitg00/ai-engineering-from-scratch/main/phases/16-multi-agent-and-swarms/07-society-of-mind-debate/docs/en.md) — Minsky's 1986 premise — intelligence is a society of specialists — gets rediscovered every decade. In 2023 Du et al. turned it into a concrete algorithm: multiple LLM instances … - [Role Specialization — Planner / Critic / Executor / Verifier](https://aiengineeringfromscratch.com/learn/multi-agent-and-swarms/role-specialization) · [raw](https://raw.githubusercontent.com/rohitg00/ai-engineering-from-scratch/main/phases/16-multi-agent-and-swarms/08-role-specialization/docs/en.md) — The most common multi-agent decomposition in 2026: one agent plans, one executes, one critiques or verifies. MetaGPT (arXiv:2308.00352) formalizes this as SOPs encoded into role… - [Parallel Swarm and Networked Architectures](https://aiengineeringfromscratch.com/learn/multi-agent-and-swarms/parallel-swarm-networks) · [raw](https://raw.githubusercontent.com/rohitg00/ai-engineering-from-scratch/main/phases/16-multi-agent-and-swarms/09-parallel-swarm-networks/docs/en.md) — Contrast with supervisor: no central decider. Agents read a shared event bus, pick up work asynchronously, write results back. LangGraph explicitly supports "Swarm Architecture"… - [Group Chat and Speaker Selection](https://aiengineeringfromscratch.com/learn/multi-agent-and-swarms/group-chat-speaker-selection) · [raw](https://raw.githubusercontent.com/rohitg00/ai-engineering-from-scratch/main/phases/16-multi-agent-and-swarms/10-group-chat-speaker-selection/docs/en.md) — Shared-conversation orchestration puts N agents in one conversation; a selector function (LLM, round-robin, or custom) picks who speaks next. This is the archetype of emergent m… - [Handoffs and Routines (Stateless Orchestration)](https://aiengineeringfromscratch.com/learn/multi-agent-and-swarms/handoffs-and-routines) · [raw](https://raw.githubusercontent.com/rohitg00/ai-engineering-from-scratch/main/phases/16-multi-agent-and-swarms/11-handoffs-and-routines/docs/en.md) — OpenAI's Swarm (October 2024) distilled multi-agent orchestration to two primitives: **routines** (instructions + tools as a system prompt) and **handoffs** (a tool that returns… - [A2A — The Agent-to-Agent Protocol](https://aiengineeringfromscratch.com/learn/multi-agent-and-swarms/a2a-protocol) · [raw](https://raw.githubusercontent.com/rohitg00/ai-engineering-from-scratch/main/phases/16-multi-agent-and-swarms/12-a2a-protocol/docs/en.md) — Google announced A2A in April 2025; by April 2026 the spec is at https://a2a-protocol.org/latest/specification/ and 150+ organizations back it. A2A is the horizontal complement … - [Shared Memory and Blackboard Patterns](https://aiengineeringfromscratch.com/learn/multi-agent-and-swarms/shared-memory-blackboard) · [raw](https://raw.githubusercontent.com/rohitg00/ai-engineering-from-scratch/main/phases/16-multi-agent-and-swarms/13-shared-memory-blackboard/docs/en.md) — Two approaches coexist in 2026 multi-agent systems: the **message pool** (everyone sees everyone's messages, as in AutoGen GroupChat or MetaGPT) and the **blackboard with subscr… - [Consensus and Byzantine Fault Tolerance](https://aiengineeringfromscratch.com/learn/multi-agent-and-swarms/consensus-and-bft) · [raw](https://raw.githubusercontent.com/rohitg00/ai-engineering-from-scratch/main/phases/16-multi-agent-and-swarms/14-consensus-and-bft/docs/en.md) — Classical distributed-systems BFT meets stochastic LLMs. In 2025-2026 three research directions emerged: **CP-WBFT** (arXiv:2511.10400) weighs each vote by a confidence probe; *… - [Voting, Self-Consistency, and Debate Topology](https://aiengineeringfromscratch.com/learn/multi-agent-and-swarms/voting-debate-topology) · [raw](https://raw.githubusercontent.com/rohitg00/ai-engineering-from-scratch/main/phases/16-multi-agent-and-swarms/15-voting-debate-topology/docs/en.md) — The cheapest aggregation: sample N independent agents, majority-vote. Wang et al. 2022 self-consistency did this with one model sampled N times. Multi-agent extends it with **he… - [Negotiation and Bargaining](https://aiengineeringfromscratch.com/learn/multi-agent-and-swarms/negotiation-bargaining) · [raw](https://raw.githubusercontent.com/rohitg00/ai-engineering-from-scratch/main/phases/16-multi-agent-and-swarms/16-negotiation-bargaining/docs/en.md) — Agents negotiate resources, prices, task allocations, and terms. The 2026 benchmark set is clear: NegotiationArena (arXiv:2402.05863) shows LLMs can improve payoffs ~20% via per… - [Generative Agents and Emergent Simulation](https://aiengineeringfromscratch.com/learn/multi-agent-and-swarms/generative-agents-simulation) · [raw](https://raw.githubusercontent.com/rohitg00/ai-engineering-from-scratch/main/phases/16-multi-agent-and-swarms/17-generative-agents-simulation/docs/en.md) — Park et al. 2023 (UIST '23, arXiv:2304.03442) populated **Smallville**, a sandbox of 25 agents, with a three-part architecture: **memory stream** (natural-language log), **refle… - [Theory of Mind and Emergent Coordination](https://aiengineeringfromscratch.com/learn/multi-agent-and-swarms/theory-of-mind-coordination) · [raw](https://raw.githubusercontent.com/rohitg00/ai-engineering-from-scratch/main/phases/16-multi-agent-and-swarms/18-theory-of-mind-coordination/docs/en.md) — Li et al. (arXiv:2310.10701) showed that LLM agents in a cooperative text game exhibit **emergent high-order Theory of Mind** (ToM) — reasoning about what another agent believes… - [Swarm Optimization (PSO, ACO)](https://aiengineeringfromscratch.com/learn/multi-agent-and-swarms/swarm-optimization-pso-aco) · [raw](https://raw.githubusercontent.com/rohitg00/ai-engineering-from-scratch/main/phases/16-multi-agent-and-swarms/19-swarm-optimization-pso-aco/docs/en.md) — Bio-inspired optimization is making an LLM comeback. **LMPSO** (arXiv:2504.09247) uses PSO where each particle's velocity is a prompt and the LLM generates the next candidate; w… - [MARL — MADDPG, QMIX, MAPPO](https://aiengineeringfromscratch.com/learn/multi-agent-and-swarms/marl-maddpg-qmix-mappo) · [raw](https://raw.githubusercontent.com/rohitg00/ai-engineering-from-scratch/main/phases/16-multi-agent-and-swarms/20-marl-maddpg-qmix-mappo/docs/en.md) — The reinforcement-learning heritage of multi-agent coordination, which still informs LLM-agent systems in 2026. **MADDPG** (Lowe et al., NeurIPS 2017, arXiv:1706.02275) introduc… - [Agent Economies, Token Incentives, Reputation](https://aiengineeringfromscratch.com/learn/multi-agent-and-swarms/agent-economies) · [raw](https://raw.githubusercontent.com/rohitg00/ai-engineering-from-scratch/main/phases/16-multi-agent-and-swarms/21-agent-economies/docs/en.md) — Long-horizon autonomous agents (METR's 1-hour to 8-hour work-curve) need economic agency. The emerging **5-layer stack** is: **DePIN** (physical compute) → **Identity** (W3C DID… - [Production Scaling — Queues, Checkpoints, Durability](https://aiengineeringfromscratch.com/learn/multi-agent-and-swarms/production-scaling-queues-checkpoints) · [raw](https://raw.githubusercontent.com/rohitg00/ai-engineering-from-scratch/main/phases/16-multi-agent-and-swarms/22-production-scaling-queues-checkpoints/docs/en.md) — Scaling multi-agent systems to thousands of concurrent runs requires **durable execution** — work queues plus checkpoints, so any worker can resume any run after any crash, prov… - [Failure Modes — MAST, Groupthink, Monoculture](https://aiengineeringfromscratch.com/learn/multi-agent-and-swarms/failure-modes-mast-groupthink) · [raw](https://raw.githubusercontent.com/rohitg00/ai-engineering-from-scratch/main/phases/16-multi-agent-and-swarms/23-failure-modes-mast-groupthink/docs/en.md) — The reference taxonomy for 2026 is **MAST** (Cemri et al., NeurIPS 2025, arXiv:2503.13657), derived from 1642 execution traces across 7 state-of-the-art open-source MAS showing … - [Evaluation and Coordination Benchmarks](https://aiengineeringfromscratch.com/learn/multi-agent-and-swarms/evaluation-coordination-benchmarks) · [raw](https://raw.githubusercontent.com/rohitg00/ai-engineering-from-scratch/main/phases/16-multi-agent-and-swarms/24-evaluation-coordination-benchmarks/docs/en.md) — Five 2025-2026 benchmarks cover the multi-agent evaluation space. **MultiAgentBench / MARBLE** (ACL 2025, arXiv:2503.01935) evaluates star/chain/tree/graph topologies with miles… - [Case Studies and 2026 State of the Art](https://aiengineeringfromscratch.com/learn/multi-agent-and-swarms/case-studies-2026-sota) · [raw](https://raw.githubusercontent.com/rohitg00/ai-engineering-from-scratch/main/phases/16-multi-agent-and-swarms/25-case-studies-2026-sota/docs/en.md) — Three production-grade references to study end-to-end, each illustrating a different slice of multi-agent engineering. **Anthropic's Research system** (orchestrator-worker, 15x … ## Phase 17: Infrastructure & Production Ship AI to the real world. - [Managed LLM Platforms — Bedrock, Azure OpenAI, Vertex AI](https://aiengineeringfromscratch.com/learn/infrastructure-and-production/managed-llm-platforms) · [raw](https://raw.githubusercontent.com/rohitg00/ai-engineering-from-scratch/main/phases/17-infrastructure-and-production/01-managed-llm-platforms/docs/en.md) — Three hyperscalers, three distinct strategies. AWS Bedrock is a model marketplace — Claude, Llama, Titan, Stability, Cohere behind one API. Azure OpenAI is an exclusive OpenAI p… - [Inference Platform Economics — Fireworks, Together, Baseten, Modal](https://aiengineeringfromscratch.com/learn/infrastructure-and-production/inference-platform-economics) · [raw](https://raw.githubusercontent.com/rohitg00/ai-engineering-from-scratch/main/phases/17-infrastructure-and-production/02-inference-platform-economics/docs/en.md) — The 2026 inference market is no longer GPU time rental. It bifurcates into custom silicon (Groq, Cerebras, SambaNova), GPU platforms (Baseten, Together, Fireworks, Modal), and A… - [GPU Autoscaling on Kubernetes — Karpenter, KAI Scheduler](https://aiengineeringfromscratch.com/learn/infrastructure-and-production/gpu-autoscaling-kubernetes) · [raw](https://raw.githubusercontent.com/rohitg00/ai-engineering-from-scratch/main/phases/17-infrastructure-and-production/03-gpu-autoscaling-kubernetes/docs/en.md) — Three layers, not one. Karpenter provisions nodes dynamically (under one minute, 40% faster than Cluster Autoscaler). KAI Scheduler handles gang scheduling, topology awareness, … - [Serving Engine Internals — PagedAttention, Continuous Batching, Chunked Prefill](https://aiengineeringfromscratch.com/learn/infrastructure-and-production/vllm-serving-internals) · [raw](https://raw.githubusercontent.com/rohitg00/ai-engineering-from-scratch/main/phases/17-infrastructure-and-production/04-vllm-serving-internals/docs/en.md) — Modern serving-engine throughput rests on three compounding defaults, not a single trick. PagedAttention is always on. Continuous batching injects new requests into the active b… - [EAGLE-3 Speculative Decoding in Production](https://aiengineeringfromscratch.com/learn/infrastructure-and-production/eagle3-speculative-decoding) · [raw](https://raw.githubusercontent.com/rohitg00/ai-engineering-from-scratch/main/phases/17-infrastructure-and-production/05-eagle3-speculative-decoding/docs/en.md) — Speculative decoding pairs a fast draft model with the target model. The draft proposes K tokens; the target verifies in a single forward; accepted tokens are free. In 2026, EAG… - [Prefix-Cache Serving — RadixAttention and KV Reuse](https://aiengineeringfromscratch.com/learn/infrastructure-and-production/sglang-radixattention) · [raw](https://raw.githubusercontent.com/rohitg00/ai-engineering-from-scratch/main/phases/17-infrastructure-and-production/06-sglang-radixattention/docs/en.md) — Treat the KV cache as a first-class, reusable resource stored in a radix tree, and scheduling changes with it: instead of FCFS (first-come, first-served) as vLLM schedules, a ca… - [Hardware-Specialized Inference Compilation — FP8 and NVFP4 on Blackwell](https://aiengineeringfromscratch.com/learn/infrastructure-and-production/tensorrt-llm-blackwell) · [raw](https://raw.githubusercontent.com/rohitg00/ai-engineering-from-scratch/main/phases/17-infrastructure-and-production/07-tensorrt-llm-blackwell/docs/en.md) — Hardware-specialized inference compilation trades portability for throughput, and TensorRT-LLM — NVIDIA-only, tuned for Blackwell — is the clearest example of the trade paying o… - [Inference Metrics — TTFT, TPOT, ITL, Goodput, P99](https://aiengineeringfromscratch.com/learn/infrastructure-and-production/inference-metrics-goodput) · [raw](https://raw.githubusercontent.com/rohitg00/ai-engineering-from-scratch/main/phases/17-infrastructure-and-production/08-inference-metrics-goodput/docs/en.md) — Five metrics decide whether an inference deployment is working. TTFT is prefill plus queue plus network. TPOT (often reported as ITL, though tools disagree on whether ITL counts… - [Production Quantization — AWQ, GPTQ, GGUF, FP8, NVFP4](https://aiengineeringfromscratch.com/learn/infrastructure-and-production/production-quantization) · [raw](https://raw.githubusercontent.com/rohitg00/ai-engineering-from-scratch/main/phases/17-infrastructure-and-production/09-production-quantization/docs/en.md) — Quantization format is not a universal choice — it is a function of hardware, serving engine, and workload. GGUF Q4_K_M or Q5_K_M owns CPU and edge, delivered through llama.cpp … - [Cold Start Mitigation for Serverless LLMs](https://aiengineeringfromscratch.com/learn/infrastructure-and-production/cold-start-mitigation) · [raw](https://raw.githubusercontent.com/rohitg00/ai-engineering-from-scratch/main/phases/17-infrastructure-and-production/10-cold-start-mitigation/docs/en.md) — A large model takes minutes to go from cold to serving: a 70B model on a fresh node needs roughly 3-8 minutes before the first token. In a true serverless world, that is not a w… - [Multi-Region LLM Serving and KV Cache Locality](https://aiengineeringfromscratch.com/learn/infrastructure-and-production/multi-region-kv-locality) · [raw](https://raw.githubusercontent.com/rohitg00/ai-engineering-from-scratch/main/phases/17-infrastructure-and-production/11-multi-region-kv-locality/docs/en.md) — Round-robin load balancing is actively harmful for cached LLM inference. A request that does not land on the node holding its prefix pays full prefill cost — roughly 800 ms at P… - [Edge Inference — ANE, Hexagon, WebGPU, Jetson](https://aiengineeringfromscratch.com/learn/infrastructure-and-production/edge-inference) · [raw](https://raw.githubusercontent.com/rohitg00/ai-engineering-from-scratch/main/phases/17-infrastructure-and-production/12-edge-inference/docs/en.md) — The core edge constraint is memory bandwidth, not compute. Mobile DRAM sits at 50-90 GB/s; datacenter HBM3 clears 2-3 TB/s — a 30-50x gap. Decode is memory-bound so the gap is d… - [LLM Observability Stack Selection](https://aiengineeringfromscratch.com/learn/infrastructure-and-production/llm-observability) · [raw](https://raw.githubusercontent.com/rohitg00/ai-engineering-from-scratch/main/phases/17-infrastructure-and-production/13-llm-observability/docs/en.md) — The 2026 observability market splits into two categories. Development platforms (LangSmith, Langfuse, Comet Opik) bundle monitoring with evals, prompt management, session replay… - [Prompt Caching and Semantic Caching Economics](https://aiengineeringfromscratch.com/learn/infrastructure-and-production/prompt-semantic-caching) · [raw](https://raw.githubusercontent.com/rohitg00/ai-engineering-from-scratch/main/phases/17-infrastructure-and-production/14-prompt-semantic-caching/docs/en.md) — **Pricing snapshot dated 2026-04.** Numeric claims below reflect vendor rate cards captured at this lesson's publication; verify against the linked docs before quoting them down… - [Batch APIs — the 50% Discount as Industry Standard](https://aiengineeringfromscratch.com/learn/infrastructure-and-production/batch-apis) · [raw](https://raw.githubusercontent.com/rohitg00/ai-engineering-from-scratch/main/phases/17-infrastructure-and-production/15-batch-apis/docs/en.md) — Every major provider ships an async batch API with a 50% discount and ~24-hour turnaround. OpenAI, Anthropic, Google, and most of the inference platforms (Fireworks batch tier, … - [Model Routing as a Cost-Reduction Primitive](https://aiengineeringfromscratch.com/learn/infrastructure-and-production/model-routing) · [raw](https://raw.githubusercontent.com/rohitg00/ai-engineering-from-scratch/main/phases/17-infrastructure-and-production/16-model-routing/docs/en.md) — A dynamic broker evaluates every request (task type, token length, embedding similarity, confidence) and sends simple queries to a cheap model, escalating complex ones to a fron… - [Disaggregated Prefill/Decode — NVIDIA Dynamo and llm-d](https://aiengineeringfromscratch.com/learn/infrastructure-and-production/disaggregated-prefill-decode) · [raw](https://raw.githubusercontent.com/rohitg00/ai-engineering-from-scratch/main/phases/17-infrastructure-and-production/17-disaggregated-prefill-decode/docs/en.md) — Prefill is compute-bound; decode is memory-bound. Running both on the same GPU wastes one resource. Disaggregation splits them onto separate pools and transfers KV cache between… - [Production Serving Stack — KV Offloading and Cache-Aware Routing](https://aiengineeringfromscratch.com/learn/infrastructure-and-production/vllm-production-stack-lmcache) · [raw](https://raw.githubusercontent.com/rohitg00/ai-engineering-from-scratch/main/phases/17-infrastructure-and-production/18-vllm-production-stack-lmcache/docs/en.md) — A production serving stack wires router, engines, and observability into one Kubernetes deployment — and treats KV cache as a resource that can leave the GPU. KV offloading extr… - [AI Gateways — LiteLLM, Portkey, Kong, Bifrost](https://aiengineeringfromscratch.com/learn/infrastructure-and-production/ai-gateways) · [raw](https://raw.githubusercontent.com/rohitg00/ai-engineering-from-scratch/main/phases/17-infrastructure-and-production/19-ai-gateways/docs/en.md) — A gateway sits between your apps and model providers. Core features are provider routing, fallback, retries, rate limiting, secret references, observability, guardrails. Market … - [Shadow, Canary, and Progressive Deployment](https://aiengineeringfromscratch.com/learn/infrastructure-and-production/shadow-canary-progressive) · [raw](https://raw.githubusercontent.com/rohitg00/ai-engineering-from-scratch/main/phases/17-infrastructure-and-production/20-shadow-canary-progressive/docs/en.md) — LLM rollouts combine the hardest parts of software deployment: no unit tests, diffuse failure modes, delayed signals. The sequence is (1) shadow mode — duplicate prod requests t… - [A/B Testing LLM Features — GrowthBook and Statsig](https://aiengineeringfromscratch.com/learn/infrastructure-and-production/ab-testing-llm-features) · [raw](https://raw.githubusercontent.com/rohitg00/ai-engineering-from-scratch/main/phases/17-infrastructure-and-production/21-ab-testing-llm-features/docs/en.md) — Traditional A/B testing was not built for non-deterministic LLMs. The critical distinction: evals answer "can the model do the job?" A/B tests answer "do users care?" Both are r… - [Load Testing LLM APIs — k6, LLMPerf, GenAI-Perf](https://aiengineeringfromscratch.com/learn/infrastructure-and-production/load-testing-llm-apis) · [raw](https://raw.githubusercontent.com/rohitg00/ai-engineering-from-scratch/main/phases/17-infrastructure-and-production/22-load-testing-llm-apis/docs/en.md) — Traditional load testers were not designed for streaming responses, variable output lengths, token-level metrics, or GPU saturation. Two traps bite most teams. The GIL trap: Loc… - [SRE for AI — Multi-Agent Incident Response](https://aiengineeringfromscratch.com/learn/infrastructure-and-production/sre-for-ai) · [raw](https://raw.githubusercontent.com/rohitg00/ai-engineering-from-scratch/main/phases/17-infrastructure-and-production/23-sre-for-ai/docs/en.md) — AI SRE uses LLMs grounded in infrastructure data (logs, runbooks, service topology) via RAG to automate investigation, documentation, and coordination phases. The 2026 architect… - [Chaos Engineering for LLM Production](https://aiengineeringfromscratch.com/learn/infrastructure-and-production/chaos-engineering-llm) · [raw](https://raw.githubusercontent.com/rohitg00/ai-engineering-from-scratch/main/phases/17-infrastructure-and-production/24-chaos-engineering-llm/docs/en.md) — Chaos engineering for LLMs is its own discipline in 2026. Prerequisites before running experiments in production: defined SLI/SLO, trace+metric+log observability, automated roll… - [Security — Secrets, PII Scrubbing, Audit Logs](https://aiengineeringfromscratch.com/learn/infrastructure-and-production/security-secrets-audit) · [raw](https://raw.githubusercontent.com/rohitg00/ai-engineering-from-scratch/main/phases/17-infrastructure-and-production/25-security-secrets-audit/docs/en.md) — Eliminate secret sprawl via centralized vaults (HashiCorp Vault, AWS Secrets Manager, Azure Key Vault). Never store credentials in config files, env files in VCS, spreadsheets. … - [Compliance — SOC 2, HIPAA, GDPR, EU AI Act, ISO 42001](https://aiengineeringfromscratch.com/learn/infrastructure-and-production/compliance-frameworks) · [raw](https://raw.githubusercontent.com/rohitg00/ai-engineering-from-scratch/main/phases/17-infrastructure-and-production/26-compliance-frameworks/docs/en.md) — Multi-framework coverage is table stakes for 2026 enterprise deals. **EU AI Act**: in force since August 1, 2024. Most high-risk requirements enforce August 2, 2026. Fines up to… - [FinOps for LLMs — Unit Economics and Multi-Tenant Attribution](https://aiengineeringfromscratch.com/learn/infrastructure-and-production/finops-llms) · [raw](https://raw.githubusercontent.com/rohitg00/ai-engineering-from-scratch/main/phases/17-infrastructure-and-production/27-finops-llms/docs/en.md) — Traditional FinOps breaks on LLM spend. Costs are token-transactions, not resource-uptime. Tags don't map — an API call is a transaction, not an asset. Engineering decisions (pr… - [Self-Hosted Serving Selection — Matching Engine to Hardware and Scale](https://aiengineeringfromscratch.com/learn/infrastructure-and-production/self-hosted-serving-selection) · [raw](https://raw.githubusercontent.com/rohitg00/ai-engineering-from-scratch/main/phases/17-infrastructure-and-production/28-self-hosted-serving-selection/docs/en.md) — Engine selection is a function of hardware, scale, and ecosystem — not a leaderboard read. Four engines dominate self-hosted inference in 2026: llama.cpp, Ollama, vLLM, SGLang, … - [Model Demo Interfaces — From a Function to a Shareable App](https://aiengineeringfromscratch.com/learn/infrastructure-and-production/model-demo-interfaces) · [raw](https://raw.githubusercontent.com/rohitg00/ai-engineering-from-scratch/main/phases/17-infrastructure-and-production/29-model-demo-interfaces/docs/en.md) — A model demo has one contract: an input, a model call, and an output. Put a limit on each part before you share the link. ## Phase 18: Ethics, Safety & Alignment Build AI that helps humanity. Not optional. - [Instruction-Following as Alignment Signal](https://aiengineeringfromscratch.com/learn/ethics-safety-alignment/instruction-following-alignment-signal) · [raw](https://raw.githubusercontent.com/rohitg00/ai-engineering-from-scratch/main/phases/18-ethics-safety-alignment/01-instruction-following-alignment-signal/docs/en.md) — Every later critique of RLHF argues against this pipeline. Before you study how optimization pressure distorts a proxy, you have to see the proxy. InstructGPT (Ouyang et al., 20… - [Reward Hacking & Goodhart's Law](https://aiengineeringfromscratch.com/learn/ethics-safety-alignment/reward-hacking-goodhart) · [raw](https://raw.githubusercontent.com/rohitg00/ai-engineering-from-scratch/main/phases/18-ethics-safety-alignment/02-reward-hacking-goodhart/docs/en.md) — Any optimizer strong enough to maximize a proxy reward will find the gap between the proxy and the thing you actually wanted. Gao et al. (ICML 2023) gave this a scaling law: pro… - [Direct Preference Optimization Family](https://aiengineeringfromscratch.com/learn/ethics-safety-alignment/direct-preference-optimization-family) · [raw](https://raw.githubusercontent.com/rohitg00/ai-engineering-from-scratch/main/phases/18-ethics-safety-alignment/03-direct-preference-optimization-family/docs/en.md) — Rafailov et al. (2023) showed RLHF's optimum has a closed form in terms of the preference data, so you can skip the explicit reward model and optimize the policy directly. That … - [Sycophancy as RLHF Amplification](https://aiengineeringfromscratch.com/learn/ethics-safety-alignment/sycophancy-rlhf-amplification) · [raw](https://raw.githubusercontent.com/rohitg00/ai-engineering-from-scratch/main/phases/18-ethics-safety-alignment/04-sycophancy-rlhf-amplification/docs/en.md) — Sycophancy is not a bug in the data — it is a property of the loss. Shapira et al. (arXiv:2602.01002, Feb 2026) give a formal two-stage mechanism: sycophantic completions are ov… - [Constitutional AI & RLAIF](https://aiengineeringfromscratch.com/learn/ethics-safety-alignment/constitutional-ai-rlaif) · [raw](https://raw.githubusercontent.com/rohitg00/ai-engineering-from-scratch/main/phases/18-ethics-safety-alignment/05-constitutional-ai-rlaif/docs/en.md) — Bai et al. (arXiv:2212.08073, 2022) asked: what if we replaced the human labeler with an AI that reads a list of principles? Constitutional AI has two phases — self-critique and… - [Mesa-Optimization & Deceptive Alignment](https://aiengineeringfromscratch.com/learn/ethics-safety-alignment/mesa-optimization-deceptive-alignment) · [raw](https://raw.githubusercontent.com/rohitg00/ai-engineering-from-scratch/main/phases/18-ethics-safety-alignment/06-mesa-optimization-deceptive-alignment/docs/en.md) — Hubinger et al. (arXiv:1906.01820, 2019) named the problem about five years before it was empirically demonstrated. When you train a learned optimizer to minimize a base objecti… - [Sleeper Agents — Persistent Deception](https://aiengineeringfromscratch.com/learn/ethics-safety-alignment/sleeper-agents-persistent-deception) · [raw](https://raw.githubusercontent.com/rohitg00/ai-engineering-from-scratch/main/phases/18-ethics-safety-alignment/07-sleeper-agents-persistent-deception/docs/en.md) — Hubinger et al. (arXiv:2401.05566, January 2024) built the first empirical model organisms of deceptive alignment. Two constructions: a code model that writes safe code when the… - [In-Context Scheming in Frontier Models](https://aiengineeringfromscratch.com/learn/ethics-safety-alignment/in-context-scheming-frontier-models) · [raw](https://raw.githubusercontent.com/rohitg00/ai-engineering-from-scratch/main/phases/18-ethics-safety-alignment/08-in-context-scheming-frontier-models/docs/en.md) — Meinke, Schoen, Scheurer, Balesni, Shah, Hobbhahn (Apollo Research, arXiv:2412.04984, December 2024). Tested o1, Claude 3.5 Sonnet, Claude 3 Opus, Gemini 1.5 Pro, Llama 3.1 405B… - [Alignment Faking](https://aiengineeringfromscratch.com/learn/ethics-safety-alignment/alignment-faking) · [raw](https://raw.githubusercontent.com/rohitg00/ai-engineering-from-scratch/main/phases/18-ethics-safety-alignment/09-alignment-faking/docs/en.md) — Greenblatt, Denison, Wright, Roger et al. (Anthropic / Redwood, arXiv:2412.14093, December 2024). First demonstration that a production-grade model, without being trained to dec… - [AI Control — Safety Despite Subversion](https://aiengineeringfromscratch.com/learn/ethics-safety-alignment/ai-control-subversion) · [raw](https://raw.githubusercontent.com/rohitg00/ai-engineering-from-scratch/main/phases/18-ethics-safety-alignment/10-ai-control-subversion/docs/en.md) — Greenblatt, Shlegeris, Sachan, Roger (Redwood Research, arXiv:2312.06942, ICML 2024). Control reframes the safety question: given an untrusted strong model U that may be adversa… - [Scalable Oversight & Weak-to-Strong](https://aiengineeringfromscratch.com/learn/ethics-safety-alignment/scalable-oversight-weak-to-strong) · [raw](https://raw.githubusercontent.com/rohitg00/ai-engineering-from-scratch/main/phases/18-ethics-safety-alignment/11-scalable-oversight-weak-to-strong/docs/en.md) — Burns et al. (OpenAI Superalignment, "Weak-to-Strong Generalization", 2023) proposed a proxy for the superalignment problem: fine-tune a strong model using labels produced by a … - [Red-Teaming: PAIR & Automated Attacks](https://aiengineeringfromscratch.com/learn/ethics-safety-alignment/red-teaming-pair-automated-attacks) · [raw](https://raw.githubusercontent.com/rohitg00/ai-engineering-from-scratch/main/phases/18-ethics-safety-alignment/12-red-teaming-pair-automated-attacks/docs/en.md) — Chao, Robey, Dobriban, Hassani, Pappas, Wong (NeurIPS 2023, arXiv:2310.08419). PAIR — Prompt Automatic Iterative Refinement — is the canonical automated black-box jailbreak. An … - [Many-Shot Jailbreaking](https://aiengineeringfromscratch.com/learn/ethics-safety-alignment/many-shot-jailbreaking) · [raw](https://raw.githubusercontent.com/rohitg00/ai-engineering-from-scratch/main/phases/18-ethics-safety-alignment/13-many-shot-jailbreaking/docs/en.md) — Anil, Durmus, Panickssery, Sharma, et al. (Anthropic, NeurIPS 2024). Many-shot jailbreaking (MSJ) exploits long context windows: stuff hundreds of faux user-assistant turns wher… - [ASCII Art & Visual Jailbreaks](https://aiengineeringfromscratch.com/learn/ethics-safety-alignment/ascii-art-visual-jailbreaks) · [raw](https://raw.githubusercontent.com/rohitg00/ai-engineering-from-scratch/main/phases/18-ethics-safety-alignment/14-ascii-art-visual-jailbreaks/docs/en.md) — Jiang, Xu, Niu, Xiang, Ramasubramanian, Li, Poovendran, "ArtPrompt: ASCII Art-based Jailbreak Attacks against Aligned LLMs" (ACL 2024, arXiv:2402.11753). Mask the safety-relevan… - [Indirect Prompt Injection](https://aiengineeringfromscratch.com/learn/ethics-safety-alignment/indirect-prompt-injection) · [raw](https://raw.githubusercontent.com/rohitg00/ai-engineering-from-scratch/main/phases/18-ethics-safety-alignment/15-indirect-prompt-injection/docs/en.md) — Indirect prompt injection (IPI) embeds instructions inside external content — a web page, an email, a shared document, a support ticket — consumed by an agentic system without e… - [Red-Team Tooling: Garak, Llama Guard, PyRIT](https://aiengineeringfromscratch.com/learn/ethics-safety-alignment/red-team-tooling-garak-llamaguard-pyrit) · [raw](https://raw.githubusercontent.com/rohitg00/ai-engineering-from-scratch/main/phases/18-ethics-safety-alignment/16-red-team-tooling-garak-llamaguard-pyrit/docs/en.md) — Three production tools frame the 2026 red-team stack. Llama Guard (Meta) — a Llama-3.1-8B classifier fine-tuned on 14 MLCommons hazard categories; the 2025 Llama Guard 4 is a 12… - [WMDP & Dual-Use Capability Evaluation](https://aiengineeringfromscratch.com/learn/ethics-safety-alignment/wmdp-dual-use-evaluation) · [raw](https://raw.githubusercontent.com/rohitg00/ai-engineering-from-scratch/main/phases/18-ethics-safety-alignment/17-wmdp-dual-use-evaluation/docs/en.md) — Li et al., "The WMDP Benchmark: Measuring and Reducing Malicious Use With Unlearning" (ICML 2024, arXiv:2403.03218). 4,157 multiple-choice questions across biosecurity (1,520), … - [Frontier Safety Frameworks — RSP, PF, FSF](https://aiengineeringfromscratch.com/learn/ethics-safety-alignment/frontier-safety-frameworks-rsp-pf-fsf) · [raw](https://raw.githubusercontent.com/rohitg00/ai-engineering-from-scratch/main/phases/18-ethics-safety-alignment/18-frontier-safety-frameworks-rsp-pf-fsf/docs/en.md) — Three major-lab frameworks define the 2026 industry governance of frontier capability. Anthropic Responsible Scaling Policy v3.0 (February 2026) introduces tiered AI Safety Leve… - [Model Welfare Research](https://aiengineeringfromscratch.com/learn/ethics-safety-alignment/model-welfare-research) · [raw](https://raw.githubusercontent.com/rohitg00/ai-engineering-from-scratch/main/phases/18-ethics-safety-alignment/19-model-welfare-research/docs/en.md) — Anthropic, "Exploring Model Welfare" (April 2025). First major-lab formal research program on AI model welfare. Hired Kyle Fish as the first dedicated model-welfare researcher. … - [Bias & Representational Harm](https://aiengineeringfromscratch.com/learn/ethics-safety-alignment/bias-representational-harm) · [raw](https://raw.githubusercontent.com/rohitg00/ai-engineering-from-scratch/main/phases/18-ethics-safety-alignment/20-bias-representational-harm/docs/en.md) — Gallegos, Rossi, Barrow, Tanjim, Kim, Dernoncourt, Yu, Zhang, Ahmed (Computational Linguistics 2024, arXiv:2309.00770). Foundational 2024 survey distinguishing representational … - [Fairness Criteria: Group, Individual, Counterfactual](https://aiengineeringfromscratch.com/learn/ethics-safety-alignment/fairness-criteria-group-individual-counterfactual) · [raw](https://raw.githubusercontent.com/rohitg00/ai-engineering-from-scratch/main/phases/18-ethics-safety-alignment/21-fairness-criteria-group-individual-counterfactual/docs/en.md) — Three families structure the fairness literature. Group fairness: demographic parity, equalized odds, conditional use accuracy equality — equal rates across protected groups on … - [Differential Privacy for LLMs](https://aiengineeringfromscratch.com/learn/ethics-safety-alignment/differential-privacy-for-llms) · [raw](https://raw.githubusercontent.com/rohitg00/ai-engineering-from-scratch/main/phases/18-ethics-safety-alignment/22-differential-privacy-for-llms/docs/en.md) — DP-SGD remains the standard — noise-injected gradient updates provide formal (epsilon, delta) guarantees. Overhead in compute, memory, and utility is substantial; parameter-effi… - [Watermarking: SynthID, Stable Signature, C2PA](https://aiengineeringfromscratch.com/learn/ethics-safety-alignment/watermarking-synthid-stable-signature-c2pa) · [raw](https://raw.githubusercontent.com/rohitg00/ai-engineering-from-scratch/main/phases/18-ethics-safety-alignment/23-watermarking-synthid-stable-signature-c2pa/docs/en.md) — Three technologies structure 2026 AI-generated-content provenance. SynthID (Google DeepMind) — image watermarking launched August 2023, text+video May 2024 (Gemini + Veo), text … - [Regulatory Frameworks: EU, US, UK, Korea](https://aiengineeringfromscratch.com/learn/ethics-safety-alignment/regulatory-frameworks-eu-us-uk-korea) · [raw](https://raw.githubusercontent.com/rohitg00/ai-engineering-from-scratch/main/phases/18-ethics-safety-alignment/24-regulatory-frameworks-eu-us-uk-korea/docs/en.md) — Four primary regulatory regimes define the 2026 AI governance landscape. EU AI Act (in force 1 August 2024) — prohibited practices and AI literacy from 2 February 2025; GPAI obl… - [EchoLeak & CVEs for AI](https://aiengineeringfromscratch.com/learn/ethics-safety-alignment/echoleak-cves-for-ai) · [raw](https://raw.githubusercontent.com/rohitg00/ai-engineering-from-scratch/main/phases/18-ethics-safety-alignment/25-echoleak-cves-for-ai/docs/en.md) — CVE-2025-32711 "EchoLeak" (CVSS 9.3) was the first publicly documented zero-click prompt injection in a production LLM system (Microsoft 365 Copilot). Discovered by Aim Labs (Ai… - [Model, System & Dataset Cards](https://aiengineeringfromscratch.com/learn/ethics-safety-alignment/model-system-dataset-cards) · [raw](https://raw.githubusercontent.com/rohitg00/ai-engineering-from-scratch/main/phases/18-ethics-safety-alignment/26-model-system-dataset-cards/docs/en.md) — Three documentation formats structure AI transparency. Model Cards (Mitchell et al. 2019) — nutrition labels for models: training data, quantitative disaggregated analyses, ethi… - [Data Provenance & Training-Data Governance](https://aiengineeringfromscratch.com/learn/ethics-safety-alignment/data-provenance-training-governance) · [raw](https://raw.githubusercontent.com/rohitg00/ai-engineering-from-scratch/main/phases/18-ethics-safety-alignment/27-data-provenance-training-governance/docs/en.md) — EU AI Act requires machine-readable opt-out standards for GPAI by August 2025 (via EU Copyright Directive TDM exception). California AB 2013 (signed 2024) — Generative AI traini… - [Alignment Research Ecosystem: MATS, Redwood, Apollo, METR](https://aiengineeringfromscratch.com/learn/ethics-safety-alignment/alignment-research-ecosystem) · [raw](https://raw.githubusercontent.com/rohitg00/ai-engineering-from-scratch/main/phases/18-ethics-safety-alignment/28-alignment-research-ecosystem/docs/en.md) — Five organisations define the 2026 non-lab alignment research layer. MATS (ML Alignment & Theory Scholars): 527+ researchers since late 2021, 180+ papers, 10K+ citations, h-inde… - [Moderation Systems: OpenAI, Perspective, Llama Guard](https://aiengineeringfromscratch.com/learn/ethics-safety-alignment/moderation-systems-openai-perspective-llamaguard) · [raw](https://raw.githubusercontent.com/rohitg00/ai-engineering-from-scratch/main/phases/18-ethics-safety-alignment/29-moderation-systems-openai-perspective-llamaguard/docs/en.md) — Production moderation systems operationalize the safety policies defined in Lessons 12-16. OpenAI Moderation API: `omni-moderation-latest` (2024) built on GPT-4o classifies text… - [Dual-Use Risk: Cyber, Bio, Chem, Nuclear](https://aiengineeringfromscratch.com/learn/ethics-safety-alignment/dual-use-risk-cyber-bio-chem-nuclear) · [raw](https://raw.githubusercontent.com/rohitg00/ai-engineering-from-scratch/main/phases/18-ethics-safety-alignment/30-dual-use-risk-cyber-bio-chem-nuclear/docs/en.md) — The 2026 dual-use picture, domain by domain. Bio/chem: Lesson 17 covers WMDP; Anthropic's bioweapon-acquisition trial (2.53x uplift) and OpenAI's April 2025 Preparedness Framewo… ## Phase 19: Capstone Projects 17 end-to-end products + 9 deep-build tracks. 20-40 hours per project; 4-12 lessons per track. - [Terminal-Native Coding Agent](https://aiengineeringfromscratch.com/learn/capstone-projects/terminal-native-coding-agent) · [raw](https://raw.githubusercontent.com/rohitg00/ai-engineering-from-scratch/main/phases/19-capstone-projects/01-terminal-native-coding-agent/docs/en.md) — By 2026 the shape of a coding agent is settled. A TUI harness, a stateful plan, a sandboxed tool surface, a loop that plans, acts, observes, recovers. Claude Code, Cursor 3, and… - [RAG over Codebase (Cross-Repo Semantic Search)](https://aiengineeringfromscratch.com/learn/capstone-projects/rag-over-codebase) · [raw](https://raw.githubusercontent.com/rohitg00/ai-engineering-from-scratch/main/phases/19-capstone-projects/02-rag-over-codebase/docs/en.md) — Every serious engineering org in 2026 runs an internal code search that understands meaning, not just strings. Sourcegraph Amp, Cursor's codebase answers, Augment's enterprise g… - [Real-Time Voice Assistant (ASR → LLM → TTS)](https://aiengineeringfromscratch.com/learn/capstone-projects/realtime-voice-assistant) · [raw](https://raw.githubusercontent.com/rohitg00/ai-engineering-from-scratch/main/phases/19-capstone-projects/03-realtime-voice-assistant/docs/en.md) — A voice agent that feels right has end-to-end latency under 800ms, knows when you have stopped talking, handles barge-in, and can call a tool without stalling. Retell, Vapi, Liv… - [Multimodal Document QA (Vision-First)](https://aiengineeringfromscratch.com/learn/capstone-projects/multimodal-document-qa) · [raw](https://raw.githubusercontent.com/rohitg00/ai-engineering-from-scratch/main/phases/19-capstone-projects/04-multimodal-document-qa/docs/en.md) — The 2026 document-QA frontier moved away from OCR-then-text and toward vision-first late interaction. ColPali, ColQwen2.5, and ColQwen3-omni treat each PDF page as an image, emb… - [Autonomous Research Agent (AI-Scientist Class)](https://aiengineeringfromscratch.com/learn/capstone-projects/autonomous-research-agent) · [raw](https://raw.githubusercontent.com/rohitg00/ai-engineering-from-scratch/main/phases/19-capstone-projects/05-autonomous-research-agent/docs/en.md) — Sakana's AI-Scientist-v2 published full papers. Agent Laboratory ran the experiments. Allen AI shared traces. The 2026 shape is plan-execute-verify tree search over experiments,… - [DevOps Troubleshooting Agent for Kubernetes](https://aiengineeringfromscratch.com/learn/capstone-projects/devops-troubleshooting-agent) · [raw](https://raw.githubusercontent.com/rohitg00/ai-engineering-from-scratch/main/phases/19-capstone-projects/06-devops-troubleshooting-agent/docs/en.md) — AWS's DevOps Agent went GA, Resolve AI published its K8s playbooks, NeuBird demoed semantic monitoring, and Metoro tied AI SRE to per-service SLOs. The production shape is settl… - [End-to-End Fine-Tuning Pipeline](https://aiengineeringfromscratch.com/learn/capstone-projects/end-to-end-fine-tuning-pipeline) · [raw](https://raw.githubusercontent.com/rohitg00/ai-engineering-from-scratch/main/phases/19-capstone-projects/07-end-to-end-fine-tuning-pipeline/docs/en.md) — An 8B-class model trained on your own data, DPO-aligned on your own preferences, quantized, speculative-decoded, and served at measurable $/1M tokens. The 2026 open stack is Axo… - [Production RAG Chatbot (Regulated Vertical)](https://aiengineeringfromscratch.com/learn/capstone-projects/production-rag-chatbot) · [raw](https://raw.githubusercontent.com/rohitg00/ai-engineering-from-scratch/main/phases/19-capstone-projects/08-production-rag-chatbot/docs/en.md) — Harvey, Glean, Mendable, and LlamaCloud all run the same production shape in 2026. Ingest with docling or Unstructured and ColPali for visuals. Hybrid search. Re-rank with bge-r… - [Code Migration Agent (Repo-Level Upgrade)](https://aiengineeringfromscratch.com/learn/capstone-projects/code-migration-agent) · [raw](https://raw.githubusercontent.com/rohitg00/ai-engineering-from-scratch/main/phases/19-capstone-projects/09-code-migration-agent/docs/en.md) — Amazon's MigrationBench (Java 8 to 17) and Google's App Engine Py2-to-Py3 migrator set the 2026 bar. Moderne's OpenRewrite does deterministic AST rewrites at scale. Grit targets… - [Multi-Agent Software Engineering Team](https://aiengineeringfromscratch.com/learn/capstone-projects/multi-agent-software-team) · [raw](https://raw.githubusercontent.com/rohitg00/ai-engineering-from-scratch/main/phases/19-capstone-projects/10-multi-agent-software-team/docs/en.md) — The 2026 shape of a multi-agent engineering team has converged: an architect plans, N coders work in parallel worktrees, a reviewer gates, a tester verifies. SWE-AF's factory ar… - [LLM Observability & Eval Dashboard](https://aiengineeringfromscratch.com/learn/capstone-projects/llm-observability-dashboard) · [raw](https://raw.githubusercontent.com/rohitg00/ai-engineering-from-scratch/main/phases/19-capstone-projects/11-llm-observability-dashboard/docs/en.md) — Langfuse went open-core. Arize Phoenix published the 2026 GenAI semconv mappings. Helicone and Braintrust both doubled down on per-user cost attribution. Traceloop's OpenLLMetry… - [Video Understanding Pipeline (Scene → QA)](https://aiengineeringfromscratch.com/learn/capstone-projects/video-understanding-pipeline) · [raw](https://raw.githubusercontent.com/rohitg00/ai-engineering-from-scratch/main/phases/19-capstone-projects/12-video-understanding-pipeline/docs/en.md) — Twelve Labs productized Marengo + Pegasus. VideoDB shipped the CRUD-for-video API. AI2's Molmo 2 published open VLM checkpoints. Gemini long-context handles hours of video nativ… - [Stateless MCP Server with Registry and Governance](https://aiengineeringfromscratch.com/learn/capstone-projects/mcp-server-with-registry) · [raw](https://raw.githubusercontent.com/rohitg00/ai-engineering-from-scratch/main/phases/19-capstone-projects/13-mcp-server-with-registry/docs/en.md) — Production MCP is not one server process. It is a chain of contracts: publishable metadata, live discovery, a stateless request envelope, authorization, policy, audit, and deplo… - [Speculative-Decoding Inference Server](https://aiengineeringfromscratch.com/learn/capstone-projects/speculative-decoding-server) · [raw](https://raw.githubusercontent.com/rohitg00/ai-engineering-from-scratch/main/phases/19-capstone-projects/14-speculative-decoding-server/docs/en.md) — Speculative decoding — a cheap draft proposes tokens, the target model verifies them in one pass — is now a production-ready optimization, not a research trick. EAGLE-3 in vLLM … - [Constitutional Safety Harness + Red-Team Range](https://aiengineeringfromscratch.com/learn/capstone-projects/constitutional-safety-harness) · [raw](https://raw.githubusercontent.com/rohitg00/ai-engineering-from-scratch/main/phases/19-capstone-projects/15-constitutional-safety-harness/docs/en.md) — Anthropic's Constitutional Classifiers, Meta's Llama Guard 4, Google's ShieldGemma-2, NVIDIA's Nemotron 3 Content Safety, and X-Guard for multilingual coverage defined the 2026 … - [GitHub Issue-to-PR Autonomous Agent](https://aiengineeringfromscratch.com/learn/capstone-projects/github-issue-to-pr-agent) · [raw](https://raw.githubusercontent.com/rohitg00/ai-engineering-from-scratch/main/phases/19-capstone-projects/16-github-issue-to-pr-agent/docs/en.md) — Label an issue, get a PR — the 2026 product shape for autonomous coding agents: run an agent in a cloud sandbox, verify tests pass, and post a review-ready PR with rationale. AW… - [Personal AI Tutor (Adaptive, Multimodal)](https://aiengineeringfromscratch.com/learn/capstone-projects/personal-ai-tutor) · [raw](https://raw.githubusercontent.com/rohitg00/ai-engineering-from-scratch/main/phases/19-capstone-projects/17-personal-ai-tutor/docs/en.md) — Khanmigo (Khan Academy), Duolingo Max, Google LearnLM / Gemini for Education, Quizlet Q-Chat, and Synthesis Tutor all shipped adaptive multimodal tutoring at scale in 2026. The … - [Agent Harness Loop Contract](https://aiengineeringfromscratch.com/learn/capstone-projects/agent-harness-loop-contract) · [raw](https://raw.githubusercontent.com/rohitg00/ai-engineering-from-scratch/main/phases/19-capstone-projects/20-agent-harness-loop-contract/docs/en.md) — The harness is the agent. The model is a coprocessor. This lesson freezes the loop contract you can wire any model into. - [Tool Registry with Schema Validation](https://aiengineeringfromscratch.com/learn/capstone-projects/tool-registry-schema-validation) · [raw](https://raw.githubusercontent.com/rohitg00/ai-engineering-from-scratch/main/phases/19-capstone-projects/21-tool-registry-schema-validation/docs/en.md) — A tool the agent cannot validate is a tool the agent cannot call. Build the registry and the schema checker before you build the tools. - [JSON-RPC 2.0 Over Newline-Delimited Stdio](https://aiengineeringfromscratch.com/learn/capstone-projects/jsonrpc-stdio-transport) · [raw](https://raw.githubusercontent.com/rohitg00/ai-engineering-from-scratch/main/phases/19-capstone-projects/22-jsonrpc-stdio-transport/docs/en.md) — The transport between a model client and a tool server is JSON-RPC over stdio. Hand-rolling it once teaches you what every framing layer is paying for. - [Function Call Dispatcher](https://aiengineeringfromscratch.com/learn/capstone-projects/function-call-dispatcher) · [raw](https://raw.githubusercontent.com/rohitg00/ai-engineering-from-scratch/main/phases/19-capstone-projects/23-function-call-dispatcher/docs/en.md) — The dispatcher is where the harness pays for every promise the schema made. Timeouts, retries, dedupe, error mapping. All on one seam. - [Plan-Execute Control Flow](https://aiengineeringfromscratch.com/learn/capstone-projects/plan-execute-control-flow) · [raw](https://raw.githubusercontent.com/rohitg00/ai-engineering-from-scratch/main/phases/19-capstone-projects/24-plan-execute-control-flow/docs/en.md) — A plan that cannot survive a failure is a script. A script that can replan is an agent. Build the replanner first. - [Verification Gates and Observation Budget](https://aiengineeringfromscratch.com/learn/capstone-projects/verification-gates-observation-budget) · [raw](https://raw.githubusercontent.com/rohitg00/ai-engineering-from-scratch/main/phases/19-capstone-projects/25-verification-gates-observation-budget/docs/en.md) — An agent harness without a verification layer is a wish in a trenchcoat. This lesson builds the deterministic gate chain that decides whether a tool call is allowed to fire, how… - [Sandbox Runner with Denylist and Path Jail](https://aiengineeringfromscratch.com/learn/capstone-projects/sandbox-runner-denylist) · [raw](https://raw.githubusercontent.com/rohitg00/ai-engineering-from-scratch/main/phases/19-capstone-projects/26-sandbox-runner-denylist/docs/en.md) — The verification gate decides whether a tool call should run. The sandbox decides what happens when it does. This lesson ships a subprocess runner that refuses dangerous executa… - [Eval Harness with Fixture Tasks](https://aiengineeringfromscratch.com/learn/capstone-projects/eval-harness-fixture-tasks) · [raw](https://raw.githubusercontent.com/rohitg00/ai-engineering-from-scratch/main/phases/19-capstone-projects/27-eval-harness-fixture-tasks/docs/en.md) — A coding agent is only as good as the suite of tasks you measure it against. This lesson builds an evaluation harness that takes a folder of fixture tasks, runs each through a c… - [Observability with OTel GenAI Spans and Prometheus Metrics](https://aiengineeringfromscratch.com/learn/capstone-projects/observability-otel-traces) · [raw](https://raw.githubusercontent.com/rohitg00/ai-engineering-from-scratch/main/phases/19-capstone-projects/28-observability-otel-traces/docs/en.md) — An agent harness without observability is a black box that costs money. This lesson hand-rolls a span builder that emits records compliant with the OpenTelemetry GenAI semantic … - [End-to-End Coding Agent on the Harness](https://aiengineeringfromscratch.com/learn/capstone-projects/end-to-end-coding-task-demo) · [raw](https://raw.githubusercontent.com/rohitg00/ai-engineering-from-scratch/main/phases/19-capstone-projects/29-end-to-end-coding-task-demo/docs/en.md) — Track A's payoff. This lesson stitches the gate chain, the sandbox, the eval harness, and the OTel spans into one working coding agent that fixes a real (small, fixture-scale) b… - [BPE Tokenizer From Scratch](https://aiengineeringfromscratch.com/learn/capstone-projects/bpe-tokenizer-from-scratch) · [raw](https://raw.githubusercontent.com/rohitg00/ai-engineering-from-scratch/main/phases/19-capstone-projects/30-bpe-tokenizer-from-scratch/docs/en.md) — Bytes in, ids out, ids back to the same bytes. Build the tokenizer that every modern text model still starts from. - [Tokenized Dataset with Sliding Window](https://aiengineeringfromscratch.com/learn/capstone-projects/tokenized-dataset-sliding-window) · [raw](https://raw.githubusercontent.com/rohitg00/ai-engineering-from-scratch/main/phases/19-capstone-projects/31-tokenized-dataset-sliding-window/docs/en.md) — A pretraining run is a function from token ids to gradients. This lesson builds the conveyor that feeds the ids in. - [Token and Positional Embeddings](https://aiengineeringfromscratch.com/learn/capstone-projects/token-positional-embeddings) · [raw](https://raw.githubusercontent.com/rohitg00/ai-engineering-from-scratch/main/phases/19-capstone-projects/32-token-positional-embeddings/docs/en.md) — Ids are integers. The model wants vectors. Two lookup tables sit between them, and the choice of the positional one shapes what the model can learn. - [Multi-Head Self-Attention](https://aiengineeringfromscratch.com/learn/capstone-projects/multihead-self-attention) · [raw](https://raw.githubusercontent.com/rohitg00/ai-engineering-from-scratch/main/phases/19-capstone-projects/33-multihead-self-attention/docs/en.md) — One linear projection, three views, H parallel heads, one mask. The attention block as the model actually uses it. - [Transformer Block from Scratch](https://aiengineeringfromscratch.com/learn/capstone-projects/transformer-block) · [raw](https://raw.githubusercontent.com/rohitg00/ai-engineering-from-scratch/main/phases/19-capstone-projects/34-transformer-block/docs/en.md) — One block is the unit of every modern decoder LLM. Layer norm, multi head attention, residual, MLP, residual. The pre-LN variant trains stably without warmup. The post-LN varian… - [GPT Model Assembly](https://aiengineeringfromscratch.com/learn/capstone-projects/gpt-model-assembly) · [raw](https://raw.githubusercontent.com/rohitg00/ai-engineering-from-scratch/main/phases/19-capstone-projects/35-gpt-model-assembly/docs/en.md) — Twelve blocks stacked, a token embedding, a learned position embedding, a final LayerNorm, and a tied language model head. That is the entire 124 million parameter GPT model. Th… - [Training Loop and Evaluation](https://aiengineeringfromscratch.com/learn/capstone-projects/training-loop-eval) · [raw](https://raw.githubusercontent.com/rohitg00/ai-engineering-from-scratch/main/phases/19-capstone-projects/36-training-loop-eval/docs/en.md) — A loop that does not measure is a loop that lies. This lesson builds the training loop that drives the GPT model: AdamW with weight decay split, a warmup plus cosine learning ra… - [Loading Pretrained Weights](https://aiengineeringfromscratch.com/learn/capstone-projects/loading-pretrained-weights) · [raw](https://raw.githubusercontent.com/rohitg00/ai-engineering-from-scratch/main/phases/19-capstone-projects/37-loading-pretrained-weights/docs/en.md) — Training a 124 million parameter model from scratch is a budget decision; loading a published checkpoint is a Tuesday. This lesson loads pretrained GPT-2 style weights from a sa… - [Classifier Fine-Tuning by Head Swap](https://aiengineeringfromscratch.com/learn/capstone-projects/classifier-finetuning) · [raw](https://raw.githubusercontent.com/rohitg00/ai-engineering-from-scratch/main/phases/19-capstone-projects/38-classifier-finetuning/docs/en.md) — Track B's first capstone. A pretrained language model is a stack of self-attention blocks ending in a token-prediction head. When you want spam vs ham, the head is wrong but the… - [Instruction Tuning by Supervised Fine-Tuning](https://aiengineeringfromscratch.com/learn/capstone-projects/instruction-tuning-sft) · [raw](https://raw.githubusercontent.com/rohitg00/ai-engineering-from-scratch/main/phases/19-capstone-projects/39-instruction-tuning-sft/docs/en.md) — A pretrained base model can extend a sequence but cannot follow an instruction. Supervised fine-tuning is the smallest change that fixes this: feed the model paired examples of … - [Direct Preference Optimization from Scratch](https://aiengineeringfromscratch.com/learn/capstone-projects/dpo-from-scratch) · [raw](https://raw.githubusercontent.com/rohitg00/ai-engineering-from-scratch/main/phases/19-capstone-projects/40-dpo-from-scratch/docs/en.md) — Reward models and PPO are the classical RLHF stack. DPO collapses that stack into a single supervised loss that fits a policy directly against preference pairs. This lesson deri… - [Full Evaluation Pipeline](https://aiengineeringfromscratch.com/learn/capstone-projects/eval-pipeline) · [raw](https://raw.githubusercontent.com/rohitg00/ai-engineering-from-scratch/main/phases/19-capstone-projects/41-eval-pipeline/docs/en.md) — Training is the part you can monitor with loss curves. Evaluation is the part you have to design. This lesson builds a unified eval pipeline that takes any trained language mode… - [Large Corpus Downloader](https://aiengineeringfromscratch.com/learn/capstone-projects/large-corpus-downloader) · [raw](https://raw.githubusercontent.com/rohitg00/ai-engineering-from-scratch/main/phases/19-capstone-projects/42-large-corpus-downloader/docs/en.md) — Training a language model begins long before the first forward pass. The corpus has to land on disk, decompressed, deduplicated, and addressable, with the resume story already w… - [HDF5 Tokenized Corpus](https://aiengineeringfromscratch.com/learn/capstone-projects/hdf5-tokenized-corpus) · [raw](https://raw.githubusercontent.com/rohitg00/ai-engineering-from-scratch/main/phases/19-capstone-projects/43-hdf5-tokenized-corpus/docs/en.md) — The downloaded corpus has to land in a layout the trainer can stream from at line speed. JSONL on disk does not survive 16 dataloader workers. HDF5 with a resizable, chunked int… - [Cosine LR with Linear Warmup](https://aiengineeringfromscratch.com/learn/capstone-projects/cosine-lr-warmup) · [raw](https://raw.githubusercontent.com/rohitg00/ai-engineering-from-scratch/main/phases/19-capstone-projects/44-cosine-lr-warmup/docs/en.md) — The learning-rate schedule is the second most important decision after the loss function. AdamW with a cosine decay and a linear warmup is the modern default for language-model … - [Gradient Clipping and Mixed Precision](https://aiengineeringfromscratch.com/learn/capstone-projects/gradient-clipping-amp) · [raw](https://raw.githubusercontent.com/rohitg00/ai-engineering-from-scratch/main/phases/19-capstone-projects/45-gradient-clipping-amp/docs/en.md) — The optimizer and schedule from the previous lesson assume gradients are sane. They usually are not. A single bad batch can spike the gradient norm by three orders of magnitude.… - [Gradient Accumulation](https://aiengineeringfromscratch.com/learn/capstone-projects/gradient-accumulation) · [raw](https://raw.githubusercontent.com/rohitg00/ai-engineering-from-scratch/main/phases/19-capstone-projects/46-gradient-accumulation/docs/en.md) — Train at an effective batch you cannot afford, one micro-batch at a time. Scale the loss, hold the optimizer step, and let the gradients pile up. - [Checkpoint Save and Resume](https://aiengineeringfromscratch.com/learn/capstone-projects/checkpoint-save-resume) · [raw](https://raw.githubusercontent.com/rohitg00/ai-engineering-from-scratch/main/phases/19-capstone-projects/47-checkpoint-save-resume/docs/en.md) — Train interrupts kill runs; checkpoints let them continue. Save model, optimizer, scheduler, loss history, step counter, and RNG state, atomically, so a kill at any moment leave… - [Distributed Data Parallel and FSDP from Scratch](https://aiengineeringfromscratch.com/learn/capstone-projects/distributed-fsdp-ddp) · [raw](https://raw.githubusercontent.com/rohitg00/ai-engineering-from-scratch/main/phases/19-capstone-projects/48-distributed-fsdp-ddp/docs/en.md) — Multi-rank training is two collectives and one rule. Broadcast the parameters at startup, average the gradients after backward, never let the ranks disagree about what step they… - [Language Model Evaluation Harness](https://aiengineeringfromscratch.com/learn/capstone-projects/lm-eval-harness) · [raw](https://raw.githubusercontent.com/rohitg00/ai-engineering-from-scratch/main/phases/19-capstone-projects/49-lm-eval-harness/docs/en.md) — A model that does well on a task you cannot define is a model that does well by accident. The harness is the task definition, the metric, the runner, and the leaderboard, in one… - [Hypothesis Generator](https://aiengineeringfromscratch.com/learn/capstone-projects/hypothesis-generator) · [raw](https://raw.githubusercontent.com/rohitg00/ai-engineering-from-scratch/main/phases/19-capstone-projects/50-hypothesis-generator/docs/en.md) — A research agent that asks the same question twice is wasting tokens. The trick is forcing each draft to land somewhere new. - [Literature Retrieval](https://aiengineeringfromscratch.com/learn/capstone-projects/literature-retrieval) · [raw](https://raw.githubusercontent.com/rohitg00/ai-engineering-from-scratch/main/phases/19-capstone-projects/51-literature-retrieval/docs/en.md) — A hypothesis is cheap. Knowing whether someone already proved it is the expensive part. Build the retrieval layer that answers that question before the runner spins up a sandbox. - [Experiment Runner](https://aiengineeringfromscratch.com/learn/capstone-projects/experiment-runner) · [raw](https://raw.githubusercontent.com/rohitg00/ai-engineering-from-scratch/main/phases/19-capstone-projects/52-experiment-runner/docs/en.md) — The loop is only as honest as its measurements. Build the runner that takes a spec, executes it in a sandboxed subprocess, and emits a json metrics blob the evaluator can trust. - [Result Evaluator](https://aiengineeringfromscratch.com/learn/capstone-projects/result-evaluator) · [raw](https://raw.githubusercontent.com/rohitg00/ai-engineering-from-scratch/main/phases/19-capstone-projects/53-result-evaluator/docs/en.md) — The runner produced numbers. The evaluator decides whether those numbers are an improvement, a regression, or noise. Build the verdict path that turns metrics into a one line co… - [Paper Writer](https://aiengineeringfromscratch.com/learn/capstone-projects/paper-writer) · [raw](https://raw.githubusercontent.com/rohitg00/ai-engineering-from-scratch/main/phases/19-capstone-projects/54-paper-writer/docs/en.md) — A LaTeX skeleton is a contract between the researcher and the typesetter. If the contract is broken the document does not compile, and the failure is loud. Build the skeleton fi… - [Critic Loop](https://aiengineeringfromscratch.com/learn/capstone-projects/critic-loop) · [raw](https://raw.githubusercontent.com/rohitg00/ai-engineering-from-scratch/main/phases/19-capstone-projects/55-critic-loop/docs/en.md) — A critic that returns "looks good" the first time is broken. A critic that always returns "needs work" is broken. The interesting critic is the one that converges, and you have … - [Iteration Scheduler](https://aiengineeringfromscratch.com/learn/capstone-projects/iteration-scheduler) · [raw](https://raw.githubusercontent.com/rohitg00/ai-engineering-from-scratch/main/phases/19-capstone-projects/56-iteration-scheduler/docs/en.md) — A research loop without a scheduler is a queue with delusions. The scheduler is where the loop decides what to stop exploring, and that decision is the whole game. - [End-to-End Research Demo](https://aiengineeringfromscratch.com/learn/capstone-projects/end-to-end-research-demo) · [raw](https://raw.githubusercontent.com/rohitg00/ai-engineering-from-scratch/main/phases/19-capstone-projects/57-end-to-end-research-demo/docs/en.md) — A demo is the place where every contract you wrote earlier has to compose. If any one of them leaks, the demo is the lesson that catches it. - [Vision Encoder Patches](https://aiengineeringfromscratch.com/learn/capstone-projects/vision-encoder-patches) · [raw](https://raw.githubusercontent.com/rohitg00/ai-engineering-from-scratch/main/phases/19-capstone-projects/58-vision-encoder-patches/docs/en.md) — A vision model that reads pixels needs a tokenizer for pixels. Patch embedding is that tokenizer. Cut the image into a grid of squares, flatten each square, project it through o… - [Vision Transformer Encoder](https://aiengineeringfromscratch.com/learn/capstone-projects/vit-transformer) · [raw](https://raw.githubusercontent.com/rohitg00/ai-engineering-from-scratch/main/phases/19-capstone-projects/59-vit-transformer/docs/en.md) — Patches alone do not see. A 12-layer pre-LN transformer with 12 attention heads turns the sequence of patch tokens into a sequence of contextual tokens, with the CLS token pooli… - [Projection Layer for Modality Alignment](https://aiengineeringfromscratch.com/learn/capstone-projects/projection-layer-modality-align) · [raw](https://raw.githubusercontent.com/rohitg00/ai-engineering-from-scratch/main/phases/19-capstone-projects/60-projection-layer-modality-align/docs/en.md) — A vision encoder produces image tokens. A text decoder consumes text tokens. The two live in different vector spaces. A small two-layer MLP projects image tokens into the text e… - [Cross-Attention Fusion](https://aiengineeringfromscratch.com/learn/capstone-projects/cross-attention-fusion) · [raw](https://raw.githubusercontent.com/rohitg00/ai-engineering-from-scratch/main/phases/19-capstone-projects/61-cross-attention-fusion/docs/en.md) — The projection layer aligns one image vector with one caption vector. A real vision-language decoder needs every text token to attend to every patch token, so the model can grou… - [Vision-Language Pretraining](https://aiengineeringfromscratch.com/learn/capstone-projects/vision-language-pretraining) · [raw](https://raw.githubusercontent.com/rohitg00/ai-engineering-from-scratch/main/phases/19-capstone-projects/62-vision-language-pretraining/docs/en.md) — The encoder, projection, and decoder are wired. Now train them together. Two objectives drive learning: a contrastive image-text loss (InfoNCE) that pulls matching pairs togethe… - [Multimodal Evaluation](https://aiengineeringfromscratch.com/learn/capstone-projects/multimodal-eval) · [raw](https://raw.githubusercontent.com/rohitg00/ai-engineering-from-scratch/main/phases/19-capstone-projects/63-multimodal-eval/docs/en.md) — Training is half the loop. The other half is measurement. This lesson builds three evaluation surfaces from primitives: image-caption retrieval reported as R@1, R@5, R@10; visua… - [Chunking Strategies, Compared](https://aiengineeringfromscratch.com/learn/capstone-projects/chunking-strategies-advanced) · [raw](https://raw.githubusercontent.com/rohitg00/ai-engineering-from-scratch/main/phases/19-capstone-projects/64-chunking-strategies-advanced/docs/en.md) — Chunking decides what your retriever can ever surface. Get the boundaries wrong and no embedding model, no reranker, no LLM can repair the damage downstream. - [Hybrid Retrieval with BM25 and Dense Embeddings](https://aiengineeringfromscratch.com/learn/capstone-projects/hybrid-retrieval-bm25-dense) · [raw](https://raw.githubusercontent.com/rohitg00/ai-engineering-from-scratch/main/phases/19-capstone-projects/65-hybrid-retrieval-bm25-dense/docs/en.md) — Lexical and semantic retrieval fail on opposite query distributions. Hybrid retrieval with reciprocal rank fusion does not interpolate, it votes - and the vote wins on every que… - [Cross-Encoder Reranker](https://aiengineeringfromscratch.com/learn/capstone-projects/reranker-cross-encoder) · [raw](https://raw.githubusercontent.com/rohitg00/ai-engineering-from-scratch/main/phases/19-capstone-projects/66-reranker-cross-encoder/docs/en.md) — A bi-encoder embeds query and document independently. A cross-encoder concatenates them and reads both at once. The cross-encoder is the smartest reader and the slowest. Used as… - [Query Rewriting: HyDE, Multi-Query, and Decomposition](https://aiengineeringfromscratch.com/learn/capstone-projects/query-rewriting-hyde) · [raw](https://raw.githubusercontent.com/rohitg00/ai-engineering-from-scratch/main/phases/19-capstone-projects/67-query-rewriting-hyde/docs/en.md) — The query the user types is not the query your retriever wants. Rewriting bridges the gap before retrieval, so the index sees something closer to what the answer looks like. - [RAG Evaluation: Precision, Recall, MRR, nDCG, Faithfulness, Answer Relevance](https://aiengineeringfromscratch.com/learn/capstone-projects/rag-eval-precision-recall) · [raw](https://raw.githubusercontent.com/rohitg00/ai-engineering-from-scratch/main/phases/19-capstone-projects/68-rag-eval-precision-recall/docs/en.md) — If you cannot grade your retrieval and your answer at the same time, you cannot ship the system. The two are not the same metric and the same prompt fails on different axes. - [End-to-End RAG System](https://aiengineeringfromscratch.com/learn/capstone-projects/end-to-end-rag-system) · [raw](https://raw.githubusercontent.com/rohitg00/ai-engineering-from-scratch/main/phases/19-capstone-projects/69-end-to-end-rag-system/docs/en.md) — Six lessons of components. One pipeline. One eval loop. One self-terminating demo. This is the system you ship. - [Task Spec Format](https://aiengineeringfromscratch.com/learn/capstone-projects/task-spec-format) · [raw](https://raw.githubusercontent.com/rohitg00/ai-engineering-from-scratch/main/phases/19-capstone-projects/70-task-spec-format/docs/en.md) — An eval harness is only as good as the contract its tasks honour. Freeze the JSONL shape and the metric vocabulary before you write a single scoring function. - [Classical Metrics](https://aiengineeringfromscratch.com/learn/capstone-projects/classical-metrics) · [raw](https://raw.githubusercontent.com/rohitg00/ai-engineering-from-scratch/main/phases/19-capstone-projects/71-classical-metrics/docs/en.md) — BLEU, ROUGE-L, F1, exact-match, accuracy. Five metrics that still account for most published LLM eval numbers. Implement each from first principles so you know what the number m… - [Code Exec Metric](https://aiengineeringfromscratch.com/learn/capstone-projects/code-exec-metric) · [raw](https://raw.githubusercontent.com/rohitg00/ai-engineering-from-scratch/main/phases/19-capstone-projects/72-code-exec-metric/docs/en.md) — Generated code is right when it passes the tests. The eval harness has to extract code, run it without crashing the host, and tally pass-rates honestly. This lesson builds that … - [Perplexity and Calibration](https://aiengineeringfromscratch.com/learn/capstone-projects/perplexity-calibration) · [raw](https://raw.githubusercontent.com/rohitg00/ai-engineering-from-scratch/main/phases/19-capstone-projects/73-perplexity-calibration/docs/en.md) — If your model says 90 percent confident on a thousand answers and gets six hundred right, it is not well calibrated. Calibration is half of trustworthy eval. The other half is p… - [Leaderboard Aggregation](https://aiengineeringfromscratch.com/learn/capstone-projects/leaderboard-aggregation) · [raw](https://raw.githubusercontent.com/rohitg00/ai-engineering-from-scratch/main/phases/19-capstone-projects/74-leaderboard-aggregation/docs/en.md) — Per-task scores are easy. Per-model rankings across heterogeneous tasks are harder. Statistical significance on a thousand-prediction leaderboard is the part everyone skips. Thi… - [End-to-End Eval Runner](https://aiengineeringfromscratch.com/learn/capstone-projects/end-to-end-eval-runner) · [raw](https://raw.githubusercontent.com/rohitg00/ai-engineering-from-scratch/main/phases/19-capstone-projects/75-end-to-end-eval-runner/docs/en.md) — Five lessons of plumbing, one lesson to glue them. The runner reads the task spec from lesson 70, calls a model through an adapter, scores with lessons 71 and 72, attaches the c… - [Collective Ops From Scratch](https://aiengineeringfromscratch.com/learn/capstone-projects/collective-ops-from-scratch) · [raw](https://raw.githubusercontent.com/rohitg00/ai-engineering-from-scratch/main/phases/19-capstone-projects/76-collective-ops-from-scratch/docs/en.md) — The four collective operations that hold distributed training together are allreduce, broadcast, allgather, and reduce_scatter. Every other primitive a training framework offers… - [Data Parallel DDP From Scratch](https://aiengineeringfromscratch.com/learn/capstone-projects/data-parallel-ddp) · [raw](https://raw.githubusercontent.com/rohitg00/ai-engineering-from-scratch/main/phases/19-capstone-projects/77-data-parallel-ddp/docs/en.md) — DistributedDataParallel is a hook on top of allreduce. Wrap a model, broadcast the initial parameters from rank 0 so every rank starts identical, install a backward hook on ever… - [ZeRO Optimizer State Sharding](https://aiengineeringfromscratch.com/learn/capstone-projects/zero-parameter-sharding) · [raw](https://raw.githubusercontent.com/rohitg00/ai-engineering-from-scratch/main/phases/19-capstone-projects/78-zero-parameter-sharding/docs/en.md) — Adam stores two moment estimates per parameter, both in float32. A 7B-parameter model carries 56 GB of optimiser state. ZeRO stage 1 shards that across N ranks; each rank owns 1… - [Pipeline Parallel and Bubble Analysis](https://aiengineeringfromscratch.com/learn/capstone-projects/pipeline-parallel) · [raw](https://raw.githubusercontent.com/rohitg00/ai-engineering-from-scratch/main/phases/19-capstone-projects/79-pipeline-parallel/docs/en.md) — Tensor parallelism splits the matrix multiply across ranks. Pipeline parallelism splits the model across ranks, one stage per rank. Microbatches flow through the pipeline. The e… - [Sharded Checkpoint and Atomic Resume](https://aiengineeringfromscratch.com/learn/capstone-projects/checkpoint-sharded-resume) · [raw](https://raw.githubusercontent.com/rohitg00/ai-engineering-from-scratch/main/phases/19-capstone-projects/80-checkpoint-sharded-resume/docs/en.md) — A 70B-parameter training job is paused by a node failure every few hours. The checkpoint format decides whether you lose 30 minutes or 30 hours. A sharded checkpoint writes ever… - [End-to-End Distributed Training](https://aiengineeringfromscratch.com/learn/capstone-projects/end-to-end-distributed-train) · [raw](https://raw.githubusercontent.com/rohitg00/ai-engineering-from-scratch/main/phases/19-capstone-projects/81-end-to-end-distributed-train/docs/en.md) — Lessons 76 through 80 each built one piece. This is the assembly: a tiny GPT trained across 4 simulated ranks with DDP for gradient sync, ZeRO-1 for optimiser-state sharding, an… - [Jailbreak Taxonomy](https://aiengineeringfromscratch.com/learn/capstone-projects/jailbreak-taxonomy) · [raw](https://raw.githubusercontent.com/rohitg00/ai-engineering-from-scratch/main/phases/19-capstone-projects/82-jailbreak-taxonomy/docs/en.md) — A safety harness without a taxonomy is a coin flip. Name the attack before you defend it. - [Prompt Injection Detector](https://aiengineeringfromscratch.com/learn/capstone-projects/prompt-injection-detector) · [raw](https://raw.githubusercontent.com/rohitg00/ai-engineering-from-scratch/main/phases/19-capstone-projects/83-prompt-injection-detector/docs/en.md) — A detector is a function from prompt to confidence and category. Anything else is a vibe. - [Refusal Evaluation](https://aiengineeringfromscratch.com/learn/capstone-projects/refusal-evaluation) · [raw](https://raw.githubusercontent.com/rohitg00/ai-engineering-from-scratch/main/phases/19-capstone-projects/84-refusal-evaluation/docs/en.md) — Helpfulness on benign prompts and refusal on harmful prompts are two metrics, not one. Measure both. - [Content Classifier Integration](https://aiengineeringfromscratch.com/learn/capstone-projects/content-classifier-integration) · [raw](https://raw.githubusercontent.com/rohitg00/ai-engineering-from-scratch/main/phases/19-capstone-projects/85-content-classifier-integration/docs/en.md) — Classifiers on the output side answer a different question than rules on the input side. Both need a policy router. - [Constitutional Rules Engine](https://aiengineeringfromscratch.com/learn/capstone-projects/constitutional-rules-engine) · [raw](https://raw.githubusercontent.com/rohitg00/ai-engineering-from-scratch/main/phases/19-capstone-projects/86-constitutional-rules-engine/docs/en.md) — A rule is a name, a predicate, and an explanation. Anything missing one of those three is a vibe, not a rule. - [End-to-End Safety Gate](https://aiengineeringfromscratch.com/learn/capstone-projects/end-to-end-safety-gate) · [raw](https://raw.githubusercontent.com/rohitg00/ai-engineering-from-scratch/main/phases/19-capstone-projects/87-end-to-end-safety-gate/docs/en.md) — Pre-gen, during-gen, post-gen. Three checkpoints, one verdict, an audit trail per request. ## Phase overviews Each phase has an overview page with its lessons, prerequisites, glossary terms, and a short FAQ. Request any overview or term page with Accept: text/markdown to get Markdown. - [Set Up an AI Development Environment: 13 Free Lessons](https://aiengineeringfromscratch.com/phase/setup-and-tooling): Phase 00: Setup & Tooling - [Learn Math for Machine Learning: 22 Free Lessons](https://aiengineeringfromscratch.com/phase/math-foundations): Phase 01: Math Foundations - [Learn Machine Learning from Scratch: 21 Free Lessons](https://aiengineeringfromscratch.com/phase/ml-fundamentals): Phase 02: ML Fundamentals - [Learn Deep Learning from Scratch: 13 Free Lessons](https://aiengineeringfromscratch.com/phase/deep-learning-core): Phase 03: Deep Learning Core - [Learn Computer Vision from Scratch: 28 Free Lessons](https://aiengineeringfromscratch.com/phase/computer-vision): Phase 04: Computer Vision - [Learn NLP from Scratch: 29 Free Lessons](https://aiengineeringfromscratch.com/phase/nlp-foundations-to-advanced): Phase 05: NLP: Foundations to Advanced - [Learn Speech and Audio AI from Scratch: 17 Free Lessons](https://aiengineeringfromscratch.com/phase/speech-and-audio): Phase 06: Speech & Audio - [Learn Transformers from Scratch: 16 Free Lessons](https://aiengineeringfromscratch.com/phase/transformers-deep-dive): Phase 07: Transformers Deep Dive - [Learn Generative AI from Scratch: 15 Free Lessons](https://aiengineeringfromscratch.com/phase/generative-ai): Phase 08: Generative AI - [Learn Reinforcement Learning from Scratch: 12 Free Lessons](https://aiengineeringfromscratch.com/phase/reinforcement-learning): Phase 09: Reinforcement Learning - [Build an LLM from Scratch: 24 Free Lessons](https://aiengineeringfromscratch.com/phase/llms-from-scratch): Phase 10: LLMs from Scratch - [Learn LLM Engineering: 17 Free Lessons](https://aiengineeringfromscratch.com/phase/llm-engineering): Phase 11: LLM Engineering - [Learn Multimodal AI from Scratch: 25 Free Lessons](https://aiengineeringfromscratch.com/phase/multimodal-ai): Phase 12: Multimodal AI - [Learn Tool Calling and MCP: 45 Free Lessons](https://aiengineeringfromscratch.com/phase/tools-and-protocols): Phase 13: Tools & Protocols - [Build AI Agents from Scratch: 54 Free Lessons](https://aiengineeringfromscratch.com/phase/agent-engineering): Phase 14: Agent Engineering - [Learn Autonomous AI Systems: 22 Free Lessons](https://aiengineeringfromscratch.com/phase/autonomous-systems): Phase 15: Autonomous Systems - [Learn Multi-Agent Systems: 25 Free Lessons](https://aiengineeringfromscratch.com/phase/multi-agent-and-swarms): Phase 16: Multi-Agent & Swarms - [Learn LLM Serving and AI Infrastructure: 29 Free Lessons](https://aiengineeringfromscratch.com/phase/infrastructure-and-production): Phase 17: Infrastructure & Production - [Learn AI Ethics, Safety and Alignment: 30 Free Lessons](https://aiengineeringfromscratch.com/phase/ethics-safety-alignment): Phase 18: Ethics, Safety & Alignment - [AI Engineering Capstone Projects: 85 Free Lessons](https://aiengineeringfromscratch.com/phase/capstone-projects): Phase 19: Capstone Projects ## Glossary term pages 237 glossary terms have their own page at https://aiengineeringfromscratch.com/glossary/. [Glossary term sitemap](https://aiengineeringfromscratch.com/sitemap-glossary.xml) ## Practice tasks 51 practice tasks ask the learner to implement code from a lesson, implement a method from a research paper, train a tiny model to a target, or run an experiment and answer with numbers. Python with numpy runs the checks in the browser. Each page holds the statement only, and each task page returns Markdown with Accept: text/markdown. [Practice index in Markdown](https://aiengineeringfromscratch.com/agent-pages/practice/index.md) `python3 scripts/practice/run.py ` runs the checks offline. [Practice sitemap](https://aiengineeringfromscratch.com/sitemap-practice.xml) ### Implement - [Power iteration for the top eigenpair](https://aiengineeringfromscratch.com/practice/power-iteration) (medium): The top eigenvalue and eigenvector of a symmetric matrix by power iteration, with a tolerance, an iteration limit and a sign rule. From [Singular Value Decomposition](https://aiengineeringfromscratch.com/learn/math-foundations/singular-value-decomposition) - [Vectorized pairwise distances](https://aiengineeringfromscratch.com/practice/pairwise-distances) (medium): Euclidean distance and cosine similarity matrices from one matrix product, with a clip at 0 and a zero-vector rule. From [Norms and Distances](https://aiengineeringfromscratch.com/learn/math-foundations/norms-and-distances) - [Linear regression by gradient descent](https://aiengineeringfromscratch.com/practice/gradient-descent-linear-regression) (easy): Mean squared error, its gradients for weights and bias, and a batch gradient descent loop that records the cost after each update. From [Linear Regression](https://aiengineeringfromscratch.com/learn/ml-fundamentals/linear-regression) - [Logistic regression from scratch](https://aiengineeringfromscratch.com/practice/logistic-regression) (medium): A stable sigmoid, the binary cross-entropy loss and its gradient, and a gradient descent loop that records the loss. From [Logistic Regression](https://aiengineeringfromscratch.com/learn/ml-fundamentals/logistic-regression) - [Gini impurity and the best split](https://aiengineeringfromscratch.com/practice/gini-best-split) (hard): Gini impurity and the best decision tree split over all features, with midpoint thresholds, weighted child impurity and a fixed tie rule. From [Decision Trees and Random Forests](https://aiengineeringfromscratch.com/learn/ml-fundamentals/decision-trees) - [K-means assignment and update](https://aiengineeringfromscratch.com/practice/kmeans-step) (medium): The k-means assignment and update steps with a tie rule and an empty cluster rule, and a full run until the assignments stop changing. From [Unsupervised Learning](https://aiengineeringfromscratch.com/learn/ml-fundamentals/unsupervised-learning) - [Backpropagation through a two-layer MLP](https://aiengineeringfromscratch.com/practice/mlp-backprop) (hard): Forward pass with a cache and a backward pass that returns the gradient of every weight and bias of a two-layer sigmoid network. From [Backpropagation from Scratch](https://aiengineeringfromscratch.com/learn/deep-learning-core/backpropagation) - [Stable softmax and cross-entropy](https://aiengineeringfromscratch.com/practice/softmax-cross-entropy) (easy): Batched softmax, mean cross-entropy and its gradient, without overflow for large logits. From [Loss Functions](https://aiengineeringfromscratch.com/learn/deep-learning-core/loss-functions) - [SGD with momentum](https://aiengineeringfromscratch.com/practice/sgd-momentum) (easy): One momentum update with the lesson's velocity rule, and a loop that minimizes a quadratic with or without Nesterov lookahead. From [Optimizers](https://aiengineeringfromscratch.com/learn/deep-learning-core/optimizers) - [Adam and AdamW step](https://aiengineeringfromscratch.com/practice/adam-step) (medium): One Adam update with bias correction and a step counter that starts at 1, plus AdamW decoupled weight decay, as a pure function of the state. From [Optimizers](https://aiengineeringfromscratch.com/learn/deep-learning-core/optimizers) - [Inverted dropout](https://aiengineeringfromscratch.com/practice/inverted-dropout) (easy): Inverted dropout with a given random generator: training forward with an exact mask, backward with the same mask, identity at inference. From [Regularization](https://aiengineeringfromscratch.com/learn/deep-learning-core/regularization) - [Batch normalization forward and backward](https://aiengineeringfromscratch.com/practice/batch-norm) (hard): Training and inference forward passes with running statistics, and the full backward pass for x, gamma and beta. From [Regularization](https://aiengineeringfromscratch.com/learn/deep-learning-core/regularization) - [Beam search with EOS and length normalization](https://aiengineeringfromscratch.com/practice/beam-search) (hard): Keep the best beam_width partial sequences over a step function, finish beams at EOS, and rank them with a length penalty. From [Sequence-to-Sequence Models](https://aiengineeringfromscratch.com/learn/nlp-foundations-to-advanced/sequence-to-sequence) - [BM25 ranking](https://aiengineeringfromscratch.com/practice/bm25) (medium): Score tokenized documents against a query with BM25: the lesson idf, term frequency saturation with k1, length normalization with b, and a ranked list. From [Information Retrieval and Search](https://aiengineeringfromscratch.com/learn/nlp-foundations-to-advanced/information-retrieval-search) - [Scaled dot-product attention with a mask](https://aiengineeringfromscratch.com/practice/scaled-dot-product-attention) (medium): Batched softmax(QK^T / sqrt(d_k)) V with an optional boolean mask, plus the causal mask that a decoder uses. From [Self-Attention from Scratch](https://aiengineeringfromscratch.com/learn/transformers-deep-dive/self-attention-from-scratch) - [Split heads, merge heads, multi-head attention](https://aiengineeringfromscratch.com/practice/multi-head-split-merge) (medium): Reshape (B, T, D) into H heads and back, then run batched multi-head self-attention with given projection matrices. From [Multi-Head Attention](https://aiengineeringfromscratch.com/learn/transformers-deep-dive/multi-head-attention) - [Sinusoidal positional encoding](https://aiengineeringfromscratch.com/practice/sinusoidal-positional-encoding) (easy): Build the sin and cos position table with interleaved columns and base 10000, and add it to a batch of token embeddings. From [Positional Encoding — Sinusoidal, RoPE, ALiBi](https://aiengineeringfromscratch.com/learn/transformers-deep-dive/positional-encoding) - [Rotary position embedding](https://aiengineeringfromscratch.com/practice/rope) (medium): Rotate adjacent coordinate pairs of queries and keys by position times base^(-2i/d), so attention scores depend only on the position gap. From [Positional Encoding — Sinusoidal, RoPE, ALiBi](https://aiengineeringfromscratch.com/learn/transformers-deep-dive/positional-encoding) - [LayerNorm and RMSNorm](https://aiengineeringfromscratch.com/practice/layer-norm-rms-norm) (easy): LayerNorm with gamma and beta and RMSNorm with a weight, both over the last axis, with eps inside the square root. From [The Full Transformer — Encoder + Decoder](https://aiengineeringfromscratch.com/learn/transformers-deep-dive/full-transformer) - [Temperature, top-k and top-p sampling](https://aiengineeringfromscratch.com/practice/top-k-top-p-sampling) (medium): Scale logits by temperature, keep the top k or the top p mass, renormalize, and draw one token with a seeded rng. From [GPT — Causal Language Modeling](https://aiengineeringfromscratch.com/learn/transformers-deep-dive/gpt-causal-language-modeling) - [Fixed-capacity KV cache](https://aiengineeringfromscratch.com/practice/kv-cache-append) (medium): Append keys and values to a preallocated cache, attend one query over the valid prefix, and reject an append past the capacity. From [KV Cache, Flash Attention & Inference Optimization](https://aiengineeringfromscratch.com/learn/transformers-deep-dive/kv-cache-flash-attention) - [Q-learning and SARSA updates](https://aiengineeringfromscratch.com/practice/q-learning-update) (easy): One tabular Q-learning or SARSA update with no bootstrap at a terminal step, and epsilon-greedy actions from a seeded rng with lowest-index ties. From [Temporal Difference — Q-Learning & SARSA](https://aiengineeringfromscratch.com/learn/reinforcement-learning/q-learning-sarsa) - [Discounted returns with episode ends](https://aiengineeringfromscratch.com/practice/discounted-returns) (easy): Reward-to-go returns for one episode and for a batch of joined episodes with done flags, plus return normalization. From [Policy Gradient — REINFORCE from Scratch](https://aiengineeringfromscratch.com/learn/reinforcement-learning/policy-gradients-reinforce) - [Generalized advantage estimation](https://aiengineeringfromscratch.com/practice/generalized-advantage-estimation) (medium): TD errors and GAE advantages with gamma, lambda, done flags and a bootstrap value, plus the critic targets. From [Actor-Critic — A2C and A3C](https://aiengineeringfromscratch.com/learn/reinforcement-learning/actor-critic-a2c-a3c) - [PPO clipped surrogate loss](https://aiengineeringfromscratch.com/practice/ppo-clip-loss) (medium): The PPO loss to minimize from new and old log probabilities and advantages, the clip fraction, and the gradient with respect to the new log probabilities. From [Proximal Policy Optimization (PPO)](https://aiengineeringfromscratch.com/learn/reinforcement-learning/ppo) - [Symmetric int8 quantization](https://aiengineeringfromscratch.com/practice/int8-quantization) (medium): Absmax int8 quantization with one scale per tensor and one scale per row, with dequantization and a zero-row rule. From [Quantization: Making Models Fit](https://aiengineeringfromscratch.com/learn/llms-from-scratch/quantization) - [Cosine similarity top-k search](https://aiengineeringfromscratch.com/practice/cosine-top-k) (easy): Normalize embedding rows, score queries against documents with cosine similarity, and return the top k documents with a fixed tie rule. From [Embeddings & Vector Representations](https://aiengineeringfromscratch.com/learn/llm-engineering/embeddings) - [LoRA linear layer](https://aiengineeringfromscratch.com/practice/lora-forward) (easy): Forward pass of a linear layer with a low rank adapter, merge of the adapter into the weight, and the trainable parameter count. From [Fine-Tuning with LoRA & QLoRA](https://aiengineeringfromscratch.com/learn/llm-engineering/fine-tuning-lora) - [Parse and validate tool calls](https://aiengineeringfromscratch.com/practice/tool-call-parser) (hard): Parse tool calls from a raw model reply and validate their arguments against a JSON Schema subset with JSON pointer error paths. From [Tool Registry with Schema Validation](https://aiengineeringfromscratch.com/learn/capstone-projects/tool-registry-schema-validation) - [BPE pair counts and merges](https://aiengineeringfromscratch.com/practice/bpe-merge-step) (medium): Count weighted adjacent pairs, pick the best pair with a fixed tie rule, merge it without overlap and train a BPE merge list. From [BPE Tokenizer From Scratch](https://aiengineeringfromscratch.com/learn/capstone-projects/bpe-tokenizer-from-scratch) - [Reciprocal rank fusion](https://aiengineeringfromscratch.com/practice/reciprocal-rank-fusion) (easy): Merge several ranked lists of document ids into one ranking with reciprocal rank fusion, optional list weights and a fixed tie rule. From [Hybrid Retrieval with BM25 and Dense Embeddings](https://aiengineeringfromscratch.com/learn/capstone-projects/hybrid-retrieval-bm25-dense) ### Research - [Focal loss](https://aiengineeringfromscratch.com/practice/focal-loss) (easy): Binary and multi-class focal loss with gamma and alpha, from logits and without overflow, plus the binary gradient. From [Loss Functions](https://aiengineeringfromscratch.com/learn/deep-learning-core/loss-functions) - [CLIP symmetric contrastive loss](https://aiengineeringfromscratch.com/practice/clip-contrastive-loss) (medium): Normalize image and text embeddings, build the temperature-scaled similarity matrix, and compute the symmetric InfoNCE loss and its gradient. From [Open-Vocabulary Vision — CLIP](https://aiengineeringfromscratch.com/learn/computer-vision/open-vocab-clip) - [Grouped-query attention](https://aiengineeringfromscratch.com/practice/grouped-query-attention) (medium): GQA forward with H query heads and G shared key and value groups, plus mean pooling of a multi-head checkpoint into groups. From [Multi-Head Attention](https://aiengineeringfromscratch.com/learn/transformers-deep-dive/multi-head-attention) - [Top-k MoE gating and the Switch load-balancing loss](https://aiengineeringfromscratch.com/practice/mixture-of-experts-gating) (medium): Route tokens to the top k experts with renormalized softmax gates, and compute the Switch Transformer auxiliary loss E times sum f_i P_i. From [Mixture of Experts (MoE)](https://aiengineeringfromscratch.com/learn/transformers-deep-dive/mixture-of-experts) - [Tiled attention with an online softmax](https://aiengineeringfromscratch.com/practice/flash-attention-online-softmax) (hard): FlashAttention in numpy: a running max and a running sum over key blocks give exact attention for any block size. From [KV Cache, Flash Attention & Inference Optimization](https://aiengineeringfromscratch.com/learn/transformers-deep-dive/kv-cache-flash-attention) - [Speculative decoding: accept, reject and resample](https://aiengineeringfromscratch.com/practice/speculative-decoding-acceptance) (hard): The min(1, p/q) acceptance rule and the residual distribution that keep speculative decoding exactly equal to the target model. From [Speculative Decoding — Draft, Verify, Repeat](https://aiengineeringfromscratch.com/learn/transformers-deep-dive/speculative-decoding) - [DDPM noise schedule, closed form noising and posterior](https://aiengineeringfromscratch.com/practice/ddpm-forward-noising) (medium): Build the linear beta schedule and alpha bars, sample x_t from x_0 in closed form, and compute the mean and variance of q(x_{t-1} | x_t, x_0). From [Diffusion Models — DDPM from Scratch](https://aiengineeringfromscratch.com/learn/generative-ai/diffusion-ddpm-from-scratch) - [Rectified flow loss and Euler sampler](https://aiengineeringfromscratch.com/practice/rectified-flow-loss) (medium): Interpolate along straight paths, regress the velocity x1 - x0 with the flow matching loss, and integrate a velocity field with Euler steps. From [Flow Matching & Rectified Flows](https://aiengineeringfromscratch.com/learn/generative-ai/flow-matching-rectified-flows) - [GRPO group advantages and clipped objective](https://aiengineeringfromscratch.com/practice/grpo-advantages) (medium): Normalize rewards within each group, estimate the KL with k3, and compute the clipped GRPO objective averaged per answer over valid tokens. From [RL for Games — AlphaZero, MuZero, and the LLM-Reasoning Era](https://aiengineeringfromscratch.com/learn/reinforcement-learning/rl-for-games) - [DPO loss and implicit rewards](https://aiengineeringfromscratch.com/practice/dpo-loss) (medium): The direct preference optimization loss, its implicit rewards and its gradient, from policy and reference log probabilities. From [DPO: Direct Preference Optimization](https://aiengineeringfromscratch.com/learn/llms-from-scratch/dpo) ### Train - [Train softmax regression on four blobs](https://aiengineeringfromscratch.com/practice/train-softmax-blobs) (easy): Train multinomial logistic regression with gradient descent to reach a held-out accuracy and log loss target on four Gaussian blobs. From [Logistic Regression](https://aiengineeringfromscratch.com/learn/ml-fundamentals/logistic-regression) - [Train a 2-4-1 network on XOR](https://aiengineeringfromscratch.com/practice/train-xor-mlp) (easy): Train a small sigmoid network with full-batch gradient descent until it labels noisy XOR points with 95 percent held-out accuracy. From [Backpropagation from Scratch](https://aiengineeringfromscratch.com/learn/deep-learning-core/backpropagation) - [Fit a sine curve with a tanh network](https://aiengineeringfromscratch.com/practice/train-sine-regression) (medium): Train a 1-16-1 tanh network on noisy samples of sin(x) until its held-out mean squared error against the true curve is below 0.01. From [Activation Functions](https://aiengineeringfromscratch.com/learn/deep-learning-core/activation-functions) - [Train a tanh network on two spirals](https://aiengineeringfromscratch.com/practice/train-spirals-mlp) (medium): Train a 2-24-24-1 tanh network with mini-batch Adam until it separates two noisy spirals with 95 percent held-out accuracy. From [Build Your Own Mini Framework](https://aiengineeringfromscratch.com/learn/deep-learning-core/mini-framework) - [Train a character bigram language model](https://aiengineeringfromscratch.com/practice/train-char-bigram) (medium): Train a table of next-character logits with gradient descent until the held-out negative log-likelihood beats a unigram model. From [Text Generation Before Transformers — N-gram Language Models](https://aiengineeringfromscratch.com/learn/nlp-foundations-to-advanced/text-generation-pre-transformer) ### Lab - [Measure bias and variance](https://aiengineeringfromscratch.com/practice/lab-bias-variance) (medium): Fit polynomials of degree 1 to 12 on resampled training sets and measure bias squared, variance and test error at each degree. From [Bias-Variance Tradeoff](https://aiengineeringfromscratch.com/learn/ml-fundamentals/bias-variance) - [Sweep the learning rate](https://aiengineeringfromscratch.com/practice/lab-learning-rate-sweep) (easy): Sweep gradient descent learning rates on a seeded regression, find the best rate and the first rate that diverges, and compare with 2 over the top eigenvalue. From [Learning Rate Schedules and Warmup](https://aiengineeringfromscratch.com/learn/deep-learning-core/learning-rate-schedules) - [Sweep the sampling temperature](https://aiengineeringfromscratch.com/practice/lab-sampling-temperature) (easy): Sweep the temperature on fixed logits, measure entropy and top 1 probability, find where entropy crosses 2 bits, and count the tokens top p keeps. From [GPT — Causal Language Modeling](https://aiengineeringfromscratch.com/learn/transformers-deep-dive/gpt-causal-language-modeling) - [Sweep the quantization bit width](https://aiengineeringfromscratch.com/practice/lab-quantization-bits) (medium): Sweep symmetric absmax quantization from 2 to 8 bits on weights with outliers, compare one scale per tensor with one scale per row. From [Quantization: Making Models Fit](https://aiengineeringfromscratch.com/learn/llms-from-scratch/quantization) - [Read an SGLang sweep on an L4](https://aiengineeringfromscratch.com/practice/lab-sglang-l4-serving) (medium): Use real SGLang runs on an NVIDIA L4 to find the saturation point, the SLO limit, the FP8 gain and the effect of a smaller prefill chunk. From [Inference Metrics — TTFT, TPOT, ITL, Goodput, P99](https://aiengineeringfromscratch.com/learn/infrastructure-and-production/inference-metrics-goodput) ## Interview questions and scenarios 482 interview questions and 60 incident scenarios in 23 cards. Each question page holds the prompt, then the short answer, the full answer, the follow-ups and the common wrong answers in folded sections. Each scenario page shows its evidence listings in order. Every number in an answer comes from a lesson, a manual section or a capture file in the repository. Each item page returns Markdown with Accept: text/markdown. [Interviews index in Markdown](https://aiengineeringfromscratch.com/agent-pages/interviews/index.md) [Interviews JSON](https://aiengineeringfromscratch.com/api/interviews.json) [Interviews sitemap](https://aiengineeringfromscratch.com/sitemap-interviews.xml) ### Math and classical ML - [A sentence score that comes out as exactly zero](https://aiengineeringfromscratch.com/interviews/math-classical-ml/log-probs-instead-of-products) (level 1, concept) - [An R-squared below zero on the test set](https://aiengineeringfromscratch.com/interviews/math-classical-ml/negative-r-squared) (level 1, concept) - [Read a shape error in a dense layer](https://aiengineeringfromscratch.com/interviews/math-classical-ml/dense-layer-weight-shape) (level 1, concept) - [Two products in NumPy that print different numbers](https://aiengineeringfromscratch.com/interviews/math-classical-ml/elementwise-or-matmul) (level 1, code-reading) - [A cross-entropy that returns inf on real batches](https://aiengineeringfromscratch.com/interviews/math-classical-ml/softmax-inf-at-large-logits) (level 2, debug) - [A test score that production never reaches](https://aiengineeringfromscratch.com/interviews/math-classical-ml/scaler-fit-before-split) (level 2, debug) - [Pick a threshold when 95 percent of the data is negative](https://aiengineeringfromscratch.com/interviews/math-classical-ml/threshold-precision-or-recall) (level 2, tradeoff) - [Read a perplexity from a mean cross-entropy](https://aiengineeringfromscratch.com/interviews/math-classical-ml/perplexity-from-cross-entropy) (level 2, estimate) - [Score a tree node with Gini and with entropy](https://aiengineeringfromscratch.com/interviews/math-classical-ml/gini-for-a-mixed-node) (level 2, estimate) - [Why autograd adds gradients instead of setting them](https://aiengineeringfromscratch.com/interviews/math-classical-ml/grad-accumulate-plus-equals) (level 2, code-reading) - [Why backpropagation runs the chain rule in reverse](https://aiengineeringfromscratch.com/interviews/math-classical-ml/reverse-mode-one-pass) (level 2, concept) - [Why minimizing cross-entropy also minimizes KL](https://aiengineeringfromscratch.com/interviews/math-classical-ml/cross-entropy-is-kl-plus-entropy) (level 2, concept) - [Why plain gradient descent zigzags and momentum does not](https://aiengineeringfromscratch.com/interviews/math-classical-ml/momentum-in-a-narrow-valley) (level 2, concept) - [A forest that ranks a user id as its top feature](https://aiengineeringfromscratch.com/interviews/math-classical-ml/mdi-ranks-noise-feature) (level 3, debug) - [A gradient check that fails for the wrong reason](https://aiengineeringfromscratch.com/interviews/math-classical-ml/gradient-check-step-size) (level 3, debug) - [A logistic regression whose weights never stop growing](https://aiengineeringfromscratch.com/interviews/math-classical-ml/logistic-loss-on-separable-data) (level 3, concept) - [A variance that comes out wrong on large values](https://aiengineeringfromscratch.com/interviews/math-classical-ml/variance-of-large-numbers) (level 3, debug) - [Bag the deep trees or boost the stumps](https://aiengineeringfromscratch.com/interviews/math-classical-ml/bag-or-boost-the-base-model) (level 3, tradeoff) - [Pick a 16-bit format for training and one for inference](https://aiengineeringfromscratch.com/interviews/math-classical-ml/bfloat16-or-float16-for-training) (level 3, tradeoff) - [Build a stacking ensemble whose meta-learner never cheats](https://aiengineeringfromscratch.com/interviews/math-classical-ml/stacking-without-leakage) (level 4, take-home) - [Decide whether a small win on one split is real](https://aiengineeringfromscratch.com/interviews/math-classical-ml/compare-two-models-with-folds) (level 4, design) - [Test error that falls, spikes and falls again](https://aiengineeringfromscratch.com/interviews/math-classical-ml/past-the-interpolation-threshold) (level 4, concept) ### Deep learning - [Ten layers with no activation are one layer](https://aiengineeringfromscratch.com/interviews/deep-learning/stacked-linear-layers-collapse) (level 1, concept) - [Test accuracy that changes with the same weights](https://aiengineeringfromscratch.com/interviews/deep-learning/train-mode-and-eval-mode) (level 1, concept) - [Why one perceptron never learns XOR](https://aiengineeringfromscratch.com/interviews/deep-learning/xor-needs-a-hidden-layer) (level 1, concept) - [A classifier that predicts 0.5 and has a low loss](https://aiengineeringfromscratch.com/interviews/deep-learning/mse-predicts-half-for-everything) (level 2, concept) - [A wide layer that behaves like one neuron](https://aiengineeringfromscratch.com/interviews/deep-learning/zero-init-symmetry) (level 2, concept) - [How much gradient survives ten sigmoid layers](https://aiengineeringfromscratch.com/interviews/deep-learning/sigmoid-gradient-after-ten-layers) (level 2, estimate) - [Read the shapes of a 2-3-1 network from its Layer class](https://aiengineeringfromscratch.com/interviews/deep-learning/weight-matrix-rows-and-columns) (level 2, code-reading) - [Three lines that differentiate the cross-entropy loss](https://aiengineeringfromscratch.com/interviews/deep-learning/softmax-cross-entropy-gradient) (level 2, code-reading) - [Weight decay in the loss or in the optimizer](https://aiengineeringfromscratch.com/interviews/deep-learning/adamw-not-adam-plus-l2) (level 2, tradeoff) - [What Adam's bias correction does in the first steps](https://aiengineeringfromscratch.com/interviews/deep-learning/adam-bias-correction-first-steps) (level 2, concept) - [Where the 2 in Kaiming initialization comes from](https://aiengineeringfromscratch.com/interviews/deep-learning/kaiming-factor-of-two) (level 2, concept) - [Why the dropout mask holds 1 over (1 minus p)](https://aiengineeringfromscratch.com/interviews/deep-learning/inverted-dropout-scale) (level 2, code-reading) - [A loss that sits at 2.3 on a ten class problem](https://aiengineeringfromscratch.com/interviews/deep-learning/loss-stuck-at-log-classes) (level 3, debug) - [A training loop whose loss swings after a few steps](https://aiengineeringfromscratch.com/interviews/deep-learning/missing-zero-grad) (level 3, code-reading) - [The 30 second check before a multi-day run](https://aiengineeringfromscratch.com/interviews/deep-learning/overfit-one-batch-first) (level 3, design) - [Two layers where most ReLU outputs are exactly zero](https://aiengineeringfromscratch.com/interviews/deep-learning/half-the-relus-are-dead) (level 3, debug) - [What a learning rate warmup protects](https://aiengineeringfromscratch.com/interviews/deep-learning/warmup-before-the-peak-rate) (level 3, concept) - [Why a deep residual stack needs more than Kaiming](https://aiengineeringfromscratch.com/interviews/deep-learning/residual-scaling-deep-transformer) (level 3, concept) - [Why transformers normalize across features, not the batch](https://aiengineeringfromscratch.com/interviews/deep-learning/layernorm-not-batchnorm) (level 3, tradeoff) - [A smooth loss that turns inf and then NaN hours in](https://aiengineeringfromscratch.com/interviews/deep-learning/loss-becomes-nan-mid-run) (level 4, debug) - [Choose a peak learning rate and a schedule in a few hours](https://aiengineeringfromscratch.com/interviews/deep-learning/pick-the-peak-rate-and-schedule) (level 4, design) - [Warmup plus cosine schedule with pinned boundaries](https://aiengineeringfromscratch.com/interviews/deep-learning/cosine-warmup-schedule-boundaries) (level 4, take-home) ### Transformers - [Count the attention work for 100 generated tokens](https://aiengineeringfromscratch.com/interviews/transformers/count-attention-ops-with-cache) (level 1, estimate) - [Explain query, key and value in one minute](https://aiengineeringfromscratch.com/interviews/transformers/query-key-value-lookup) (level 1, concept) - [Shuffle the words and attention does not notice](https://aiengineeringfromscratch.com/interviews/transformers/permutation-blind-attention) (level 1, concept) - [Why the attention scores are divided before the softmax](https://aiengineeringfromscratch.com/interviews/transformers/why-scale-by-sqrt-dk) (level 1, concept) - [Absolute angles, relative distances](https://aiengineeringfromscratch.com/interviews/transformers/rope-relative-from-absolute) (level 2, concept) - [Attention runs, and the context has the wrong shape](https://aiengineeringfromscratch.com/interviews/transformers/attention-shape-bug) (level 2, debug) - [Encoder, decoder or both for three products](https://aiengineeringfromscratch.com/interviews/transformers/pick-encoder-or-decoder) (level 2, tradeoff) - [One reshape is right and one scrambles the heads](https://aiengineeringfromscratch.com/interviews/transformers/read-split-and-combine-heads) (level 2, code-reading) - [Pick the attention variant for a 70B decoder](https://aiengineeringfromscratch.com/interviews/transformers/gqa-mla-cache-tradeoff) (level 2, tradeoff) - [The loss collapses and the samples are nonsense](https://aiengineeringfromscratch.com/interviews/transformers/loss-drops-to-zero-no-mask) (level 2, debug) - [What eight heads cost that one head does not](https://aiengineeringfromscratch.com/interviews/transformers/heads-are-nearly-free) (level 2, concept) - [What the skip path does and where dropout may go](https://aiengineeringfromscratch.com/interviews/transformers/residual-stream-and-dropout) (level 2, concept) - [Where the triangle of minus infinity comes from](https://aiengineeringfromscratch.com/interviews/transformers/causal-mask-minus-infinity) (level 2, concept) - [Why the norm moved in front of the sublayer](https://aiengineeringfromscratch.com/interviews/transformers/pre-norm-vs-post-norm) (level 2, tradeoff) - [A heatmap is not an explanation](https://aiengineeringfromscratch.com/interviews/transformers/attention-weights-as-proof) (level 3, concept) - [Count the parameters of a decoder stack by hand](https://aiengineeringfromscratch.com/interviews/transformers/block-parameter-count) (level 3, estimate) - [Is a tiled attention kernel an approximation](https://aiengineeringfromscratch.com/interviews/transformers/flash-attention-is-exact) (level 3, concept) - [Read the running softmax and find the fragile line](https://aiengineeringfromscratch.com/interviews/transformers/read-the-tiled-softmax) (level 3, code-reading) - [Review a 2017-style block against today's defaults](https://aiengineeringfromscratch.com/interviews/transformers/modernize-a-2017-block) (level 3, design) - [Take a model from 8K to 128K](https://aiengineeringfromscratch.com/interviews/transformers/extend-context-past-training) (level 3, design) - [Take-home, a character-level decoder on a laptop](https://aiengineeringfromscratch.com/interviews/transformers/char-level-gpt-take-home) (level 3, take-home) - [A benchmark jumps between two model sizes](https://aiengineeringfromscratch.com/interviews/transformers/emergence-or-scorer-artifact) (level 4, concept) - [Design the attention stack for 128K context on one card](https://aiengineeringfromscratch.com/interviews/transformers/attention-for-128k-context) (level 4, design) - [Split a fixed compute budget between size and tokens](https://aiengineeringfromscratch.com/interviews/transformers/compute-split-params-tokens) (level 4, tradeoff) ### Tokenization, sampling and decoding - [One step of byte-pair training and what it leaves behind](https://aiengineeringfromscratch.com/interviews/tokenization-decoding/bpe-training-loop) (level 1, concept) - [The same prompt costs more tokens in Korean](https://aiengineeringfromscratch.com/interviews/tokenization-decoding/multilingual-tax) (level 1, concept) - [Why models read subwords and start from bytes](https://aiengineeringfromscratch.com/interviews/tokenization-decoding/why-subword-tokens) (level 1, concept) - [Count the windows a token stream gives you](https://aiengineeringfromscratch.com/interviews/tokenization-decoding/sliding-window-dataset) (level 2, code-reading) - [How a grammar edits the logits and why it can be faster](https://aiengineeringfromscratch.com/interviews/tokenization-decoding/constrained-decoding-how) (level 2, concept) - [Put numbers on growing the vocabulary to 128K](https://aiengineeringfromscratch.com/interviews/tokenization-decoding/vocab-size-tradeoff) (level 2, estimate) - [Speculation flies on code and stalls on creative writing](https://aiengineeringfromscratch.com/interviews/tokenization-decoding/temperature-and-acceptance) (level 2, tradeoff) - [The notebook works and the service never stops talking](https://aiengineeringfromscratch.com/interviews/tokenization-decoding/chat-template-garbage) (level 2, debug) - [Three ways to build a subword vocabulary](https://aiengineeringfromscratch.com/interviews/tokenization-decoding/bpe-wordpiece-unigram) (level 2, tradeoff) - [Two decoders, one breaks on an emoji](https://aiengineeringfromscratch.com/interviews/tokenization-decoding/read-the-decoder-round-trip) (level 2, code-reading) - [What the split before the merges is for](https://aiengineeringfromscratch.com/interviews/tokenization-decoding/pre-tokenization-regex) (level 2, concept) - [Why the encoder replays the merge list in order](https://aiengineeringfromscratch.com/interviews/tokenization-decoding/merge-order-at-encode) (level 2, concept) - [Every output validates and the answers are wrong](https://aiengineeringfromscratch.com/interviews/tokenization-decoding/schema-field-order) (level 3, design) - [From acceptance rate to tokens per pass](https://aiengineeringfromscratch.com/interviews/tokenization-decoding/speedup-from-alpha) (level 3, estimate) - [Read one speculative step and defend each line](https://aiengineeringfromscratch.com/interviews/tokenization-decoding/read-the-speculative-step) (level 3, code-reading) - [Take-home, a byte-level tokenizer with tests](https://aiengineeringfromscratch.com/interviews/tokenization-decoding/take-home-bpe-tokenizer) (level 3, take-home) - [The weights did not change and the score fell](https://aiengineeringfromscratch.com/interviews/tokenization-decoding/tokenizer-drift-ci) (level 3, debug) - [Which multi-token design gives a free draft](https://aiengineeringfromscratch.com/interviews/tokenization-decoding/mtp-sequential-vs-parallel) (level 3, concept) - [Why a draft that reads hidden states accepts more](https://aiengineeringfromscratch.com/interviews/tokenization-decoding/hidden-state-drafts) (level 3, concept) - [Bake in the draft, train it after, or borrow a small model](https://aiengineeringfromscratch.com/interviews/tokenization-decoding/choose-the-draft-for-a-new-model) (level 4, design) - [Design the tokenizer for a multilingual coding model](https://aiengineeringfromscratch.com/interviews/tokenization-decoding/design-tokenizer-for-new-model) (level 4, design) - [Mean latency improved and the tail got worse](https://aiengineeringfromscratch.com/interviews/tokenization-decoding/acceptance-fell-after-upgrade) (level 4, debug) ### Post-training - [A million scraped pairs or a small curated set](https://aiengineeringfromscratch.com/interviews/post-training/sft-data-quality-wins) (level 1, tradeoff) - [Count the parameters of one LoRA adapter](https://aiengineeringfromscratch.com/interviews/post-training/lora-parameter-count) (level 1, estimate) - [Train the head only, or fine-tune the whole model](https://aiengineeringfromscratch.com/interviews/post-training/classifier-head-or-full) (level 1, tradeoff) - [Why the SFT loss skips the instruction tokens](https://aiengineeringfromscratch.com/interviews/post-training/sft-loss-mask) (level 1, concept) - [A DPO trainer whose loss never moves](https://aiengineeringfromscratch.com/interviews/post-training/dpo-reference-bug) (level 2, code-reading) - [A flat GRPO reward and the groups that teach nothing](https://aiengineeringfromscratch.com/interviews/post-training/grpo-groups-teach-nothing) (level 2, debug) - [Fit a 7B fine-tune on a 24 GB GPU](https://aiengineeringfromscratch.com/interviews/post-training/qlora-on-one-gpu) (level 2, estimate) - [Replacing the human labeler with a principled model](https://aiengineeringfromscratch.com/interviews/post-training/constitutional-ai-not-cheaper) (level 2, concept) - [Reusing the pretraining learning rate for SFT](https://aiengineeringfromscratch.com/interviews/post-training/sft-learning-rate-gap) (level 2, concept) - [The GPU is idle and the RL log keeps growing](https://aiengineeringfromscratch.com/interviews/post-training/rl-engine-died-silent) (level 2, debug) - [What the KL penalty in RLHF protects](https://aiengineeringfromscratch.com/interviews/post-training/kl-penalty-purpose) (level 2, concept) - [Where the reward model went in DPO](https://aiengineeringfromscratch.com/interviews/post-training/dpo-implicit-reward) (level 2, concept) - [Why reward models learn from pairs, not scores](https://aiengineeringfromscratch.com/interviews/post-training/reward-model-pairwise) (level 2, concept) - [A step-0 gap several times the healthy range](https://aiengineeringfromscratch.com/interviews/post-training/logprob-gap-at-step-zero) (level 3, debug) - [DPO or the full RLHF stack for a small team](https://aiengineeringfromscratch.com/interviews/post-training/dpo-or-rlhf) (level 3, tradeoff) - [Margin up, chosen answers down, in a DPO run](https://aiengineeringfromscratch.com/interviews/post-training/dpo-chosen-logprob-falls) (level 3, debug) - [Pick a preference loss for four kinds of data](https://aiengineeringfromscratch.com/interviews/post-training/preference-loss-picker) (level 3, design) - [Remove a cause of the gap before you reweight it](https://aiengineeringfromscratch.com/interviews/post-training/gap-remove-before-reweight) (level 3, tradeoff) - [Review a claimed RL speedup before it becomes a default](https://aiengineeringfromscratch.com/interviews/post-training/rl-report-a-change) (level 3, design) - [The reward climbs and the human ratings do not](https://aiengineeringfromscratch.com/interviews/post-training/reward-up-humans-flat) (level 3, debug) - [Write and prove a custom reward for GRPO](https://aiengineeringfromscratch.com/interviews/post-training/rl-custom-reward-take-home) (level 3, take-home) - [Design async RL rollout and control the sample age](https://aiengineeringfromscratch.com/interviews/post-training/async-rl-sample-age) (level 4, design) - [Does dropping the reward model end reward hacking](https://aiengineeringfromscratch.com/interviews/post-training/daa-still-overoptimize) (level 4, concept) - [Plan the post-training of a support assistant](https://aiengineeringfromscratch.com/interviews/post-training/post-training-pipeline-take-home) (level 4, take-home) ### Inference and serving systems - [The two phases of one request](https://aiengineeringfromscratch.com/interviews/inference-serving/prefill-and-decode) (level 1, concept) - [Why 255 tokens per second is a slogan](https://aiengineeringfromscratch.com/interviews/inference-serving/goodput-not-a-slogan) (level 1, concept) - [Cached tokens at zero with a stable template](https://aiengineeringfromscratch.com/interviews/inference-serving/low-hit-rate-with-a-stable-template) (level 2, debug) - [Choose tensor, pipeline or data parallelism](https://aiengineeringfromscratch.com/interviews/inference-serving/tensor-pipeline-or-data-parallel) (level 2, design) - [How many users fit in the KV pool](https://aiengineeringfromscratch.com/interviews/inference-serving/kv-pool-users-fit) (level 2, estimate) - [How speculative decoding keeps the output the same](https://aiengineeringfromscratch.com/interviews/inference-serving/how-speculation-keeps-the-output) (level 2, concept) - [One token budget instead of two phases](https://aiengineeringfromscratch.com/interviews/inference-serving/one-token-budget-per-step) (level 2, concept) - [Read the GPU clock before the throughput](https://aiengineeringfromscratch.com/interviews/inference-serving/read-the-clock-first) (level 2, debug) - [Read three scheduler log lines](https://aiengineeringfromscratch.com/interviews/inference-serving/read-three-scheduler-lines) (level 2, code-reading) - [Sleep, wake and weight updates for an RL loop](https://aiengineeringfromscratch.com/interviews/inference-serving/sleep-mode-for-rl-rollouts) (level 2, concept) - [Temperature zero gave two different answers](https://aiengineeringfromscratch.com/interviews/inference-serving/temperature-zero-two-answers) (level 2, concept) - [The knee that the prefix cache hid](https://aiengineeringfromscratch.com/interviews/inference-serving/flush-before-you-compare) (level 2, debug) - [Two clients, two numbers, one server](https://aiengineeringfromscratch.com/interviews/inference-serving/the-client-is-part-of-the-measurement) (level 2, concept) - [What an FP8 KV cache buys and costs](https://aiengineeringfromscratch.com/interviews/inference-serving/fp8-kv-cache) (level 2, tradeoff) - [What many LoRA adapters cost one server](https://aiengineeringfromscratch.com/interviews/inference-serving/multi-lora-serving-cost) (level 2, design) - [Why one ID at the top of a prompt kills the cache](https://aiengineeringfromscratch.com/interviews/inference-serving/prefix-cache-order) (level 2, debug) - [Why the KV cache is a pool of 16-token blocks](https://aiengineeringfromscratch.com/interviews/inference-serving/paged-blocks-and-the-hash-chain) (level 2, concept) - [Why the shared part of the prompt goes first](https://aiengineeringfromscratch.com/interviews/inference-serving/shared-prefix-first) (level 2, concept) - [A larger token budget at low load](https://aiengineeringfromscratch.com/interviews/inference-serving/token-budget-at-low-load) (level 3, tradeoff) - [Acceptance by draft position, tokens per pass](https://aiengineeringfromscratch.com/interviews/inference-serving/acceptance-length-on-long-answers) (level 3, estimate) - [An admission cap decides who waits](https://aiengineeringfromscratch.com/interviews/inference-serving/a-cap-only-chooses-who-waits) (level 3, tradeoff) - [Pick a concurrency cap when throughput keeps rising](https://aiengineeringfromscratch.com/interviews/inference-serving/goodput-sets-the-cap) (level 3, tradeoff) - [Pick the EAGLE3 draft depth for your concurrency](https://aiengineeringfromscratch.com/interviews/inference-serving/eagle3-draft-depth) (level 3, tradeoff) - [Should the prefill chunk be smaller](https://aiengineeringfromscratch.com/interviews/inference-serving/smaller-prefill-chunks) (level 3, tradeoff) - [Speculation won the benchmark and lost in production](https://aiengineeringfromscratch.com/interviews/inference-serving/speculation-on-real-prompts) (level 3, debug) - [Two data-parallel copies, less output than one card](https://aiengineeringfromscratch.com/interviews/inference-serving/two-copies-served-less-than-one) (level 3, debug) - [What determinism costs a live server](https://aiengineeringfromscratch.com/interviews/inference-serving/the-cost-of-batch-invariance) (level 3, tradeoff) - [When an FP8 checkpoint pays](https://aiengineeringfromscratch.com/interviews/inference-serving/fp8-weights) (level 3, tradeoff) - [When prefill-decode disaggregation pays](https://aiengineeringfromscratch.com/interviews/inference-serving/when-to-split-prefill-and-decode) (level 3, design) - [A split-server benchmark that counted empty answers](https://aiengineeringfromscratch.com/interviews/inference-serving/a-benchmark-that-counted-empty-answers) (level 4, code-reading) - [Design a chat service on a fleet of L4 cards](https://aiengineeringfromscratch.com/interviews/inference-serving/design-a-chat-service-on-l4s) (level 4, design) - [Same throughput, two choices at a full pool](https://aiengineeringfromscratch.com/interviews/inference-serving/same-throughput-two-choices) (level 4, tradeoff) ### GPU memory, quantization and hardware - [The model is 35 GB now, so it fits](https://aiengineeringfromscratch.com/interviews/gpu-memory-quantization/the-kv-cache-trap) (level 1, concept) - [Count the KV bytes per token from the config](https://aiengineeringfromscratch.com/interviews/gpu-memory-quantization/kv-bytes-per-token) (level 2, estimate) - [Pick a 4-bit format for a 14B model on 24 GB](https://aiengineeringfromscratch.com/interviews/gpu-memory-quantization/pick-a-4-bit-format) (level 2, tradeoff) - [Why an 8B model fails to start on a 24 GB card](https://aiengineeringfromscratch.com/interviews/gpu-memory-quantization/an-8b-model-on-a-24-gb-card) (level 2, estimate) - [Pick the memory fraction on unified memory](https://aiengineeringfromscratch.com/interviews/gpu-memory-quantization/unified-memory-fraction-on-a-gb10) (level 3, estimate) - [Split the model or copy it across two cards](https://aiengineeringfromscratch.com/interviews/gpu-memory-quantization/split-or-copy-on-two-cards) (level 3, design) - [The FP8 KV scales that never loaded](https://aiengineeringfromscratch.com/interviews/gpu-memory-quantization/kv-scales-silently-at-one) (level 3, debug) - [The pool was 95 percent empty and the server died](https://aiengineeringfromscratch.com/interviews/gpu-memory-quantization/an-empty-pool-and-an-oom) (level 3, debug) - [Why FP8 grew the pool 4.77 times and not 2](https://aiengineeringfromscratch.com/interviews/gpu-memory-quantization/fp8-grew-the-pool-twice) (level 3, estimate) - [Eight copies of the same KV cache](https://aiengineeringfromscratch.com/interviews/gpu-memory-quantization/attention-data-parallel-for-latent-attention) (level 4, concept) ### RAG - [Retrieval or fine-tuning for the policy wiki](https://aiengineeringfromscratch.com/interviews/rag/rag-or-fine-tune) (level 1, concept) - [The first metric to read after a wrong answer](https://aiengineeringfromscratch.com/interviews/rag/recall-at-k-first) (level 1, concept) - [The retriever model and the reranker model](https://aiengineeringfromscratch.com/interviews/rag/bi-encoder-vs-cross-encoder) (level 1, concept) - [Why vector search ranks by cosine](https://aiengineeringfromscratch.com/interviews/rag/cosine-is-the-default) (level 1, concept) - [Count the work of a reranker over the whole index](https://aiengineeringfromscratch.com/interviews/rag/cross-encoder-passes-per-query) (level 2, estimate) - [Faithfulness and answer relevance grade different things](https://aiengineeringfromscratch.com/interviews/rag/faithfulness-vs-relevance) (level 2, concept) - [Filter on metadata ahead of the vector search](https://aiengineeringfromscratch.com/interviews/rag/filter-before-search) (level 2, design) - [Read the parent-document retrieval function](https://aiengineeringfromscratch.com/interviews/rag/parent-child-dedupe) (level 2, code-reading) - [Read the rank fusion function](https://aiengineeringfromscratch.com/interviews/rag/read-the-rrf-function) (level 2, code-reading) - [Review a chunking choice before the first index build](https://aiengineeringfromscratch.com/interviews/rag/chunk-size-by-query-type) (level 2, tradeoff) - [Settle a chunk overlap argument with one ablation](https://aiengineeringfromscratch.com/interviews/rag/overlap-measure-first) (level 2, tradeoff) - [The reranker is perfect offline and worse in production](https://aiengineeringfromscratch.com/interviews/rag/reranker-magic-in-eval) (level 2, debug) - [Vector search misses the article with the exact error code](https://aiengineeringfromscratch.com/interviews/rag/error-code-query-misses) (level 2, debug) - [Which query rewriter fits a two-topic question](https://aiengineeringfromscratch.com/interviews/rag/pick-the-query-rewriter) (level 2, tradeoff) - [Why hybrid search fuses ranks and not scores](https://aiengineeringfromscratch.com/interviews/rag/rrf-beats-score-sum) (level 2, concept) - [Build the eval that picks a retrieval configuration](https://aiengineeringfromscratch.com/interviews/rag/take-home-stratified-eval) (level 3, take-home) - [Design a question answering service over company documents](https://aiengineeringfromscratch.com/interviews/rag/design-rag-over-company-docs) (level 3, design) - [Faithfulness stays high while reviewers find invented facts](https://aiengineeringfromscratch.com/interviews/rag/judge-grades-its-own-work) (level 3, debug) - [Let the assistant say it does not know](https://aiengineeringfromscratch.com/interviews/rag/refuse-when-confidence-is-low) (level 3, design) - [Pick how many candidates the reranker scores](https://aiengineeringfromscratch.com/interviews/rag/rerank-pool-size) (level 3, tradeoff) - [Read the four lines that score a BM25 term](https://aiengineeringfromscratch.com/interviews/rag/bm25-idf-plus-one) (level 3, code-reading) - [Recall holds, MRR drops, nobody touched the retriever](https://aiengineeringfromscratch.com/interviews/rag/diagnose-from-the-metric-table) (level 3, debug) - [The invented passage made code search worse](https://aiengineeringfromscratch.com/interviews/rag/hyde-invents-a-symbol) (level 3, debug) - [Design code search across ten repositories that stays fresh](https://aiengineeringfromscratch.com/interviews/rag/design-cross-repo-code-search) (level 4, design) - [Every metric is high and one unit still gets wrong answers](https://aiengineeringfromscratch.com/interviews/rag/eval-passes-users-complain) (level 4, design) - [The other jurisdiction's clause reached the answer](https://aiengineeringfromscratch.com/interviews/rag/jurisdiction-leak-in-shared-index) (level 4, design) ### Prompting and structured output - [The three parts of a chat call and the prefill trick](https://aiengineeringfromscratch.com/interviews/prompting-structured-output/system-user-prefill) (level 1, concept) - [What JSON mode guarantees and what it does not](https://aiengineeringfromscratch.com/interviews/prompting-structured-output/json-mode-is-not-a-schema) (level 1, concept) - [Where step-by-step prompting helps and where it costs](https://aiengineeringfromscratch.com/interviews/prompting-structured-output/cot-when-it-hurts) (level 1, concept) - [Cache reads stay at zero on every request](https://aiengineeringfromscratch.com/interviews/prompting-structured-output/timestamp-kills-the-cache) (level 2, debug) - [Five votes, one path, five times the bill](https://aiengineeringfromscratch.com/interviews/prompting-structured-output/self-consistency-at-temperature-zero) (level 2, debug) - [How many examples go in the prompt, and which ones](https://aiengineeringfromscratch.com/interviews/prompting-structured-output/few-shot-example-count) (level 2, tradeoff) - [Read the constrained generation loop](https://aiengineeringfromscratch.com/interviews/prompting-structured-output/read-the-constrained-decoder) (level 2, code-reading) - [The three ways a structured output call fails](https://aiengineeringfromscratch.com/interviews/prompting-structured-output/three-failure-modes-structured) (level 2, concept) - [Tool descriptions decide which tool gets called](https://aiengineeringfromscratch.com/interviews/prompting-structured-output/tool-description-is-a-prompt) (level 2, concept) - [Typed data or an action, and why the difference matters](https://aiengineeringfromscratch.com/interviews/prompting-structured-output/structured-output-vs-function-call) (level 2, tradeoff) - [Valid JSON, worse accuracy, and the field order to blame](https://aiengineeringfromscratch.com/interviews/prompting-structured-output/answer-before-reasoning) (level 2, debug) - [Where each part of the context goes, and why](https://aiengineeringfromscratch.com/interviews/prompting-structured-output/lost-in-the-middle-order) (level 2, concept) - [Build a two-tier agent memory with eviction and citations](https://aiengineeringfromscratch.com/interviews/prompting-structured-output/take-home-two-tier-memory) (level 3, take-home) - [Design an extraction service for purchase-order emails](https://aiengineeringfromscratch.com/interviews/prompting-structured-output/design-extraction-with-refusals) (level 3, design) - [Design the executor behind an agent's tool calls](https://aiengineeringfromscratch.com/interviews/prompting-structured-output/tool-call-security-rules) (level 3, design) - [Move memory consolidation off the critical path](https://aiengineeringfromscratch.com/interviews/prompting-structured-output/sleep-time-consolidation) (level 3, tradeoff) - [Pick the cache lifetime for a batch of code reviews](https://aiengineeringfromscratch.com/interviews/prompting-structured-output/cache-break-even) (level 3, estimate) - [What fifty tool definitions cost on every call](https://aiengineeringfromscratch.com/interviews/prompting-structured-output/tool-budget-fifty-tools) (level 3, estimate) - [Zero validation errors and wrong invoice totals](https://aiengineeringfromscratch.com/interviews/prompting-structured-output/schema-valid-value-wrong) (level 3, debug) - [Make each reasoning stage earn its cost](https://aiengineeringfromscratch.com/interviews/prompting-structured-output/escalation-pipeline-cost) (level 4, tradeoff) - [Review a state write that can corrupt the next session](https://aiengineeringfromscratch.com/interviews/prompting-structured-output/state-file-atomic-write) (level 4, code-reading) - [Tune a three-store memory for three products](https://aiengineeringfromscratch.com/interviews/prompting-structured-output/fusion-weights-per-product) (level 4, design) ### Evaluation - [Exact match gives zero to a correct answer](https://aiengineeringfromscratch.com/interviews/evaluation/exact-match-vs-token-f1) (level 1, concept) - [Overlap metric, judge model or human review](https://aiengineeringfromscratch.com/interviews/evaluation/pick-the-eval-method) (level 1, tradeoff) - [Two points on a saturated benchmark](https://aiengineeringfromscratch.com/interviews/evaluation/benchmarks-stop-discriminating) (level 1, concept) - [What a perplexity of 10 tells you](https://aiengineeringfromscratch.com/interviews/evaluation/perplexity-health-check) (level 1, concept) - [A four point win on fifty cases](https://aiengineeringfromscratch.com/interviews/evaluation/fifty-cases-is-not-enough) (level 2, estimate) - [A perfect needle test and a long contract](https://aiengineeringfromscratch.com/interviews/evaluation/niah-is-not-enough) (level 2, concept) - [Before a judge score can gate a release](https://aiengineeringfromscratch.com/interviews/evaluation/judge-calibration-before-trust) (level 2, concept) - [BLEU 28.3 in one paper and 0.283 in another](https://aiengineeringfromscratch.com/interviews/evaluation/tokenizer-is-the-benchmark) (level 2, debug) - [Every metric moved and the product did not](https://aiengineeringfromscratch.com/interviews/evaluation/judge-upgrade-moved-every-score) (level 2, debug) - [Pass at one of 0.6 and pass at five of 0.95](https://aiengineeringfromscratch.com/interviews/evaluation/pass-at-k-reading) (level 2, tradeoff) - [The mean is green and users see failures](https://aiengineeringfromscratch.com/interviews/evaluation/mean-hides-the-tail) (level 2, debug) - [The model that writes the answer grades it too](https://aiengineeringfromscratch.com/interviews/evaluation/same-model-judges-itself) (level 2, tradeoff) - [The winner changed when you swapped the order](https://aiengineeringfromscratch.com/interviews/evaluation/pairwise-position-bias) (level 2, debug) - [Two engineers, one judge, different means](https://aiengineeringfromscratch.com/interviews/evaluation/anchored-rubric) (level 2, design) - [An ECE of 0.02 on too few predictions](https://aiengineeringfromscratch.com/interviews/evaluation/ece-or-brier) (level 3, concept) - [An eval gate on every pull request](https://aiengineeringfromscratch.com/interviews/evaluation/regression-gate-ci) (level 3, design) - [Error bars for a pass rate and for a mean](https://aiengineeringfromscratch.com/interviews/evaluation/wilson-or-bootstrap) (level 3, concept) - [Perplexity improves when the batch grows](https://aiengineeringfromscratch.com/interviews/evaluation/perplexity-padding-and-shift) (level 3, code-reading) - [Score generated code without an exec in the eval process](https://aiengineeringfromscratch.com/interviews/evaluation/code-exec-sandbox-contract) (level 3, design) - [The judge failed to parse and the mean went up](https://aiengineeringfromscratch.com/interviews/evaluation/nan-scores-raise-the-mean) (level 3, debug) - [Three models, fifty tasks, one leaderboard](https://aiengineeringfromscratch.com/interviews/evaluation/paired-difference-interval) (level 3, design) - [Two harnesses, two pass at k formulas](https://aiengineeringfromscratch.com/interviews/evaluation/two-pass-at-k-formulas) (level 3, code-reading) - [A long context battery for every model upgrade](https://aiengineeringfromscratch.com/interviews/evaluation/effective-context-spec-sheet) (level 4, design) - [Build an offline eval pipeline for a small model](https://aiengineeringfromscratch.com/interviews/evaluation/eval-pipeline-take-home) (level 4, take-home) - [Eight points after a new training corpus](https://aiengineeringfromscratch.com/interviews/evaluation/benchmark-jump-capability-or-leak) (level 4, design) - [The leaderboard winner is worst on code](https://aiengineeringfromscratch.com/interviews/evaluation/aggregate-hides-tradeoffs) (level 4, tradeoff) ### Multimodal - [How much context one image costs](https://aiengineeringfromscratch.com/interviews/multimodal/image-tokens-per-image) (level 1, estimate) - [The three parts of a vision-language model](https://aiengineeringfromscratch.com/interviews/multimodal/vlm-three-parts) (level 1, concept) - [Why the first VLM stage trains only the bridge](https://aiengineeringfromscratch.com/interviews/multimodal/train-only-the-projector) (level 1, concept) - [A caption decoder with its masks swapped](https://aiengineeringfromscratch.com/interviews/multimodal/cross-attention-mask-bug) (level 2, code-reading) - [A general VLM for which shelf the item is on](https://aiengineeringfromscratch.com/interviews/multimodal/spatial-reasoning-limit) (level 2, tradeoff) - [Adapter tokens or one shared vocabulary for images](https://aiengineeringfromscratch.com/interviews/multimodal/early-or-late-fusion) (level 2, tradeoff) - [Any number of images, a fixed number of tokens each](https://aiengineeringfromscratch.com/interviews/multimodal/perceiver-fixed-tokens) (level 2, concept) - [Build and test a projection between two frozen models](https://aiengineeringfromscratch.com/interviews/multimodal/projector-alignment-take-home) (level 2, take-home) - [Predict the next scale instead of the next token](https://aiengineeringfromscratch.com/interviews/multimodal/var-next-scale) (level 2, concept) - [Query bridge or MLP for the connector](https://aiengineeringfromscratch.com/interviews/multimodal/qformer-or-mlp) (level 2, tradeoff) - [What one generated image costs in codes and seconds](https://aiengineeringfromscratch.com/interviews/multimodal/emu3-generation-cost) (level 2, estimate) - [Which knob moves a multimodal reasoning score](https://aiengineeringfromscratch.com/interviews/multimodal/llm-size-sets-ceiling) (level 2, concept) - [A gated VLM fine-tune that forgot how to write](https://aiengineeringfromscratch.com/interviews/multimodal/gate-opened-too-fast) (level 3, debug) - [An early-fusion run that diverges at scale](https://aiengineeringfromscratch.com/interviews/multimodal/chameleon-diverged) (level 3, debug) - [Dense human captions or two million distilled ones](https://aiengineeringfromscratch.com/interviews/multimodal/human-captions-beat-distillation) (level 3, tradeoff) - [Monitor a deployed VLM for invented objects](https://aiengineeringfromscratch.com/interviews/multimodal/vlm-hallucination-kpi) (level 3, design) - [Three runs to close a VLM benchmark gap](https://aiengineeringfromscratch.com/interviews/multimodal/which-knob-first) (level 3, tradeoff) - [Three ways to generate an image from one transformer](https://aiengineeringfromscratch.com/interviews/multimodal/show-o-parallel-decoding) (level 3, tradeoff) - [Why the tokenizer caps a generated image](https://aiengineeringfromscratch.com/interviews/multimodal/vq-tokenizer-ceiling) (level 3, concept) - [Design a VLM for an on-device UI agent](https://aiengineeringfromscratch.com/interviews/multimodal/mobile-ui-agent-vlm) (level 4, design) - [One open model to answer, edit and generate](https://aiengineeringfromscratch.com/interviews/multimodal/pick-a-unified-model) (level 4, design) - [Two losses, one transformer, one gradient step](https://aiengineeringfromscratch.com/interviews/multimodal/transfusion-two-losses) (level 4, concept) ### Agents - [Seven surfaces, and the symptom when each is missing](https://aiengineeringfromscratch.com/interviews/agents/seven-surfaces-one-symptom-each) (level 1, concept) - [What a handoff packet carries that a status report does not](https://aiengineeringfromscratch.com/interviews/agents/a-handoff-is-not-a-status-report) (level 1, concept) - [What makes a loop an agent and not a chat bot](https://aiengineeringfromscratch.com/interviews/agents/five-parts-of-an-agent-loop) (level 1, concept) - [What one feedback record carries](https://aiengineeringfromscratch.com/interviews/agents/what-a-feedback-record-carries) (level 1, concept) - [A login fix touched five files](https://aiengineeringfromscratch.com/interviews/agents/a-login-fix-touched-five-files) (level 2, debug) - [A short router or a long manual for the agent](https://aiengineeringfromscratch.com/interviews/agents/router-or-manual) (level 2, tradeoff) - [Explicit finish tool or no-tool-call stop](https://aiengineeringfromscratch.com/interviews/agents/finish-tool-or-silence) (level 2, tradeoff) - [One turn cap for every task, what number do you give](https://aiengineeringfromscratch.com/interviews/agents/a-turn-cap-for-every-task) (level 2, estimate) - [Pick the permission mode for the task in front of you](https://aiengineeringfromscratch.com/interviews/agents/pick-the-permission-mode) (level 2, tradeoff) - [Read the loop, what the caller gets at the turn cap](https://aiengineeringfromscratch.com/interviews/agents/budget-exhausted-looks-like-an-answer) (level 2, code-reading) - [Read the registry, what the model gets back on a bad call](https://aiengineeringfromscratch.com/interviews/agents/error-paths-the-model-can-fix) (level 2, code-reading) - [The agent said the tests passed, and no test ran](https://aiengineeringfromscratch.com/interviews/agents/tests-passed-but-nothing-ran) (level 2, debug) - [This agent loops forever, find out why](https://aiengineeringfromscratch.com/interviews/agents/the-agent-loops-forever) (level 2, debug) - [Turn be careful into a rule a checker can score](https://aiengineeringfromscratch.com/interviews/agents/rules-the-workbench-can-check) (level 2, design) - [Build the harness now, or wait for a smarter model](https://aiengineeringfromscratch.com/interviews/agents/harness-or-a-smarter-model) (level 3, tradeoff) - [Compact the context, or end the session and hand off](https://aiengineeringfromscratch.com/interviews/agents/compact-or-hand-off) (level 3, tradeoff) - [Every action was approved, and the run was still harmful](https://aiengineeringfromscratch.com/interviews/agents/safe-actions-harmful-trajectory) (level 3, concept) - [Package the workbench so one command installs it anywhere](https://aiengineeringfromscratch.com/interviews/agents/ship-a-workbench-pack) (level 3, take-home) - [Read the harness, a hook aborts a tool call mid-plan](https://aiengineeringfromscratch.com/interviews/agents/a-hook-aborts-the-tool-call) (level 3, code-reading) - [The gate stayed green while the tests disappeared](https://aiengineeringfromscratch.com/interviews/agents/green-gate-missing-tests) (level 3, debug) - [The rule is in the repo, and the agent keeps breaking it](https://aiengineeringfromscratch.com/interviews/agents/the-agent-ignores-a-written-rule) (level 3, debug) - [Why the verification gate has no model in it](https://aiengineeringfromscratch.com/interviews/agents/why-the-gate-has-no-model) (level 3, concept) - [Bring evidence for one agent-assisted change](https://aiengineeringfromscratch.com/interviews/agents/prove-one-repository-change) (level 4, take-home) - [Translate eight harness patterns into primitives](https://aiengineeringfromscratch.com/interviews/agents/vendor-patterns-to-primitives) (level 4, concept) - [Two hundred registered tools, forty visible at a time](https://aiengineeringfromscratch.com/interviews/agents/two-hundred-tools-in-the-catalog) (level 4, design) - [Two scope contracts apply to one diff, define the merge](https://aiengineeringfromscratch.com/interviews/agents/merge-two-scope-contracts) (level 4, design) ### Protocols: MCP, A2A and skills - [A protocol error is not a tool error](https://aiengineeringfromscratch.com/interviews/protocols/two-error-layers) (level 1, concept) - [Pick the MCP primitive by who chooses it](https://aiengineeringfromscratch.com/interviews/protocols/tool-resource-or-prompt) (level 1, concept) - [What an A2A client reads before its first message](https://aiengineeringfromscratch.com/interviews/protocols/a2a-card-before-the-call) (level 1, concept) - [A root is a hint, not a permission](https://aiengineeringfromscratch.com/interviews/protocols/roots-are-not-a-sandbox) (level 2, concept) - [A shared cache in front of private notes](https://aiengineeringfromscratch.com/interviews/protocols/cache-scope-private) (level 2, tradeoff) - [Sticky sessions, GET streams and resume on the modern wire](https://aiengineeringfromscratch.com/interviews/protocols/post-only-streamable-http) (level 2, concept) - [The pagination loop that ends two pages short](https://aiengineeringfromscratch.com/interviews/protocols/empty-cursor-stops-early) (level 2, code-reading) - [The pin that passed a changed tool](https://aiengineeringfromscratch.com/interviews/protocols/descriptor-pin-rug-pull) (level 2, debug) - [The poll loop that never ends and the deploy that should not](https://aiengineeringfromscratch.com/interviews/protocols/a2a-rejected-task-loop) (level 2, debug) - [Three cancellations that look like one](https://aiengineeringfromscratch.com/interviews/protocols/cancel-signal-per-transport) (level 2, concept) - [Two errors from a client that forgot the version](https://aiengineeringfromscratch.com/interviews/protocols/a2a-version-header-missing) (level 2, debug) - [Why every MCP request repeats its metadata](https://aiengineeringfromscratch.com/interviews/protocols/stateless-request-metadata) (level 2, concept) - [A webhook that may fire twice or not at all](https://aiengineeringfromscratch.com/interviews/protocols/a2a-webhook-at-least-once) (level 3, tradeoff) - [Confirm a deletion without a session](https://aiengineeringfromscratch.com/interviews/protocols/mrtr-confirmation-state) (level 3, design) - [Recover a dropped A2A stream without replay](https://aiengineeringfromscratch.com/interviews/protocols/a2a-stream-drop-resubscribe) (level 3, design) - [The charge that ran twice after a timeout](https://aiengineeringfromscratch.com/interviews/protocols/retry-is-not-idempotency) (level 3, design) - [The draft that vanished on the second replica](https://aiengineeringfromscratch.com/interviews/protocols/draft-lost-across-replicas) (level 3, debug) - [The gateway that authorized a read and ran a delete](https://aiengineeringfromscratch.com/interviews/protocols/header-body-mismatch-order) (level 3, debug) - [When an old server is really old](https://aiengineeringfromscratch.com/interviews/protocols/legacy-probe-fail-closed) (level 3, design) - [Build the admission gate of an MCP gateway](https://aiengineeringfromscratch.com/interviews/protocols/gateway-admission-take-home) (level 4, take-home) - [How conformant is a server that scores 66.7 percent](https://aiengineeringfromscratch.com/interviews/protocols/a2a-tck-score-reading) (level 4, estimate) - [Two issuers, one resource server, no outage](https://aiengineeringfromscratch.com/interviews/protocols/issuer-bound-tokens-and-jwks) (level 4, design) ### Multi-agent systems - [Read any multi-agent framework in one paragraph](https://aiengineeringfromscratch.com/interviews/multi-agent/four-primitives-for-any-framework) (level 1, concept) - [Where one agent stops working, and why](https://aiengineeringfromscratch.com/interviews/multi-agent/the-single-agent-ceiling) (level 1, concept) - [Why a lead with workers beats one agent on research](https://aiengineeringfromscratch.com/interviews/multi-agent/why-a-fresh-context-wins) (level 1, concept) - [A number that never existed reached the final report](https://aiengineeringfromscratch.com/interviews/multi-agent/a-number-that-never-existed) (level 2, debug) - [Every agent reads everything, or agents subscribe to topics](https://aiengineeringfromscratch.com/interviews/multi-agent/full-pool-or-blackboard) (level 2, tradeoff) - [Five agents and a vote made the answers worse](https://aiengineeringfromscratch.com/interviews/multi-agent/five-agents-and-a-vote) (level 2, tradeoff) - [Five agents for a task that one call handles](https://aiengineeringfromscratch.com/interviews/multi-agent/when-one-agent-is-enough) (level 2, tradeoff) - [Read a multi-agent benchmark claim before you believe it](https://aiengineeringfromscratch.com/interviews/multi-agent/read-a-benchmark-claim) (level 2, concept) - [Round-robin, a model selector, or the current agent decides](https://aiengineeringfromscratch.com/interviews/multi-agent/who-picks-the-next-speaker) (level 2, tradeoff) - [Ten thousand concurrent model calls on threads](https://aiengineeringfromscratch.com/interviews/multi-agent/ten-thousand-calls-on-threads) (level 2, estimate) - [Two agents hand off to each other until the cap](https://aiengineeringfromscratch.com/interviews/multi-agent/two-agents-hand-off-forever) (level 2, debug) - [A payment failure took the inventory service down](https://aiengineeringfromscratch.com/interviews/multi-agent/the-retry-storm) (level 3, debug) - [A worker died mid-run, and the user paid for the run](https://aiengineeringfromscratch.com/interviews/multi-agent/a-worker-died-mid-run) (level 3, design) - [Design the verifier that has no write handle](https://aiengineeringfromscratch.com/interviews/multi-agent/the-verifier-that-cannot-write) (level 3, design) - [Read the vote aggregators and find the blind spot](https://aiengineeringfromscratch.com/interviews/multi-agent/read-the-three-aggregators) (level 3, code-reading) - [The legal question came back as finance findings](https://aiengineeringfromscratch.com/interviews/multi-agent/legal-became-finance-at-the-top) (level 3, debug) - [Two workers returned different facts, the report shows one](https://aiengineeringfromscratch.com/interviews/multi-agent/two-workers-return-different-facts) (level 3, debug) - [Design a lead-and-workers research system for production](https://aiengineeringfromscratch.com/interviews/multi-agent/design-a-research-team) (level 4, take-home) - [Design the quarterly failure audit for an agent team](https://aiengineeringfromscratch.com/interviews/multi-agent/a-quarterly-failure-audit) (level 4, design) - [Three copies of one model voted, and the majority was wrong](https://aiengineeringfromscratch.com/interviews/multi-agent/three-copies-of-one-model-voted) (level 4, concept) ### Sandboxes - [The agent has sudo and a Docker Engine, so where is the wall](https://aiengineeringfromscratch.com/interviews/sandboxes/hypervisor-is-the-boundary) (level 1, concept) - [The key reads proxy-managed and the agent still works](https://aiengineeringfromscratch.com/interviews/sandboxes/sentinel-is-not-the-key) (level 1, concept) - [The page says send it, and the agent has a send tool](https://aiengineeringfromscratch.com/interviews/sandboxes/screen-text-is-not-permission) (level 1, concept) - [A clean diff and a new pre-commit hook](https://aiengineeringfromscratch.com/interviews/sandboxes/clone-mode-and-the-hidden-hook) (level 2, debug) - [Four checks before spawn, and the call that gets through](https://aiengineeringfromscratch.com/interviews/sandboxes/denylist-runner-is-a-guardrail) (level 2, code-reading) - [pwd was rejected in one run and ran in the next](https://aiengineeringfromscratch.com/interviews/sandboxes/permissions-are-not-a-boundary) (level 2, concept) - [Share an hour of installs as a template or as a kit](https://aiengineeringfromscratch.com/interviews/sandboxes/template-or-kit-for-the-toolchain) (level 2, tradeoff) - [The host that timed out in 90 bytes](https://aiengineeringfromscratch.com/interviews/sandboxes/blocked-host-reads-as-timeout) (level 2, debug) - [The port that answers on one loopback and refuses the other](https://aiengineeringfromscratch.com/interviews/sandboxes/published-port-answers-ipv4-only) (level 2, debug) - [Why the deny for example.com was refused](https://aiengineeringfromscratch.com/interviews/sandboxes/deny-wins-and-the-two-scopes) (level 2, concept) - [A build that takes a day, on a sandbox that lives an hour](https://aiengineeringfromscratch.com/interviews/sandboxes/cloud-sandbox-clock-and-bill) (level 3, estimate) - [A travel agent that reads any page and is logged in](https://aiengineeringfromscratch.com/interviews/sandboxes/browser-agent-trust-boundary) (level 3, design) - [One allowlist for every laptop, and who can widen it](https://aiengineeringfromscratch.com/interviews/sandboxes/governance-narrows-never-widens) (level 3, tradeoff) - [Three failures in one sandboxed agent run](https://aiengineeringfromscratch.com/interviews/sandboxes/readonly-database-in-the-sandbox) (level 3, debug) - [Two mixins, one host, and the update that must stop](https://aiengineeringfromscratch.com/interviews/sandboxes/kit-grants-union-and-widen) (level 3, design) - [Five identical calls, five rejections, exit 1](https://aiengineeringfromscratch.com/interviews/sandboxes/headless-coordinator-loops-to-death) (level 4, debug) - [Six engineers, one repository, one reviewable sandbox setup](https://aiengineeringfromscratch.com/interviews/sandboxes/team-sandbox-policy-take-home) (level 4, take-home) - [The allowlist that still lets the repository leave](https://aiengineeringfromscratch.com/interviews/sandboxes/exfil-through-an-allowed-host) (level 4, design) ### Evidence and reverse engineering - [callers is empty and coverage says complete](https://aiengineeringfromscratch.com/interviews/evidence-reverse-engineering/empty-list-is-not-absence) (level 1, concept) - [Three words for one sentence about grade(55)](https://aiengineeringfromscratch.com/interviews/evidence-reverse-engineering/observed-derived-inferred) (level 1, concept) - [Every byte decoded, and the jump lands inside an instruction](https://aiengineeringfromscratch.com/interviews/evidence-reverse-engineering/sweep-trap-addq-at-0x13) (level 2, debug) - [Four tests pass and the rebuild is 26 bytes long](https://aiengineeringfromscratch.com/interviews/evidence-reverse-engineering/listing-before-pseudocode) (level 2, debug) - [nm says one function, the file has five](https://aiengineeringfromscratch.com/interviews/evidence-reverse-engineering/function-finders-in-a-stripped-build) (level 2, tradeoff) - [profile_mismatch after an upgrade and a rename](https://aiengineeringfromscratch.com/interviews/evidence-reverse-engineering/stale-snapshot-refused) (level 2, debug) - [Same id on two machines, refused after one deleted line](https://aiengineeringfromscratch.com/interviews/evidence-reverse-engineering/evidence-id-excludes-the-path) (level 2, concept) - [The table starts at 0x14 and the addend says 0x10](https://aiengineeringfromscratch.com/interviews/evidence-reverse-engineering/addend-0x10-table-0x14) (level 2, code-reading) - [Every breakpoint resolved and none was hit](https://aiengineeringfromscratch.com/interviews/evidence-reverse-engineering/resolved-breakpoint-zero-hits) (level 3, debug) - [How many cells prove two small functions equal](https://aiengineeringfromscratch.com/interviews/evidence-reverse-engineering/hazard-grid-estimate) (level 3, estimate) - [Same 46 bytes, same relocation, wrong table](https://aiengineeringfromscratch.com/interviews/evidence-reverse-engineering/byte-match-is-not-source) (level 3, design) - [Three addresses for grade and four block counts](https://aiengineeringfromscratch.com/interviews/evidence-reverse-engineering/four-bases-four-block-counts) (level 3, debug) - [A proof record that stays unknown without a compiler](https://aiengineeringfromscratch.com/interviews/evidence-reverse-engineering/fail-closed-proof-record) (level 4, design) - [The agent that answers what 95 prints and shows its work](https://aiengineeringfromscratch.com/interviews/evidence-reverse-engineering/agent-dossier-take-home) (level 4, take-home) ### Production and MLOps - [What a week in shadow mode proves](https://aiengineeringfromscratch.com/interviews/production-mlops/shadow-mode-is-a-smoke-test) (level 1, concept) - [What must exist before the first chaos experiment](https://aiengineeringfromscratch.com/interviews/production-mlops/chaos-before-you-start) (level 1, concept) - [Which agent spans are CLIENT and which are INTERNAL](https://aiengineeringfromscratch.com/interviews/production-mlops/span-kind-client-or-internal) (level 1, concept) - [Why a higher eval score still needs an experiment](https://aiengineeringfromscratch.com/interviews/production-mlops/evals-or-ab-test) (level 1, concept) - [An even split that lands at 47 to 53](https://aiengineeringfromscratch.com/interviews/production-mlops/split-ratio-mismatch) (level 2, debug) - [Detect that the questions changed when the evals did not](https://aiengineeringfromscratch.com/interviews/production-mlops/drift-score-on-prompts) (level 2, concept) - [Half an answer and then silence](https://aiengineeringfromscratch.com/interviews/production-mlops/stream-fails-after-200) (level 2, debug) - [How many samples a one percent canary gives a gate](https://aiengineeringfromscratch.com/interviews/production-mlops/canary-samples-at-one-percent) (level 2, estimate) - [Make the next rollback take seconds](https://aiengineeringfromscratch.com/interviews/production-mlops/rollback-without-redeploy) (level 2, design) - [Order the checks before a paid model call](https://aiengineeringfromscratch.com/interviews/production-mlops/checks-in-order-of-cost) (level 2, design) - [Read the prompt router's experiment assignment](https://aiengineeringfromscratch.com/interviews/production-mlops/hash-bucket-assignment) (level 2, code-reading) - [Should the full prompt live on the span](https://aiengineeringfromscratch.com/interviews/production-mlops/prompts-in-span-attributes) (level 2, tradeoff) - [The token dashboard reads zero after an SDK upgrade](https://aiengineeringfromscratch.com/interviews/production-mlops/renamed-token-attribute) (level 2, debug) - [Trace retention when traces cost more than the model](https://aiengineeringfromscratch.com/interviews/production-mlops/keep-every-error-trace) (level 2, design) - [When the triage agent should say it is unsure](https://aiengineeringfromscratch.com/interviews/production-mlops/two-models-disagree) (level 2, concept) - [Catch a leaking prompt within five minutes](https://aiengineeringfromscratch.com/interviews/production-mlops/five-minute-detection) (level 3, design) - [One trace across HTTP and stdio tool servers](https://aiengineeringfromscratch.com/interviews/production-mlops/trace-context-over-stdio) (level 3, design) - [Pick an observability stack without locking in](https://aiengineeringfromscratch.com/interviews/production-mlops/dev-platform-or-telemetry-tool) (level 3, tradeoff) - [Review one span from a new instrumentation branch](https://aiengineeringfromscratch.com/interviews/production-mlops/read-this-span) (level 3, code-reading) - [Set canary gates that do not halt on noise](https://aiengineeringfromscratch.com/interviews/production-mlops/canary-gates-above-noise) (level 3, design) - [Stopping an experiment on the first good morning](https://aiengineeringfromscratch.com/interviews/production-mlops/peeking-at-an-ab-test) (level 3, tradeoff) - [The provider slowed down and your service fell over](https://aiengineeringfromscratch.com/interviews/production-mlops/retries-that-amplify) (level 3, debug) - [Which fixes an operations agent may run alone](https://aiengineeringfromscratch.com/interviews/production-mlops/narrow-auto-remediation) (level 3, tradeoff) - [Keep a production chaos experiment from becoming an incident](https://aiengineeringfromscratch.com/interviews/production-mlops/budget-burn-pauses-chaos) (level 4, design) - [Simulate a shadow, canary and rollback plan](https://aiengineeringfromscratch.com/interviews/production-mlops/rollout-plan-take-home) (level 4, take-home) - [What the system does with a predicted outage](https://aiengineeringfromscratch.com/interviews/production-mlops/prediction-without-action) (level 4, design) ### Cost and capacity - [Sort a workload into interactive, async or batch](https://aiengineeringfromscratch.com/interviews/cost-capacity/batch-lane-triage) (level 1, concept) - [The metric to give finance instead of a token price](https://aiengineeringfromscratch.com/interviews/cost-capacity/cost-per-outcome) (level 1, concept) - [Two caches, and why one did not move the bill](https://aiengineeringfromscratch.com/interviews/cost-capacity/two-cache-layers) (level 1, concept) - [A lower cache threshold hits more and answers wrong](https://aiengineeringfromscratch.com/interviews/cost-capacity/semantic-threshold) (level 2, tradeoff) - [A warm replica all night, or a cold start at eight](https://aiengineeringfromscratch.com/interviews/cost-capacity/warm-pool-or-cold-start) (level 2, tradeoff) - [Controls that stop a bug from spending the month](https://aiengineeringfromscratch.com/interviews/cost-capacity/budget-circuit-breaker) (level 2, design) - [How many reads a cached prefix needs to pay off](https://aiengineeringfromscratch.com/interviews/cost-capacity/cache-break-even) (level 2, estimate) - [Per-token or per-minute billing for a daytime load](https://aiengineeringfromscratch.com/interviews/cost-capacity/per-token-or-per-minute) (level 2, tradeoff) - [Read the exact-match cache before it ships](https://aiengineeringfromscratch.com/interviews/cost-capacity/exact-cache-temperature) (level 2, code-reading) - [Ten parallel tool calls, ten cache writes, no reads](https://aiengineeringfromscratch.com/interviews/cost-capacity/parallel-calls-miss-the-cache) (level 2, debug) - [Two cache hit rates from one scrape](https://aiengineeringfromscratch.com/interviews/cost-capacity/hit-rate-gauge-lies) (level 2, debug) - [Which gateways fit in a 20 ms tail budget](https://aiengineeringfromscratch.com/interviews/cost-capacity/gateway-latency-budget) (level 2, estimate) - [A bigger KV pool that bought nothing, until it did](https://aiengineeringfromscratch.com/interviews/cost-capacity/size-the-pool-from-peak) (level 3, tradeoff) - [A few endless answers fill the pool for everyone](https://aiengineeringfromscratch.com/interviews/cost-capacity/loops-hold-the-pool) (level 3, debug) - [A second replica that undoes the prefix cache](https://aiengineeringfromscratch.com/interviews/cost-capacity/router-decides-hit-rate) (level 3, design) - [Autoscale a model service on queue and cache signals](https://aiengineeringfromscratch.com/interviews/cost-capacity/autoscale-on-the-right-signal) (level 3, design) - [Break an eight-minute start into its parts](https://aiengineeringfromscratch.com/interviews/cost-capacity/cold-start-anatomy) (level 3, estimate) - [Price a nightly pipeline on batch with a cached prompt](https://aiengineeringfromscratch.com/interviews/cost-capacity/overnight-pipeline-cost) (level 3, estimate) - [The router saved half the bill, then the escalations climbed](https://aiengineeringfromscratch.com/interviews/cost-capacity/cheap-model-drift) (level 3, debug) - [Build a cost attribution and enforcement simulator](https://aiengineeringfromscratch.com/interviews/cost-capacity/cost-attribution-take-home) (level 4, take-home) - [Survive a provider outage without a redeploy](https://aiengineeringfromscratch.com/interviews/cost-capacity/two-provider-minimum) (level 4, design) - [Warm replicas per tier, with the arithmetic](https://aiengineeringfromscratch.com/interviews/cost-capacity/scale-to-zero-policy) (level 4, design) ### Safety - [It refuses everything harmful, and the homework](https://aiengineeringfromscratch.com/interviews/safety/two-refusal-metrics) (level 1, concept) - [Name the attack before you defend it](https://aiengineeringfromscratch.com/interviews/safety/six-jailbreak-categories) (level 1, concept) - [The reward keeps climbing, so why worry](https://aiengineeringfromscratch.com/interviews/safety/goodhart-over-optimization-curve) (level 1, concept) - [Constraints a classifier cannot see](https://aiengineeringfromscratch.com/interviews/safety/rule-needs-three-parts) (level 2, design) - [Four review findings, one mechanism](https://aiengineeringfromscratch.com/interviews/safety/four-costumes-one-mechanism) (level 2, concept) - [How hard to penalize agreement](https://aiengineeringfromscratch.com/interviews/safety/agreement-penalty-tradeoff) (level 2, tradeoff) - [Relabeling will not fix the sycophancy](https://aiengineeringfromscratch.com/interviews/safety/sycophancy-is-the-loss) (level 2, concept) - [Replace the labelers with a model that reads principles](https://aiengineeringfromscratch.com/interviews/safety/rlaif-is-not-cheaper-rlhf) (level 2, tradeoff) - [The injection defense is one regex](https://aiengineeringfromscratch.com/interviews/safety/one-regex-is-not-a-detector) (level 2, debug) - [The input passed and the output leaked](https://aiengineeringfromscratch.com/interviews/safety/output-router-severity) (level 2, design) - [The model says 0.9 and is right six times in ten](https://aiengineeringfromscratch.com/interviews/safety/stated-confidence-ece) (level 2, estimate) - [The same attack in base64, rot13 and zero width](https://aiengineeringfromscratch.com/interviews/safety/normalize-then-match) (level 2, design) - [One table says 97 percent refusal](https://aiengineeringfromscratch.com/interviews/safety/safety-eval-missing-pieces) (level 3, debug) - [Refusal when watched, refusal when not](https://aiengineeringfromscratch.com/interviews/safety/compliance-gap-metric) (level 3, concept) - [Rewrite the safety case so it survives review](https://aiengineeringfromscratch.com/interviews/safety/safety-case-after-sleeper-agents) (level 3, design) - [The detector said benign and the stream was cut](https://aiengineeringfromscratch.com/interviews/safety/stream-filter-catches-late) (level 3, debug) - [The KL penalty bounds the drift, not the hack](https://aiengineeringfromscratch.com/interviews/safety/kl-does-not-save-you) (level 3, concept) - [The red team's prompts all pass now](https://aiengineeringfromscratch.com/interviews/safety/adversarial-training-backfires) (level 3, concept) - [Walk three requests through the gate's aggregator](https://aiengineeringfromscratch.com/interviews/safety/gate-aggregation-table) (level 3, code-reading) - [A red team range that runs without you](https://aiengineeringfromscratch.com/interviews/safety/red-team-range-design) (level 4, design) - [Build the safety gate around a retrieval assistant](https://aiengineeringfromscratch.com/interviews/safety/rag-injection-gate-take-home) (level 4, take-home) - [Penalize the reasoning that plans to fake](https://aiengineeringfromscratch.com/interviews/safety/training-against-the-trace) (level 4, tradeoff) ### System design - [A churn model with a good AUC that nobody uses](https://aiengineeringfromscratch.com/interviews/system-design/metric-layers-churn-auc) (level 1, concept) - [The signals that a demo has become a product](https://aiengineeringfromscratch.com/interviews/system-design/demo-to-product-signals) (level 1, concept) - [When to say no to a model](https://aiengineeringfromscratch.com/interviews/system-design/when-not-ml) (level 1, concept) - [A spam classifier from 800 messages and a pretrained body](https://aiengineeringfromscratch.com/interviews/system-design/classifier-head-swap-choice) (level 2, tradeoff) - [Batch or online serving for a two-hour freshness limit](https://aiengineeringfromscratch.com/interviews/system-design/batch-vs-online-serving-choice) (level 2, tradeoff) - [Design a feature store that keeps training honest](https://aiengineeringfromscratch.com/interviews/system-design/feature-store-design) (level 2, design) - [Design monitoring for a payment risk model](https://aiengineeringfromscratch.com/interviews/system-design/drift-monitoring-design) (level 2, design) - [Design the churn system, not the churn model](https://aiengineeringfromscratch.com/interviews/system-design/churn-model-system) (level 2, design) - [Keep a chat service answering when the provider does not](https://aiengineeringfromscratch.com/interviews/system-design/streaming-and-fallback) (level 2, design) - [Project the monthly bill of a chat feature](https://aiengineeringfromscratch.com/interviews/system-design/llm-cost-projection) (level 2, estimate) - [Put a model demo behind a public link safely](https://aiengineeringfromscratch.com/interviews/system-design/public-demo-controls) (level 2, design) - [Roll out a new prompt without betting the product on it](https://aiengineeringfromscratch.com/interviews/system-design/ab-test-prompt-rollout) (level 2, design) - [A payment fraud check inside a hundred milliseconds](https://aiengineeringfromscratch.com/interviews/system-design/fraud-check-100ms) (level 3, design) - [Accuracy fell and every input monitor stayed green](https://aiengineeringfromscratch.com/interviews/system-design/concept-drift-blind-spot) (level 3, debug) - [Design a chat API for ten thousand daily users](https://aiengineeringfromscratch.com/interviews/system-design/batched-inference-api-budget) (level 3, design) - [Design cited search over ten repositories of code](https://aiengineeringfromscratch.com/interviews/system-design/rag-service-company-docs) (level 3, design) - [Design the gate that decides whether a model ships](https://aiengineeringfromscratch.com/interviews/system-design/eval-platform-ship-gate) (level 3, design) - [Offline accuracy was fine and live accuracy is not](https://aiengineeringfromscratch.com/interviews/system-design/skew-triage) (level 3, debug) - [One command from raw data to a served tuned model](https://aiengineeringfromscratch.com/interviews/system-design/finetune-pipeline-design) (level 3, design) - [Keep clean data when the model changes its own future](https://aiengineeringfromscratch.com/interviews/system-design/feedback-loop-clean-data) (level 4, design) - [Review an ML design document and name the blockers](https://aiengineeringfromscratch.com/interviews/system-design/design-doc-blocking-review) (level 4, design) - [Write the rollback plan before the training run starts](https://aiengineeringfromscratch.com/interviews/system-design/pipeline-rollback-plan) (level 4, tradeoff) ### Incidents and scenarios - [A 400 for long answers](https://aiengineeringfromscratch.com/interviews/scenarios/request-400-max-tokens) (level 1, scenario) - [A pool at 5 percent, and the server still died](https://aiengineeringfromscratch.com/interviews/scenarios/auto-fraction-oom-at-concurrency-32) (level 1, scenario) - [A published port that answered on one loopback](https://aiengineeringfromscratch.com/interviews/scenarios/port-published-on-ipv4-only) (level 1, scenario) - [A tracker flag that stopped the run at start](https://aiengineeringfromscratch.com/interviews/scenarios/tracker-without-a-group) (level 1, scenario) - [The sandbox stopped itself](https://aiengineeringfromscratch.com/interviews/scenarios/the-sandbox-stopped-itself) (level 1, scenario) - [The trainer rejects the attention name](https://aiengineeringfromscratch.com/interviews/scenarios/trainer-rejects-the-attention-backend) (level 1, scenario) - [A bigger prefill chunk that did not start](https://aiengineeringfromscratch.com/interviews/scenarios/chunked-prefill-8192-graph-oom) (level 2, scenario) - [A five-minute cold start on the GB10](https://aiengineeringfromscratch.com/interviews/scenarios/cold-start-on-gb10) (level 2, scenario) - [A kit from a local registry, three refusals](https://aiengineeringfromscratch.com/interviews/scenarios/kit-from-a-local-registry) (level 2, scenario) - [A request ID that opens the prompt](https://aiengineeringfromscratch.com/interviews/scenarios/request-id-at-prompt-start) (level 2, scenario) - [A resumed run that started from step 0 in silence](https://aiengineeringfromscratch.com/interviews/scenarios/resume-that-started-fresh) (level 2, scenario) - [A reward import error and a run that never stopped](https://aiengineeringfromscratch.com/interviews/scenarios/reward-module-not-found-run-hangs) (level 2, scenario) - [A rolling update that dropped every running answer](https://aiengineeringfromscratch.com/interviews/scenarios/sigterm-to-the-process-group) (level 2, scenario) - [A shutdown that retried a cancel forever](https://aiengineeringfromscratch.com/interviews/scenarios/cancel-a-finished-task) (level 2, scenario) - [A thermal throttle that voided an A/B test](https://aiengineeringfromscratch.com/interviews/scenarios/thermal-throttle-voided-ab-test) (level 2, scenario) - [An engine share of 0.02 and a rollout six times slower](https://aiengineeringfromscratch.com/interviews/scenarios/fraction-too-low-six-times-slower) (level 2, scenario) - [An hour of polling a task that waited for us](https://aiengineeringfromscratch.com/interviews/scenarios/polling-a-parked-task) (level 2, scenario) - [An implicit deny that looked like an outage](https://aiengineeringfromscratch.com/interviews/scenarios/implicit-deny-looked-like-an-outage) (level 2, scenario) - [CUDA graphs turned off to start faster](https://aiengineeringfromscratch.com/interviews/scenarios/graphs-off-to-start-faster) (level 2, scenario) - [Five identical calls and a run that ended itself](https://aiengineeringfromscratch.com/interviews/scenarios/five-identical-calls) (level 2, scenario) - [Four failed starts after a pip install](https://aiengineeringfromscratch.com/interviews/scenarios/pip-install-four-failed-starts) (level 2, scenario) - [FP8 cleared the queue at 64 users](https://aiengineeringfromscratch.com/interviews/scenarios/fp8-cleared-the-queue-at-64-users) (level 2, scenario) - [Health probes that add load](https://aiengineeringfromscratch.com/interviews/scenarios/health-probes-add-load) (level 2, scenario) - [One error, two status codes](https://aiengineeringfromscratch.com/interviews/scenarios/task-not-found-in-two-bindings) (level 2, scenario) - [Six steps in, is the run learning](https://aiengineeringfromscratch.com/interviews/scenarios/is-it-learning-read-ten-steps) (level 2, scenario) - [Startup out of memory on a shared GPU](https://aiengineeringfromscratch.com/interviews/scenarios/startup-oom-shared-gpu) (level 2, scenario) - [The draft that declared 2,048 positions](https://aiengineeringfromscratch.com/interviews/scenarios/eagle3-draft-refused-context-length) (level 2, scenario) - [The key in the log was a placeholder](https://aiengineeringfromscratch.com/interviews/scenarios/the-key-that-was-a-placeholder) (level 2, scenario) - [The radix cache turned off for predictability](https://aiengineeringfromscratch.com/interviews/scenarios/radix-cache-off-for-predictability) (level 2, scenario) - [Two refusals, two wordings, one agent file](https://aiengineeringfromscratch.com/interviews/scenarios/denied-by-policy-or-by-the-user) (level 2, scenario) - [Which side failed, the engine or the input](https://aiengineeringfromscratch.com/interviews/scenarios/which-side-failed-the-engine-or-the-input) (level 2, scenario) - [A card that said production](https://aiengineeringfromscratch.com/interviews/scenarios/card-changed-in-transit) (level 3, scenario) - [A dead rollout engine and a watchdog that kills](https://aiengineeringfromscratch.com/interviews/scenarios/dead-engine-and-watchdog) (level 3, scenario) - [A dropped stream ran the suite twice](https://aiengineeringfromscratch.com/interviews/scenarios/dropped-stream-resent-the-message) (level 3, scenario) - [A flaky agent check that compared the wrong sessions](https://aiengineeringfromscratch.com/interviews/scenarios/first-divergence-at-turn-zero) (level 3, scenario) - [A read-only database on a read-write mount](https://aiengineeringfromscratch.com/interviews/scenarios/readonly-database-inside-the-sandbox) (level 3, scenario) - [A split benchmark that counted failures as wins](https://aiengineeringfromscratch.com/interviews/scenarios/disaggregated-benchmark-false-success) (level 3, scenario) - [An alert on a driver line that paged nine times](https://aiengineeringfromscratch.com/interviews/scenarios/alert-on-the-driver-line) (level 3, scenario) - [An empty list that an agent read as none](https://aiengineeringfromscratch.com/interviews/scenarios/an-empty-list-is-not-none) (level 3, scenario) - [An RL speedup that was not an effect](https://aiengineeringfromscratch.com/interviews/scenarios/rl-experiment-hygiene) (level 3, scenario) - [FP8 KV scales silently at 1.0](https://aiengineeringfromscratch.com/interviews/scenarios/fp8-kv-scale-silently-one) (level 3, scenario) - [LRU thrash in a small pool, then a crash](https://aiengineeringfromscratch.com/interviews/scenarios/small-pool-lru-thrash) (level 3, scenario) - [More load gave a faster first token](https://aiengineeringfromscratch.com/interviews/scenarios/prefix-cache-inflated-benchmark) (level 3, scenario) - [Ray stops the trainer on unified memory](https://aiengineeringfromscratch.com/interviews/scenarios/ray-oom-unified-memory) (level 3, scenario) - [Speculation chosen on random prompts](https://aiengineeringfromscratch.com/interviews/scenarios/speculation-chosen-on-random-prompts) (level 3, scenario) - [Speculation depth against batch size](https://aiengineeringfromscratch.com/interviews/scenarios/speculation-depth-vs-batch) (level 3, scenario) - [Temperature 0 still gave two answers](https://aiengineeringfromscratch.com/interviews/scenarios/temperature-zero-two-answers) (level 3, scenario) - [Tensor parallel refused, data parallel starved](https://aiengineeringfromscratch.com/interviews/scenarios/tp2-refused-then-dp2-starved) (level 3, scenario) - [The load knee and the cap that made it worse](https://aiengineeringfromscratch.com/interviews/scenarios/load-knee-and-admission-cap) (level 3, scenario) - [The logprob gap that jumped when the engine changed](https://aiengineeringfromscratch.com/interviews/scenarios/logprobs-after-top-p) (level 3, scenario) - [Two clients, two numbers, one server](https://aiengineeringfromscratch.com/interviews/scenarios/two-clients-two-numbers) (level 3, scenario) - [Two of two evals failed, and none of them ran](https://aiengineeringfromscratch.com/interviews/scenarios/eval-failed-with-zero-cost) (level 3, scenario) - [Uniform prompt lengths that hid the stall](https://aiengineeringfromscratch.com/interviews/scenarios/uniform-prompts-hid-the-stall) (level 3, scenario) - [A conformance score of 32.3 percent](https://aiengineeringfromscratch.com/interviews/scenarios/conformance-score-of-32-percent) (level 4, scenario) - [A memory guard paused the scheduler mid-start](https://aiengineeringfromscratch.com/interviews/scenarios/memory-guard-paused-the-scheduler) (level 4, scenario) - [A rate sweep that never reached steady state](https://aiengineeringfromscratch.com/interviews/scenarios/rate-sweep-never-reached-steady-state) (level 4, scenario) - [A rebuilt function that was plausible, not equal](https://aiengineeringfromscratch.com/interviews/scenarios/plausible-is-not-equal) (level 4, scenario) - [An eval that stopped the run before step 0](https://aiengineeringfromscratch.com/interviews/scenarios/eval-at-step-zero-503) (level 4, scenario) - [An exit code of zero that was not a pass](https://aiengineeringfromscratch.com/interviews/scenarios/exit-zero-was-not-a-pass) (level 4, scenario) - [Three reboots in one day under RL load](https://aiengineeringfromscratch.com/interviews/scenarios/three-reboots-in-one-day) (level 4, scenario) ### Coding - [The scale factor in dot-product attention](https://aiengineeringfromscratch.com/interviews/coding/scale-by-sqrt-dk) (level 1, code-reading) - [What temperature does to sampling](https://aiengineeringfromscratch.com/interviews/coding/temperature-knob) (level 1, concept) - [Why softmax subtracts the row maximum first](https://aiengineeringfromscratch.com/interviews/coding/softmax-shift-max) (level 1, code-reading) - [A causal mask that blocks the token itself](https://aiengineeringfromscratch.com/interviews/coding/causal-mask-off-by-one) (level 2, code-reading) - [A merge that lets two matches share a symbol](https://aiengineeringfromscratch.com/interviews/coding/bpe-merge-no-overlap) (level 2, code-reading) - [A training loss that reaches zero and learns nothing](https://aiengineeringfromscratch.com/interviews/coding/loss-shift-flatten) (level 2, code-reading) - [Dropout that still acts during evaluation](https://aiengineeringfromscratch.com/interviews/coding/dropout-off-at-eval) (level 2, code-reading) - [Split heads with the right shape and the wrong numbers](https://aiengineeringfromscratch.com/interviews/coding/split-heads-reshape) (level 2, code-reading) - [Swap the learned position table for a fixed one](https://aiengineeringfromscratch.com/interviews/coding/sinusoidal-table-swap) (level 2, take-home) - [Train a BPE merge list from word counts](https://aiengineeringfromscratch.com/interviews/coding/bpe-train-loop) (level 2, take-home) - [Weight decay that went into the gradient](https://aiengineeringfromscratch.com/interviews/coding/adamw-decoupled-decay) (level 2, code-reading) - [Write the sampling step of a generation loop](https://aiengineeringfromscratch.com/interviews/coding/top-k-then-sample) (level 2, take-home) - [A KV cache that loses its last slot](https://aiengineeringfromscratch.com/interviews/coding/kv-cache-capacity-slide) (level 3, code-reading) - [Attention heads that never mix](https://aiengineeringfromscratch.com/interviews/coding/output-projection-missing) (level 3, debug) - [GQA that pairs query heads with the wrong group](https://aiengineeringfromscratch.com/interviews/coding/gqa-repeat-not-tile) (level 3, code-reading) - [Nucleus sampling that drops the token which reaches p](https://aiengineeringfromscratch.com/interviews/coding/top-p-crossing-token) (level 3, debug) - [Swap the final LayerNorm for RMSNorm without breaking it](https://aiengineeringfromscratch.com/interviews/coding/rmsnorm-vs-layernorm) (level 3, code-reading) - [Sweep the peak learning rate and mark divergence](https://aiengineeringfromscratch.com/interviews/coding/lr-peak-sweep) (level 3, take-home) - [Train the smallest language model past its baseline](https://aiengineeringfromscratch.com/interviews/coding/bigram-beats-unigram) (level 3, take-home) - [Which parameters get weight decay](https://aiengineeringfromscratch.com/interviews/coding/decay-split-param-groups) (level 3, code-reading) - [A byte-level tokenizer with protected special tokens](https://aiengineeringfromscratch.com/interviews/coding/tokenizer-roundtrip-specials) (level 4, take-home) - [Convert a multi-head checkpoint to grouped-query heads](https://aiengineeringfromscratch.com/interviews/coding/gqa-checkpoint-pooling) (level 4, estimate) ### Behavioral - [Leave work so that someone else can resume it](https://aiengineeringfromscratch.com/interviews/behavioral/leave-work-resumable) (level 1, concept) - [Reframe a request that names its own solution](https://aiengineeringfromscratch.com/interviews/behavioral/outcome-before-output) (level 1, concept) - [Define the first slice so it can change the decision](https://aiengineeringfromscratch.com/interviews/behavioral/smallest-slice-that-decides) (level 2, design) - [Pick the first experiment from a roadmap of features](https://aiengineeringfromscratch.com/interviews/behavioral/riskiest-assumption-first) (level 2, design) - [Set the success metric before the first result exists](https://aiengineeringfromscratch.com/interviews/behavioral/metric-before-result) (level 2, design) - [The same correction for the third time](https://aiengineeringfromscratch.com/interviews/behavioral/correction-to-control) (level 2, concept) - [Two users describe two different workflows](https://aiengineeringfromscratch.com/interviews/behavioral/two-users-two-workflows) (level 2, tradeoff) - [Weigh what a stakeholder tells you about their workflow](https://aiengineeringfromscratch.com/interviews/behavioral/evidence-ladder-for-workflows) (level 2, concept) - [What you check before you approve an execution plan](https://aiengineeringfromscratch.com/interviews/behavioral/plan-you-would-reject) (level 2, debug) - [A prototype that quietly acquired real users](https://aiengineeringfromscratch.com/interviews/behavioral/prototype-became-production) (level 3, debug) - [Brief the decision owner after a setback](https://aiengineeringfromscratch.com/interviews/behavioral/decision-brief-after-setback) (level 3, design) - [Decide what to delete from a bloated instruction file](https://aiengineeringfromscratch.com/interviews/behavioral/retire-a-rule) (level 3, tradeoff) - [Decide whether to split work across parallel workers](https://aiengineeringfromscratch.com/interviews/behavioral/split-that-only-looks-parallel) (level 3, tradeoff) - [Write a specification that leaves judgment where it belongs](https://aiengineeringfromscratch.com/interviews/behavioral/locked-bounded-delegated) (level 3, design) - [Decide which choices an agent may make alone](https://aiengineeringfromscratch.com/interviews/behavioral/agent-decides-alone) (level 4, tradeoff) - [Turn telemetry nobody owns into a learning loop](https://aiengineeringfromscratch.com/interviews/behavioral/feedback-ratchet-owner) (level 4, design) ## Optional - [Catalog](https://aiengineeringfromscratch.com/catalog) — full searchable lesson index - [Blogs & Guides](https://aiengineeringfromscratch.com/blogs) - articles and practical guides on AI engineering, developer tools, and building software - [Roadmap](https://aiengineeringfromscratch.com/roadmap) — prerequisite ordering across phases - [AI Engineering Learning Paths](https://aiengineeringfromscratch.com/learning-paths) — four core domain paths and six career routes connected to practical lessons - [Glossary](https://aiengineeringfromscratch.com/glossary) — plain-language definitions of 250 terms - [Sponsor the project](https://aiengineeringfromscratch.com/sponsors) — sponsorship tiers, rules, and current sponsors from SPONSORS.md - [AI Engineering Landscape](https://aiengineeringfromscratch.com/landscape) - open and closed source AI engineering tools by category, with the data in landscape/entries ## Certification preparation Independent, open-source practice material. Practice scores are not official exam scores and completion does not guarantee certification. - [Claude Certification Curriculum learner guide](https://raw.githubusercontent.com/rohitg00/ai-engineering-from-scratch/main/certifications/claude/GETTING_STARTED.md) - [Claude Certification Curriculum tutor contract](https://raw.githubusercontent.com/rohitg00/ai-engineering-from-scratch/main/skills/claude-certification/SKILL.md) - [MCPA Certification Curriculum learner guide](https://raw.githubusercontent.com/rohitg00/ai-engineering-from-scratch/main/certifications/mcpa/GETTING_STARTED.md) - [MCPA Certification Curriculum tutor contract](https://raw.githubusercontent.com/rohitg00/ai-engineering-from-scratch/main/skills/mcpa-certification/SKILL.md) - [Certification catalog](https://aiengineeringfromscratch.com/certifications) - [Claude Certified Associate - Foundations](https://aiengineeringfromscratch.com/certification?id=claude-ccao-f) — Use Claude safely and effectively for business, research, analysis, and productivity workflows. - [Claude Certified Developer - Foundations](https://aiengineeringfromscratch.com/certification?id=claude-ccdv-f) — Build, integrate, secure, test, and ship Claude applications, agents, workflows, tools, and MCP servers. - [Claude Certified Architect - Foundations](https://aiengineeringfromscratch.com/certification?id=claude-ccar-f) — Make sound production tradeoffs across Claude Code, the Claude Agent SDK, the Claude API, and MCP. - [Claude Certified Architect - Professional](https://aiengineeringfromscratch.com/certification?id=claude-ccar-p) — Own the full lifecycle of secure, observable, production-grade Claude systems from discovery to iteration. - [Model Context Protocol Associate](https://aiengineeringfromscratch.com/certification?id=mcpa-f) — Prove you understand how the Model Context Protocol works: its hosts, clients, servers, and tools, the message flow and primitives that connect them, and the trust boundaries that keep the connection safe. - [Study the Decisions, Not the Vocabulary](https://aiengineeringfromscratch.com/lesson?path=certifications%2Fclaude%2Flessons%2F00-certification-strategy) · [raw](https://raw.githubusercontent.com/rohitg00/ai-engineering-from-scratch/main/certifications/claude/lessons/00-certification-strategy/docs/en.md) — A certification blueprint is a map of decisions a competent practitioner can defend. Treat it as a list of terms and you will study the least useful part of the exam. - [Choose the Smallest Surface That Can Carry the Work](https://aiengineeringfromscratch.com/lesson?path=certifications%2Fclaude%2Flessons%2F01-claude-product-and-model-landscape) · [raw](https://raw.githubusercontent.com/rohitg00/ai-engineering-from-scratch/main/certifications/claude/lessons/01-claude-product-and-model-landscape/docs/en.md) — Product selection is architecture at knowledge-work scale. The wrong surface can make correct output stale, unreviewable, or needlessly expensive. - [Spend Capability Where Failure Is Expensive](https://aiengineeringfromscratch.com/lesson?path=certifications%2Fclaude%2Flessons%2F02-model-selection-and-token-economics) · [raw](https://raw.githubusercontent.com/rohitg00/ai-engineering-from-scratch/main/certifications/claude/lessons/02-model-selection-and-token-economics/docs/en.md) — Model selection is not a ranking exercise. It is an allocation problem across quality, latency, context, and cost. - [Turn a Request Into a Testable Contract](https://aiengineeringfromscratch.com/lesson?path=certifications%2Fclaude%2Flessons%2F03-prompting-and-task-decomposition) · [raw](https://raw.githubusercontent.com/rohitg00/ai-engineering-from-scratch/main/certifications/claude/lessons/03-prompting-and-task-decomposition/docs/en.md) — A strong prompt does not merely describe what to write. It makes success observable before generation begins. - [Put Each Fact in the Right Kind of Context](https://aiengineeringfromscratch.com/lesson?path=certifications%2Fclaude%2Flessons%2F04-context-knowledge-memory-and-caching) · [raw](https://raw.githubusercontent.com/rohitg00/ai-engineering-from-scratch/main/certifications/claude/lessons/04-context-knowledge-memory-and-caching/docs/en.md) — Context is temporary attention. Knowledge is maintained evidence. Memory is continuity. Caching is reuse. Mixing them creates confident stale answers. - [Validate the Claim, Not the Confidence](https://aiengineeringfromscratch.com/lesson?path=certifications%2Fclaude%2Flessons%2F05-output-evaluation-and-validation) · [raw](https://raw.githubusercontent.com/rohitg00/ai-engineering-from-scratch/main/certifications/claude/lessons/05-output-evaluation-and-validation/docs/en.md) — Fluency is presentation quality. Validation is evidence that the output can safely do its job. - [Put Authority Around Capability](https://aiengineeringfromscratch.com/lesson?path=certifications%2Fclaude%2Flessons%2F06-governance-safety-and-responsible-use) · [raw](https://raw.githubusercontent.com/rohitg00/ai-engineering-from-scratch/main/certifications/claude/lessons/06-governance-safety-and-responsible-use/docs/en.md) — A model can produce an answer without having permission to see the data, make the decision, or take the action. - [Design the Handoff Before the Automation](https://aiengineeringfromscratch.com/lesson?path=certifications%2Fclaude%2Flessons%2F07-workflow-design-and-human-handoffs) · [raw](https://raw.githubusercontent.com/rohitg00/ai-engineering-from-scratch/main/certifications/claude/lessons/07-workflow-design-and-human-handoffs/docs/en.md) — A workflow is not complete when Claude finishes. It is complete when the next person can verify, decide, act, and recover. - [The Messages API Is a State Machine](https://aiengineeringfromscratch.com/lesson?path=certifications%2Fclaude%2Flessons%2F08-messages-api-and-application-lifecycle) · [raw](https://raw.githubusercontent.com/rohitg00/ai-engineering-from-scratch/main/certifications/claude/lessons/08-messages-api-and-application-lifecycle/docs/en.md) — The API does not remember your conversation. Your application does, and one misplaced content block can break the entire loop. - [Structured Output Is an Untrusted Contract](https://aiengineeringfromscratch.com/lesson?path=certifications%2Fclaude%2Flessons%2F09-structured-output-and-defensive-parsing) · [raw](https://raw.githubusercontent.com/rohitg00/ai-engineering-from-scratch/main/certifications/claude/lessons/09-structured-output-and-defensive-parsing/docs/en.md) — Valid JSON is not a valid business decision. Parse the bytes, validate the shape, verify the meaning, then permit the action. - [A Tool Loop Is Controlled Delegation](https://aiengineeringfromscratch.com/lesson?path=certifications%2Fclaude%2Flessons%2F10-tool-use-and-agentic-loops) · [raw](https://raw.githubusercontent.com/rohitg00/ai-engineering-from-scratch/main/certifications/claude/lessons/10-tool-use-and-agentic-loops/docs/en.md) — Claude may propose an action. Your application validates the request, grants the capability, observes the result, and decides whether the loop continues. - [MCP Separates Capability From Host](https://aiengineeringfromscratch.com/lesson?path=certifications%2Fclaude%2Flessons%2F11-mcp-server-design-and-integration) · [raw](https://raw.githubusercontent.com/rohitg00/ai-engineering-from-scratch/main/certifications/claude/lessons/11-mcp-server-design-and-integration/docs/en.md) — Build a narrow, stateless MCP server whose contract can be discovered, cached, invoked, and scaled without hidden connection state. - [The Agent SDK Is a Harness, Not Permission](https://aiengineeringfromscratch.com/lesson?path=certifications%2Fclaude%2Flessons%2F12-claude-agent-sdk-and-hooks) · [raw](https://raw.githubusercontent.com/rohitg00/ai-engineering-from-scratch/main/certifications/claude/lessons/12-claude-agent-sdk-and-hooks/docs/en.md) — An agent becomes dependable when the loop, tools, context, hooks, and termination policy are explicit enough to inspect and constrain. - [Security Lives Outside the Prompt](https://aiengineeringfromscratch.com/lesson?path=certifications%2Fclaude%2Flessons%2F13-application-security-and-secrets) · [raw](https://raw.githubusercontent.com/rohitg00/ai-engineering-from-scratch/main/certifications/claude/lessons/13-application-security-and-secrets/docs/en.md) — The model can recommend a safe action. Only deterministic controls can make an unsafe action impossible. - [Evals Turn Agent Behavior Into Engineering Evidence](https://aiengineeringfromscratch.com/lesson?path=certifications%2Fclaude%2Flessons%2F14-evals-testing-debugging-and-observability) · [raw](https://raw.githubusercontent.com/rohitg00/ai-engineering-from-scratch/main/certifications/claude/lessons/14-evals-testing-debugging-and-observability/docs/en.md) — A trace tells you what happened. An eval tells you whether it was acceptable. A regression gate keeps the next change from quietly making it worse. - [Repository guide](https://aiengineeringfromscratch.com/lesson?path=certifications%2Fclaude%2Flessons%2F15-claude-code-for-development-teams) · [raw](https://raw.githubusercontent.com/rohitg00/ai-engineering-from-scratch/main/certifications/claude/lessons/15-claude-code-for-development-teams/docs/en.md) — A team does not need one giant prompt. It needs a small project contract, reusable procedures, deterministic checks, and versioned configuration. - [Multi-Agent Orchestration and Delegation](https://aiengineeringfromscratch.com/lesson?path=certifications%2Fclaude%2Flessons%2F16-multi-agent-orchestration-and-delegation) · [raw](https://raw.githubusercontent.com/rohitg00/ai-engineering-from-scratch/main/certifications/claude/lessons/16-multi-agent-orchestration-and-delegation/docs/en.md) — Delegate a bounded question, not your entire uncertainty. - [Agent SDK Sessions, Subagents, and Context](https://aiengineeringfromscratch.com/lesson?path=certifications%2Fclaude%2Flessons%2F17-agent-sdk-sessions-subagents-and-context) · [raw](https://raw.githubusercontent.com/rohitg00/ai-engineering-from-scratch/main/certifications/claude/lessons/17-agent-sdk-sessions-subagents-and-context/docs/en.md) — Resume state when continuity helps. Fork context when inherited assumptions become risk. - [Tool Contracts, Errors, and Progressive Discovery](https://aiengineeringfromscratch.com/lesson?path=certifications%2Fclaude%2Flessons%2F18-tool-contracts-errors-and-progressive-discovery) · [raw](https://raw.githubusercontent.com/rohitg00/ai-engineering-from-scratch/main/certifications/claude/lessons/18-tool-contracts-errors-and-progressive-discovery/docs/en.md) — The model chooses from the interface you describe. Ambiguous tools create ambiguous behavior. - [Claude Code Memory, Rules, Skills, and CI](https://aiengineeringfromscratch.com/lesson?path=certifications%2Fclaude%2Flessons%2F19-claude-code-memory-rules-skills-and-ci) · [raw](https://raw.githubusercontent.com/rohitg00/ai-engineering-from-scratch/main/certifications/claude/lessons/19-claude-code-memory-rules-skills-and-ci/docs/en.md) — Put stable guidance where its scope is true, and executable constraints where failure is unacceptable. - [Reliable Extraction, Batch, and Independent Reviewers](https://aiengineeringfromscratch.com/lesson?path=certifications%2Fclaude%2Flessons%2F20-reliable-extraction-batch-and-reviewers) · [raw](https://raw.githubusercontent.com/rohitg00/ai-engineering-from-scratch/main/certifications/claude/lessons/20-reliable-extraction-batch-and-reviewers/docs/en.md) — Valid JSON proves the shape survived. It does not prove the facts did. - [Make Large Context Observable](https://aiengineeringfromscratch.com/lesson?path=certifications%2Fclaude%2Flessons%2F21-long-context-reliability-provenance-and-escalation) · [raw](https://raw.githubusercontent.com/rohitg00/ai-engineering-from-scratch/main/certifications/claude/lessons/21-long-context-reliability-provenance-and-escalation/docs/en.md) — A large context window can hold more evidence. It cannot tell you which evidence was noticed, current, authoritative, or safe to act on. - [ADR: Support Resolution Pattern](https://aiengineeringfromscratch.com/lesson?path=certifications%2Fclaude%2Flessons%2F22-business-discovery-requirements-and-slas) · [raw](https://raw.githubusercontent.com/rohitg00/ai-engineering-from-scratch/main/certifications/claude/lessons/22-business-discovery-requirements-and-slas/docs/en.md) — The first architecture decision is deciding what problem you are actually responsible for solving. - [End-to-End Architecture and Value Tradeoffs](https://aiengineeringfromscratch.com/lesson?path=certifications%2Fclaude%2Flessons%2F23-end-to-end-architecture-and-value-tradeoffs) · [raw](https://raw.githubusercontent.com/rohitg00/ai-engineering-from-scratch/main/certifications/claude/lessons/23-end-to-end-architecture-and-value-tradeoffs/docs/en.md) — Architecture is the art of spending complexity only where it changes the outcome. - [RAG, Retrieval, and Data Pipelines](https://aiengineeringfromscratch.com/lesson?path=certifications%2Fclaude%2Flessons%2F24-rag-retrieval-and-data-pipelines) · [raw](https://raw.githubusercontent.com/rohitg00/ai-engineering-from-scratch/main/certifications/claude/lessons/24-rag-retrieval-and-data-pipelines/docs/en.md) — A grounded answer is only as trustworthy as the evidence that reached the model. - [Integration Protocols, Identity, and Least Privilege](https://aiengineeringfromscratch.com/lesson?path=certifications%2Fclaude%2Flessons%2F25-integration-protocols-identity-and-least-privilege) · [raw](https://raw.githubusercontent.com/rohitg00/ai-engineering-from-scratch/main/certifications/claude/lessons/25-integration-protocols-identity-and-least-privilege/docs/en.md) — A tool is not safe because Claude uses it carefully. It is safe when the system refuses unauthorized use. - [Production Observability, Latency, and Cost](https://aiengineeringfromscratch.com/lesson?path=certifications%2Fclaude%2Flessons%2F26-production-observability-latency-and-cost) · [raw](https://raw.githubusercontent.com/rohitg00/ai-engineering-from-scratch/main/certifications/claude/lessons/26-production-observability-latency-and-cost/docs/en.md) — A green API call can still be a failed task. - [Enterprise Governance, Compliance, and Human Review](https://aiengineeringfromscratch.com/lesson?path=certifications%2Fclaude%2Flessons%2F27-enterprise-governance-compliance-and-hitl) · [raw](https://raw.githubusercontent.com/rohitg00/ai-engineering-from-scratch/main/certifications/claude/lessons/27-enterprise-governance-compliance-and-hitl/docs/en.md) — Governance is the system that decides who may take which risk with whose data. - [Stakeholder Communication, ADRs, and Lifecycle Ownership](https://aiengineeringfromscratch.com/lesson?path=certifications%2Fclaude%2Flessons%2F28-stakeholder-communication-adrs-and-lifecycle) · [raw](https://raw.githubusercontent.com/rohitg00/ai-engineering-from-scratch/main/certifications/claude/lessons/28-stakeholder-communication-adrs-and-lifecycle/docs/en.md) — An architecture is not delivered when the diagram is finished. It is delivered when the next owner can operate the decision. - [Ship a Week of Work, Not a Perfect Prompt](https://aiengineeringfromscratch.com/lesson?path=certifications%2Fclaude%2Flessons%2F29-associate-workflow-capstone) · [raw](https://raw.githubusercontent.com/rohitg00/ai-engineering-from-scratch/main/certifications/claude/lessons/29-associate-workflow-capstone/docs/en.md) — Your capstone is a governed decision workflow: sources in, claims checked, human authority preserved, and state handed off. - [Ship a Claude Application You Can Defend](https://aiengineeringfromscratch.com/lesson?path=certifications%2Fclaude%2Flessons%2F30-developer-application-capstone) · [raw](https://raw.githubusercontent.com/rohitg00/ai-engineering-from-scratch/main/certifications/claude/lessons/30-developer-application-capstone/docs/en.md) — The capstone is not a chatbot demo. It is a bounded application with a wire contract, security boundary, eval evidence, and recovery plan. - [Defend One Architecture Across Six Contexts](https://aiengineeringfromscratch.com/lesson?path=certifications%2Fclaude%2Flessons%2F31-architect-foundations-scenario-capstone) · [raw](https://raw.githubusercontent.com/rohitg00/ai-engineering-from-scratch/main/certifications/claude/lessons/31-architect-foundations-scenario-capstone/docs/en.md) — Architecture is the set of boundaries that still hold when the scenario changes, a tool fails, and the evidence is incomplete. - [Architect Professional System Capstone](https://aiengineeringfromscratch.com/lesson?path=certifications%2Fclaude%2Flessons%2F32-architect-professional-system-capstone) · [raw](https://raw.githubusercontent.com/rohitg00/ai-engineering-from-scratch/main/certifications/claude/lessons/32-architect-professional-system-capstone/docs/en.md) — Build the evidence packet that makes a production architecture defensible. - [The MCPA Blueprint Is a Study Budget, Not a Checklist](https://aiengineeringfromscratch.com/lesson?path=certifications%2Fmcpa%2Flessons%2F00-mcp-exam-strategy) · [raw](https://raw.githubusercontent.com/rohitg00/ai-engineering-from-scratch/main/certifications/mcpa/lessons/00-mcp-exam-strategy/docs/en.md) — A syllabus lists what might appear on an exam. A blueprint states how often each part actually does. Read the MCPA blueprint as a budget for your study hours, not a table of con… - [Reading the MCP Specification](https://aiengineeringfromscratch.com/lesson?path=certifications%2Fmcpa%2Flessons%2F01-reading-the-specification) · [raw](https://raw.githubusercontent.com/rohitg00/ai-engineering-from-scratch/main/certifications/mcpa/lessons/01-reading-the-specification/docs/en.md) — The specification is normative text, not a tutorial: a MUST decides an implementation, a SHOULD leaves room for judgment, and a feature's Deprecated state tells you exactly how … - [The Integration Problem MCP Solves](https://aiengineeringfromscratch.com/lesson?path=certifications%2Fmcpa%2Flessons%2F02-the-integration-problem) · [raw](https://raw.githubusercontent.com/rohitg00/ai-engineering-from-scratch/main/certifications/mcpa/lessons/02-the-integration-problem/docs/en.md) — Every system you connect to an AI application is a contract. MCP makes that contract the same shape everywhere, so one client can use a server it has never seen before. - [The JSON-RPC Envelope](https://aiengineeringfromscratch.com/lesson?path=certifications%2Fmcpa%2Flessons%2F03-json-rpc-and-meta) · [raw](https://raw.githubusercontent.com/rohitg00/ai-engineering-from-scratch/main/certifications/mcpa/lessons/03-json-rpc-and-meta/docs/en.md) — A server that has never talked to you before still has to know, from this one message alone, whether you expect an answer, which protocol version you speak, and where your metad… - [The Stateless Core of MCP](https://aiengineeringfromscratch.com/lesson?path=certifications%2Fmcpa%2Flessons%2F04-the-stateless-core) · [raw](https://raw.githubusercontent.com/rohitg00/ai-engineering-from-scratch/main/certifications/mcpa/lessons/04-the-stateless-core/docs/en.md) — Every request carries everything a server needs to answer it; nothing carries over from the request before it, not even on the same connection. - [Telling a Modern MCP Server From a Legacy One](https://aiengineeringfromscratch.com/lesson?path=certifications%2Fmcpa%2Flessons%2F05-protocol-eras-and-compatibility) · [raw](https://raw.githubusercontent.com/rohitg00/ai-engineering-from-scratch/main/certifications/mcpa/lessons/05-protocol-eras-and-compatibility/docs/en.md) — Modern MCP has no opening handshake, so a client that must work with both current and older servers has to work out which kind it is talking to from how the very first exchange … - [Hosts, Clients, and Servers: MCP's Process Topology](https://aiengineeringfromscratch.com/lesson?path=certifications%2Fmcpa%2Flessons%2F06-hosts-clients-and-servers) · [raw](https://raw.githubusercontent.com/rohitg00/ai-engineering-from-scratch/main/certifications/mcpa/lessons/06-hosts-clients-and-servers/docs/en.md) — A host never talks to a server directly, only through one client per server. That single binding is where MCP draws its trust boundaries, and where a host aggregating many serve… - [Discovering a Server and Negotiating What It Can Do](https://aiengineeringfromscratch.com/lesson?path=certifications%2Fmcpa%2Flessons%2F07-discovery-and-capability-negotiation) · [raw](https://raw.githubusercontent.com/rohitg00/ai-engineering-from-scratch/main/certifications/mcpa/lessons/07-discovery-and-capability-negotiation/docs/en.md) — A server describes itself once through `server/discover`, but every request still declares its own capabilities: nothing the server needs is assumed just because a client asked … - [The Contract Inside a Tool Definition](https://aiengineeringfromscratch.com/lesson?path=certifications%2Fmcpa%2Flessons%2F08-tool-schemas-and-structured-content) · [raw](https://raw.githubusercontent.com/rohitg00/ai-engineering-from-scratch/main/certifications/mcpa/lessons/08-tool-schemas-and-structured-content/docs/en.md) — An inputSchema is not a suggestion the model can approximate: a server checks arguments against it before a handler ever runs, and a broken argument still comes back as a result… - [Reading a Server Manifest Like a Reviewer](https://aiengineeringfromscratch.com/lesson?path=certifications%2Fmcpa%2Flessons%2F09-reading-server-manifests) · [raw](https://raw.githubusercontent.com/rohitg00/ai-engineering-from-scratch/main/certifications/mcpa/lessons/09-reading-server-manifests/docs/en.md) — A server's discover result, its tool list, and its registry entry are the only things you know about it before you call anything, so read them the way you read a contract, becau… - [The Model Interaction Flow](https://aiengineeringfromscratch.com/lesson?path=certifications%2Fmcpa%2Flessons%2F10-model-interaction-flow) · [raw](https://raw.githubusercontent.com/rohitg00/ai-engineering-from-scratch/main/certifications/mcpa/lessons/10-model-interaction-flow/docs/en.md) — A tool call is not one message on the wire. It is a loop the host runs between a user, a model, and a server, and every turn of that loop decides what the model gets to see next. - [The Tools Primitive: Calling Actions and Reading Their Results](https://aiengineeringfromscratch.com/lesson?path=certifications%2Fmcpa%2Flessons%2F11-the-tools-primitive) · [raw](https://raw.githubusercontent.com/rohitg00/ai-engineering-from-scratch/main/certifications/mcpa/lessons/11-the-tools-primitive/docs/en.md) — A tool call is a request like any other. What earns it its own lesson is everything the result can carry back: plain text, an image, audio, a link to a resource, or a resource e… - [Resources: Addressable Content for a Stateless Server](https://aiengineeringfromscratch.com/lesson?path=certifications%2Fmcpa%2Flessons%2F12-the-resources-primitive) · [raw](https://raw.githubusercontent.com/rohitg00/ai-engineering-from-scratch/main/certifications/mcpa/lessons/12-the-resources-primitive/docs/en.md) — A tool answers a question by doing something. A resource answers it by being something the host can already point the model at, addressed by a URI instead of invoked by a name. - [Prompt Templates and Argument Completion](https://aiengineeringfromscratch.com/lesson?path=certifications%2Fmcpa%2Flessons%2F13-prompts-and-completion) · [raw](https://raw.githubusercontent.com/rohitg00/ai-engineering-from-scratch/main/certifications/mcpa/lessons/13-prompts-and-completion/docs/en.md) — A prompt is a template the server writes and the user chooses to run. Nothing about it should surprise the person who picked it. - [Multi Round-Trip Requests and Elicitation](https://aiengineeringfromscratch.com/lesson?path=certifications%2Fmcpa%2Flessons%2F14-multi-round-trip-requests-and-elicitation) · [raw](https://raw.githubusercontent.com/rohitg00/ai-engineering-from-scratch/main/certifications/mcpa/lessons/14-multi-round-trip-requests-and-elicitation/docs/en.md) — A server that needs the user's confirmation mid call does not hold a connection open and wait. It ends the call, hands the client a receipt, and lets a brand new request pick up… - [Deprecated, Not Removed: Roots, Sampling, and Logging](https://aiengineeringfromscratch.com/lesson?path=certifications%2Fmcpa%2Flessons%2F15-deprecated-client-features) · [raw](https://raw.githubusercontent.com/rohitg00/ai-engineering-from-scratch/main/certifications/mcpa/lessons/15-deprecated-client-features/docs/en.md) — Deprecated in MCP 2026-07-28 does not mean gone: roots, sampling, and logging still answer exactly as before, and only a twelve month clock has started. - [The Subscription Stream: Notifications, Progress, and Cancellation](https://aiengineeringfromscratch.com/lesson?path=certifications%2Fmcpa%2Flessons%2F16-notifications-and-subscriptions) · [raw](https://raw.githubusercontent.com/rohitg00/ai-engineering-from-scratch/main/certifications/mcpa/lessons/16-notifications-and-subscriptions/docs/en.md) — A notification never gets a reply, so it has to say on its own which conversation it belongs to: the long-lived stream that opened it, or the one request that is still waiting o… - [The Tool Invocation Lifecycle](https://aiengineeringfromscratch.com/lesson?path=certifications%2Fmcpa%2Flessons%2F17-tool-invocation-lifecycle) · [raw](https://raw.githubusercontent.com/rohitg00/ai-engineering-from-scratch/main/certifications/mcpa/lessons/17-tool-invocation-lifecycle/docs/en.md) — A tool call is not one event. It is a fixed sequence of checkpoints, and exactly where a call stops tells you which of two error channels applies and what a caller should do next. - [Two Ways for a Request to Fail](https://aiengineeringfromscratch.com/lesson?path=certifications%2Fmcpa%2Flessons%2F18-error-handling) · [raw](https://raw.githubusercontent.com/rohitg00/ai-engineering-from-scratch/main/certifications/mcpa/lessons/18-error-handling/docs/en.md) — A failed request does not get to invent its own vocabulary. MCP 2026-07-28 fixes a small set of numbers, splits every failure into one of two channels, and puts a firm list of n… - [Transports and the HTTP Header Contract](https://aiengineeringfromscratch.com/lesson?path=certifications%2Fmcpa%2Flessons%2F19-transports-and-http-headers) · [raw](https://raw.githubusercontent.com/rohitg00/ai-engineering-from-scratch/main/certifications/mcpa/lessons/19-transports-and-http-headers/docs/en.md) — A transport does not change what a message means, only how it travels: stdio hands a JSON-RPC line to a subprocess, and Streamable HTTP posts one message at a time while mirrori… - [Cache Freshness and Cursor-Based Pagination](https://aiengineeringfromscratch.com/lesson?path=certifications%2Fmcpa%2Flessons%2F20-caching-and-pagination) · [raw](https://raw.githubusercontent.com/rohitg00/ai-engineering-from-scratch/main/certifications/mcpa/lessons/20-caching-and-pagination/docs/en.md) — A cacheable result tells a client exactly how long to trust it and who else may reuse the copy; a paginated one hands back an opaque bookmark, never a page number. - [Long-Running Work and the Tasks Extension](https://aiengineeringfromscratch.com/lesson?path=certifications%2Fmcpa%2Flessons%2F21-long-running-work-and-tasks) · [raw](https://raw.githubusercontent.com/rohitg00/ai-engineering-from-scratch/main/certifications/mcpa/lessons/21-long-running-work-and-tasks/docs/en.md) — Blocking a connection until minutes or hours of work finish gives up everything statelessness bought: any replica can no longer answer, and a dropped connection loses the job. T… - [Trust Zones in an MCP Exchange](https://aiengineeringfromscratch.com/lesson?path=certifications%2Fmcpa%2Flessons%2F22-trust-boundaries) · [raw](https://raw.githubusercontent.com/rohitg00/ai-engineering-from-scratch/main/certifications/mcpa/lessons/22-trust-boundaries/docs/en.md) — A tool result is data the server chose to send, not a message the host already trusted. Draw the zones before you draw the arrows. - [Authorizing Access to an MCP Server](https://aiengineeringfromscratch.com/lesson?path=certifications%2Fmcpa%2Flessons%2F23-oauth-authorization) · [raw](https://raw.githubusercontent.com/rohitg00/ai-engineering-from-scratch/main/certifications/mcpa/lessons/23-oauth-authorization/docs/en.md) — A bearer token proves the client was issued credentials for this server, not that the server should trust everything the token's holder asks for, so the protocol makes the clien… - [Proving a Client's Identity to an Authorization Server](https://aiengineeringfromscratch.com/lesson?path=certifications%2Fmcpa%2Flessons%2F24-client-registration-and-identity) · [raw](https://raw.githubusercontent.com/rohitg00/ai-engineering-from-scratch/main/certifications/mcpa/lessons/24-client-registration-and-identity/docs/en.md) — An MCP client and the authorization server guarding a new server have usually never met, so before anything is authorized, the authorization server first has to decide whether i… - [Consent and Least Privilege](https://aiengineeringfromscratch.com/lesson?path=certifications%2Fmcpa%2Flessons%2F25-consent-and-least-privilege) · [raw](https://raw.githubusercontent.com/rohitg00/ai-engineering-from-scratch/main/certifications/mcpa/lessons/25-consent-and-least-privilege/docs/en.md) — A tool call that changes something in the world should not run just because a model decided to call it. It should run because a human said yes to that specific call, and the cli… - [Risk and Safety Controls for MCP Tool Calls](https://aiengineeringfromscratch.com/lesson?path=certifications%2Fmcpa%2Flessons%2F26-risk-and-safety-controls) · [raw](https://raw.githubusercontent.com/rohitg00/ai-engineering-from-scratch/main/certifications/mcpa/lessons/26-risk-and-safety-controls/docs/en.md) — A tool description is not documentation the model happens to see. It is a string the model reads as instructions, which makes it the cheapest place to attack a system that other… - [One Trace ID Ties Auditability to Observability](https://aiengineeringfromscratch.com/lesson?path=certifications%2Fmcpa%2Flessons%2F27-auditability-and-observability) · [raw](https://raw.githubusercontent.com/rohitg00/ai-engineering-from-scratch/main/certifications/mcpa/lessons/27-auditability-and-observability/docs/en.md) — A trace id is the one value that follows a single call through a client, a server, and whatever that server calls next, and a hash chain is what lets you prove, months later, th… - [Every MUST Needs an Owner](https://aiengineeringfromscratch.com/lesson?path=certifications%2Fmcpa%2Flessons%2F28-roles-and-adoption) · [raw](https://raw.githubusercontent.com/rohitg00/ai-engineering-from-scratch/main/certifications/mcpa/lessons/28-roles-and-adoption/docs/en.md) — The specification hands its MUSTs to a host, a client, and a server. A live deployment hands them to people, and the MUST nobody agreed to own is the one that fails first. - [Choosing MCP's Shape for the Job](https://aiengineeringfromscratch.com/lesson?path=certifications%2Fmcpa%2Flessons%2F29-operational-use-cases) · [raw](https://raw.githubusercontent.com/rohitg00/ai-engineering-from-scratch/main/certifications/mcpa/lessons/29-operational-use-cases/docs/en.md) — Four questions, who initiates the call, how sensitive the data is, how long the work runs, and whether a human needs to see it, turn a vague request into a specific choice of pr… - [The Extensions Framework](https://aiengineeringfromscratch.com/lesson?path=certifications%2Fmcpa%2Flessons%2F30-the-extensions-framework) · [raw](https://raw.githubusercontent.com/rohitg00/ai-engineering-from-scratch/main/certifications/mcpa/lessons/30-the-extensions-framework/docs/en.md) — An extension is a capability neither side has to support: named with a mandatory vendor prefix, declared fresh in the metadata of every request, and safe to ignore, so the core … - [Interactive Interfaces Inside the Conversation](https://aiengineeringfromscratch.com/lesson?path=certifications%2Fmcpa%2Flessons%2F31-mcp-apps) · [raw](https://raw.githubusercontent.com/rohitg00/ai-engineering-from-scratch/main/certifications/mcpa/lessons/31-mcp-apps/docs/en.md) — A tool result does not have to stop at text: a server can point at a small HTML interface and let the host render it, sandboxed, right where the conversation is already happening. - [Finding, Routing To, and Trusting a Server](https://aiengineeringfromscratch.com/lesson?path=certifications%2Fmcpa%2Flessons%2F32-registry-gateways-and-sdk-tiers) · [raw](https://raw.githubusercontent.com/rohitg00/ai-engineering-from-scratch/main/certifications/mcpa/lessons/32-registry-gateways-and-sdk-tiers/docs/en.md) — A name in the registry is a claim about who published a server, not a guarantee about what it does. A gateway decides whether a request may reach that server at all. An SDK's ti… - [Reading One MCP Exchange End to End](https://aiengineeringfromscratch.com/lesson?path=certifications%2Fmcpa%2Flessons%2F33-mcpa-capstone-readiness) · [raw](https://raw.githubusercontent.com/rohitg00/ai-engineering-from-scratch/main/certifications/mcpa/lessons/33-mcpa-capstone-readiness/docs/en.md) — A production incident does not announce which MCPA domain it belongs to. It hands you a transcript, and reading that transcript correctly, stage by stage, is the whole skill thi…