How the Build It / Use It Teaching Method Structures the AI Engineering from Scratch Curriculum

The AI Engineering from Scratch curriculum employs a six-beat lesson flow—MOTTO, PROBLEM, CONCEPT, BUILD IT, USE IT, and SHIP IT—that requires learners to hand-code algorithms from mathematical first principles before re-implementing them with production frameworks like PyTorch, creating explicit cognitive bridges between theory and practice.

The rohitg00/ai-engineering-from-scratch repository organizes its entire educational content around the Build It / Use It teaching method, a dual-phase approach documented in AGENTS.md that splits every lesson into raw-math and framework implementations. This structure appears consistently across all 435 lessons in the 20-phase curriculum, ensuring that learners internalize algorithmic mechanics before encountering the abstraction layers of modern AI libraries.

The Six-Beat Lesson Flow

Every lesson follows a rigid narrative spine defined in README.md (lines 20-31) and enforced by AGENTS.md. The Build It / Use It split forms the core pedagogical mechanism within a six-beat progression:

Beat Function Role in Build It / Use It
MOTTO One-line narrative hook Establishes context for both the handcrafted and library-based implementations
PROBLEM Concrete task or pain point Frames the why behind re-implementing the algorithm from first principles
CONCEPT Diagrams, intuition, and math Provides the theoretical foundation that the Build It code will follow
BUILD IT Raw-math implementation Learners write the algorithm using only standard library or minimal dependencies like numpy
USE IT Framework implementation The same logic expressed with production-grade libraries (torch, sklearn, etc.)
SHIP IT Artifact generation Produces a deployable prompt, skill, or agent that demonstrates real-world application

Directory Structure and File Layout

The repository’s physical layout mirrors this pedagogical flow. Each lesson resides at phases/<NN>-<phase-name>/<NN>-<lesson-name>/ and contains:


.
├── docs/en.md          # Narrative containing the six beats (MOTTO → SHIP IT)

├── code/
│   ├── main.py         # Contains both Build-It (pure math) and Use-It (framework) versions

│   └── tests/          # Deterministic tests exercising both implementations

└── outputs/            # Final artifact produced by the SHIP-IT step

For example, phases/07-transformers-deep-dive/04-positional-encoding/ contains docs/en.md for theory, code/main.py for dual implementations, and outputs/skill-positional-encoding.md for the shipped artifact.

Build It Phase: Raw Mathematical Implementations

The Build It phase demands a "nothing but the standard library" approach. Learners implement algorithms using pure Python and minimal dependencies like numpy, forcing explicit engagement with every mathematical operation.

In phases/10-llms-from-scratch/01-tokenizers/code/main.py, a linear regression lesson demonstrates this raw-math approach:

import numpy as np

def train_linear_regression(X, y, lr=0.01, epochs=1000):
    # Initialise weights (including bias)

    w = np.zeros(X.shape[1] + 1)  # extra slot for bias

    # Add bias term to X

    Xb = np.column_stack([np.ones(len(X)), X])

    for _ in range(epochs):
        # Predict, compute error, and take a gradient step

        preds = Xb @ w
        grad = Xb.T @ (preds - y) / len(y)
        w -= lr * grad
    return w

Similarly, a transformer block in phases/07-transformers-deep-dive/04-positional-encoding/code/main.py implements scaled dot-product attention from scratch:

import numpy as np

def scaled_dot_product_attention(Q, K, V):
    d_k = Q.shape[-1]
    scores = Q @ K.T / np.sqrt(d_k)
    attn = np.exp(scores) / np.exp(scores).sum(axis=-1, keepdims=True)
    return attn @ V

def transformer_block(X, W_q, W_k, W_v, W_o):
    Q = X @ W_q
    K = X @ W_k
    V = X @ W_v
    context = scaled_dot_product_attention(Q, K, V)
    return context @ W_o

Use It Phase: Production Framework Implementations

The Use It phase immediately follows, reproducing the identical logic with optimized, production-grade frameworks. This demonstrates the exact mapping between hand-crafted mathematics and library abstractions.

The linear regression example transforms into PyTorch in the same main.py file:

import torch
from torch import nn

def train_linear_regression_torch(X, y, lr=0.01, epochs=1000):
    X_t = torch.from_numpy(X).float()
    y_t = torch.from_numpy(y).float().unsqueeze(1)

    model = nn.Linear(X.shape[1], 1)   # framework‑provided linear layer

    optimizer = torch.optim.SGD(model.parameters(), lr=lr)
    loss_fn = nn.MSELoss()

    for _ in range(epochs):
        optimizer.zero_grad()
        preds = model(X_t)
        loss = loss_fn(preds, y_t)
        loss.backward()
        optimizer.step()
    return model

