How the Build It / Use It Pedagogical Approach Works in the ai-engineering-from-scratch Curriculum

The Build It / Use It approach splits every lesson into two phases: first, you implement an algorithm from raw mathematics without external frameworks, then you re-implement it using production-grade libraries like PyTorch or scikit-learn, turning opaque API calls into transparent operations.

The Build It / Use It pedagogical approach forms the instructional spine of the rohitg00/ai-engineering-from-scratch repository, which organizes 503 lessons across 20 phases. According to the repository's documentation in README.md (lines 99-101) and AGENTS.md (line 11), this six-beat lesson flow ensures learners understand the underlying mathematics of every algorithm before wrapping it in a high-level library abstraction.

The Six-Beat Lesson Architecture

Each lesson in the curriculum follows a rigid six-beat structure designed to eliminate the "magical API" trap. The beats progress from conceptual understanding to practical implementation, with the Build It / Use It split occurring at beats four and five.

MOTTO, PROBLEM, and CONCEPT

Every lesson opens with a one-line MOTTO capturing the core idea, followed by a concrete PROBLEM statement that defines the pain point the algorithm solves. The CONCEPT section provides intuition and diagrams to explain the mathematical foundations before any code appears.

BUILD IT: Implementation from Raw Mathematics

The BUILD IT phase requires learners to re-implement the algorithm from first principles using only raw NumPy or pure Python—no external ML frameworks allowed. In phases/02-ml-fundamentals/02-linear-regression/, this means writing manual gradient descent by deriving gradients directly from the loss function.

import numpy as np

def gradient_descent(X, y, lr=0.01, epochs=1000):
    # Initialise weights randomly

    w = np.random.randn(X.shape[1])
    b = 0.0
    N = len(y)

    for _ in range(epochs):
        # Predict and compute error

        y_pred = X @ w + b
        error = y_pred - y

        # Compute gradients

        dw = (2 / N) * X.T @ error
        db = (2 / N) * np.sum(error)

        # Update parameters

        w -= lr * dw
        b -= lr * db

    return w, b

This implementation explicitly calculates the gradients dw and db from the loss function L = (1/N) Σ (ŷ − y)², ensuring the learner understands how each parameter update affects the model.

USE IT: Production-Grade Library Implementation

Immediately following the manual implementation, the USE IT phase re-implements the identical algorithm using production libraries like scikit-learn, PyTorch, or JAX. Because the learner has already coded the underlying mathematics, the library call becomes a transparent wrapper rather than a black box.

from sklearn.linear_model import LinearRegression

def sklearn_regression(X, y):
    model = LinearRegression()
    model.fit(X, y)
    return model.coef_, model.intercept_

The learner can now compare the manually computed weights against model.coef_ and model.intercept_, verifying that the library performs the same operations they just coded by hand.

SHIP IT: Reusable Artifacts

The final beat produces a concrete artifact—a prompt, skill, agent, or MCP server—that can be dropped into real workflows. For example, phases/02-ml-fundamentals/02-linear-regression/outputs/skill-regression.md contains the final SHIP IT deliverable ready for production use.

Linear Regression Example: Build It vs. Use It

The linear regression lesson in phases/02-ml-fundamentals/02-linear-regression/ demonstrates the complete workflow. First, the learner implements gradient_descent() manually, computing gradients via matrix operations without any ML library imports. Then, they implement sklearn_regression() using scikit-learn's LinearRegression class.

To verify equivalence between the two approaches:


# Synthetic data

X = np.random.randn(100, 3)
true_w = np.array([1.5, -2.0, 0.7])
y = X @ true_w + 0.5 + np.random.randn(100) * 0.1

# Build It

w_manual, b_manual = gradient_descent(X, y)

# Use It

w_sklearn, b_sklearn = sklearn_regression(X, y)

print("Manual weights:", w_manual.round(3))
print("Sklearn weights:", w_sklearn.round(3))

Running this comparison reveals that the manually trained weights are numerically close to the scikit-learn solution, confirming functional equivalence between the low-level math and the optimized library routine.

Why the Build It / Use It Approach Works

This pedagogical strategy delivers three specific advantages for AI engineering education:

  • Deep Comprehension: By coding gradients and matrix operations manually in the BUILD IT phase, learners see exactly how each term in the loss function contributes to parameter updates, bypassing the abstraction trap of high-level APIs.

  • Confidence with Libraries: The USE IT phase transforms frameworks from magical black boxes into transparent wrappers. When calling model.fit(), the learner understands the underlying gradient descent steps because they implemented them explicitly in the previous beat.

  • Immediate Applicability: The SHIP IT requirement ensures every lesson emits a concrete artifact, reinforcing the curriculum's learning-by-doing ethos and providing reusable tools for real-world AI workflows.

Key Source Files and Implementation Structure

The following files define and implement the Build It / Use It flow throughout the curriculum:

Summary

The Build It / Use It pedagogical approach in rohitg00/ai-engineering-from-scratch creates a structured six-beat learning cycle that eliminates API opacity. Key takeaways include:

  • Every lesson requires manual implementation from raw mathematics (BUILD IT) before allowing library abstractions (USE IT).
  • The curriculum spans 503 lessons and 20 phases, maintaining consistent structure across all content.
  • Learners validate their manual implementations by comparing outputs against scikit-learn, PyTorch, and JAX equivalents.
  • Each lesson concludes with a SHIP IT artifact that converts theoretical knowledge into reusable production tools.
  • Source documentation in README.md and AGENTS.md explicitly mandates this two-phase approach as the curriculum's core spine.

Frequently Asked Questions

What is the difference between the Build It and Use It phases?

The BUILD IT phase requires implementing algorithms using only NumPy or pure Python, calculating gradients and updates from first principles without external ML libraries. The USE IT phase re-implements the same algorithm using production frameworks like scikit-learn or PyTorch, allowing learners to recognize that high-level API calls execute the same mathematics they coded manually.

Why implement algorithms from scratch before using libraries?

According to the curriculum designers in AGENTS.md, implementing from scratch ensures you "understand what the framework is doing because you wrote the smaller version yourself." This prevents the "magical API" trap where learners treat library functions as opaque black boxes rather than mathematical operations.

What is the SHIP IT phase?

The SHIP IT beat is the sixth and final phase of every lesson, requiring the creation of a reusable artifact—such as a prompt, skill, agent, or MCP server—that can be immediately deployed into real AI engineering workflows. For example, the linear regression lesson emits skill-regression.md as its final deliverable.

How many lessons use this pedagogical approach?

The Build It / Use It split appears in all 503 lessons across the repository's 20 phases, ensuring a uniform learning experience from basic linear regression through advanced transformer architectures.

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 →