The corresponding transformer implementation leverages torch.nn.functional:

import torch
import torch.nn.functional as F

def transformer_block_torch(X, W_q, W_k, W_v, W_o):
    Q = X @ W_q
    K = X @ W_k
    V = X @ W_v
    attn = F.scaled_dot_product_attention(Q, K, V, attn_mask=None, dropout_p=0.0)
    return attn @ W_o

The test suite in phases/07-transformers-deep-dive/04-positional-encoding/code/tests/test_main.py guarantees numerical parity between the handcrafted and library versions.

The Ship It Phase and Artifact Generation

The SHIP IT beat closes the learning loop by forcing practical application. Learners generate a concrete artifact—such as a prompt template, MCP server, or skill definition—that can be plugged into downstream workflows.

In the positional encoding lesson, this produces phases/07-transformers-deep-dive/04-positional-encoding/outputs/skill-positional-encoding.md, a reusable asset that demonstrates mastery while providing utility for future projects.

Why the Build It / Use It Method Works

This dual-phase approach delivers three distinct pedagogical advantages:

  • Cognitive anchoring – By constructing algorithms from scratch using only numpy operations, learners develop an intuitive mental model of every tensor transformation before those operations are hidden behind framework APIs.
  • Abstraction bridging – The immediate juxtaposition of Xb @ w against nn.Linear() makes the connection between theory and production tools explicit, demystifying libraries that would otherwise appear as black boxes.
  • Artifact-centric retention – The Ship It requirement converts abstract knowledge into a concrete, version-controlled output, reinforcing retention through creation rather than consumption.

Summary

  • The Build It / Use It teaching method structures all 435 lessons in rohitg00/ai-engineering-from-scratch around a six-beat flow: MOTTO, PROBLEM, CONCEPT, BUILD IT, USE IT, and SHIP IT.
  • Build It implementations use only standard libraries and numpy to force understanding of mathematical primitives.
  • Use It implementations reproduce the identical logic using production frameworks like PyTorch, creating explicit mappings between theory and practice.
  • Each lesson directory contains docs/en.md for narrative, code/main.py for dual implementations, code/tests/ for parity verification, and outputs/ for deployable artifacts.
  • The Ship It phase ensures learners convert theoretical knowledge into reusable prompts, agents, or skills.

Frequently Asked Questions

What exactly is the Build It / Use It teaching method?

The Build It / Use It teaching method is a bifurcated learning approach where learners first implement an algorithm using only fundamental mathematical operations and minimal dependencies (Build It), then immediately re-implement the same logic using production frameworks like PyTorch or scikit-learn (Use It). This dual exposure ensures deep understanding of underlying mechanics before learners encounter the abstractions of modern AI libraries.

How does the six-beat flow reinforce learning?

The six-beat flow (MOTTO, PROBLEM, CONCEPT, BUILD IT, USE IT, SHIP IT) creates a narrative arc that moves from motivation to hands-on construction to practical deployment. By requiring learners to Build It from scratch before using high-level APIs, the curriculum prevents "API blindness" where developers call functions without understanding the mathematics. The final Ship It beat forces application of the knowledge, cementing retention through creation.

What types of artifacts does the Ship It phase produce?

The Ship It phase generates version-controlled artifacts in the lesson’s outputs/ directory, including reusable prompt templates, skill definitions, MCP servers, or agent configurations. For example, the positional encoding lesson ships skill-positional-encoding.md, which learners can import directly into downstream projects, converting educational exercises into production assets.

How does the curriculum ensure parity between Build It and Use It implementations?

Each lesson includes a deterministic test suite in code/tests/test_main.py that validates both implementations against identical input-output specifications. These tests verify that the raw numpy version in the Build It section produces mathematically identical results to the PyTorch implementation in the Use It section, ensuring that learners correctly map their hand-crafted logic to framework APIs.

Have a question about this repo?

These articles cover the highlights, but your codebase questions are specific. Give your agent direct access to the source. Share this with your agent to get started:

Share the following with your agent to get started:
curl -s "https://instagit.com/install.md"

Works with
Claude Codex Cursor VS Code OpenClaw Any MCP Client

Maintain an open-source project? Get it listed too →