How the "Build It / Use It" Pedagogical Approach Works in AI Engineering from Scratch
The AI Engineering from Scratch curriculum structures every lesson around a six-beat flow where learners first implement algorithms from raw mathematics without frameworks, then replicate the exact same logic using production-grade libraries like PyTorch, creating a transparent bridge between first-principles understanding and practical deployment.
The open-source repository rohitg00/ai-engineering-from-scratch organizes its curriculum around a deliberate cognitive scaffold called the Build It / Use It split. This methodology, described as the "spine" of every lesson in the repository's documentation, ensures that learners internalize the mathematical foundations of AI algorithms before encountering the abstractions of modern deep-learning frameworks.
The Six-Beat Lesson Architecture
Every lesson follows a rigid six-beat narrative flow: MOTTO → PROBLEM → CONCEPT → BUILD IT → USE IT → SHIP IT. The middle two beats constitute the core pedagogical innovation. According to the source documentation in README.md and reaffirmed in AGENTS.md, this split guarantees that learners encounter the same algorithm twice—first as raw code, then as a library abstraction—cementing the relationship between theory and practice.
Build It Phase: First-Principles Implementation
In the Build It phase, you implement the core algorithm using only the language’s standard library or minimal numeric dependencies like NumPy. The code lives in phases/<phase-id>/<lesson-id>/code/ and is deliberately framework-free.
This approach forces a first-principles understanding of the math and control flow. Because no black-box API hides the internals, you can trace every variable, inspect gradients manually, and debug edge cases. For example, when implementing a perceptron in Phase 3, Lesson 1, you write the forward pass, activation logic, and weight updates using only NumPy arrays and vector operations.
# phases/03-deep-learning-core/01-the-perceptron/code/perceptron_numpy.py
import numpy as np
class Perceptron:
def __init__(self, n_features):
self.w = np.zeros(n_features + 1) # bias as last weight
def predict(self, X):
Xb = np.hstack([X, np.ones((X.shape[0], 1))]) # add bias term
return np.where(Xb @ self.w > 0, 1, 0)
def fit(self, X, y, lr=0.1, epochs=10):
Xb = np.hstack([X, np.ones((X.shape[0], 1))])
for _ in range(epochs):
for xi, yi in zip(Xb, y):
if self.predict(xi[:-1].reshape(1, -1)) != yi:
self.w += lr * (yi - self.predict(xi[:-1].reshape(1, -1))) * xi
Use It Phase: Production Framework Integration
The Use It phase takes the identical algorithmic skeleton and wraps it with a target production framework such as PyTorch, JAX, or scikit-learn. The "use-it" version is placed alongside the "build-it" version in the same lesson folder, often in a separate file like model_torch.py.
By re-using the exact same mathematical logic, you observe how the library abstracts tensor handling, autograd, and optimizers. The contrast makes the library’s behavior transparent, transforming a "magic" API call into an understandable pipeline. The repository verifies alignment by running python -m unittest discover, ensuring both versions produce identical predictions on the same data.
# phases/03-deep-learning-core/01-the-perceptron/code/perceptron_torch.py
import torch
import torch.nn as nn
class PerceptronTorch(nn.Module):
def __init__(self, n_features):
super().__init__()
self.linear = nn.Linear(n_features, 1) # bias built-in
def forward(self, x):
return (self.linear(x) > 0).float()
def fit(self, X, y, lr=0.1, epochs=10):
optimizer = torch.optim.SGD(self.parameters(), lr=lr)
criterion = nn.BCEWithLogitsLoss()
X = torch.tensor(X, dtype=torch.float32)
y = torch.tensor(y, dtype=torch.float32).unsqueeze(1)
for _ in range(epochs):
optimizer.zero_grad()
logits = self.linear(X)
loss = criterion(logits, y)
loss.backward()
optimizer.step()
Ship It Phase: Exporting Reusable Artifacts
The final Ship It beat requires exporting a reusable artifact from the lesson’s outputs/ directory. This artifact might be a prompt, a skill definition, an agent configuration, or an MCP server. The concrete, runnable outcome demonstrates that the lesson produces real-world value, closing the learning loop and providing assets for downstream projects.
Pedagogical Documentation and Structure
The methodology is explicitly defined in the repository’s root documentation. The README.md file outlines the six-beat flow and identifies the Build It / Use It split as the curriculum's organizing principle. The AGENTS.md contract file reiterates this structure for agent-related lessons, ensuring pedagogical consistency across all 503 lessons.
The static site generator in site/build.js reads the markdown structure and renders the narrative flow for the web UI, preserving the Build It / Use It dichotomy in the lesson navigation.
Summary
- Six-beat flow: Every lesson follows MOTTO → PROBLEM → CONCEPT → BUILD IT → USE IT → SHIP IT.
- Framework-free first: The Build It phase requires implementing algorithms from scratch in
phases/<phase>/<lesson>/code/using only NumPy or standard libraries. - Production parity: The Use It phase duplicates the logic in PyTorch or similar frameworks, stored in paired files like
perceptron_torch.py. - Verified alignment: Unit tests confirm that both implementations produce identical results on the same data.
- Artifact export: The Ship It phase generates reusable outputs in the
outputs/directory, ranging from skills to agent configurations.
Frequently Asked Questions
What is the "Build It / Use It" pedagogical approach?
The "Build It / Use It" approach is a dual-phase teaching methodology where learners first implement an AI algorithm from mathematical first principles without frameworks, then re-implement the identical logic using production libraries like PyTorch. This repetition reinforces the mapping between raw code and high-level abstractions.
Why implement algorithms from scratch before using frameworks?
Implementing from scratch in the Build It phase eliminates the "magic" of black-box APIs. When you write the forward pass, backpropagation, or attention mechanisms manually in NumPy, you gain explicit visibility into tensor shapes, gradient flow, and parameter updates. This foundation makes debugging and optimizing production code in the Use It phase significantly more intuitive.
Which production frameworks are used in the "Use It" phase?
The curriculum primarily uses PyTorch, but also integrates JAX, scikit-learn, and other industry-standard libraries depending on the lesson's focus. Each Use It implementation is designed to mirror the exact mathematical operations of its Build It counterpart, often residing in the same lesson directory with a descriptive suffix like _torch.py.
Where are the lesson artifacts stored after the "Ship It" phase?
Shipped artifacts are stored in the phases/<phase-id>/<lesson-id>/outputs/ directory. These files contain reusable components such as prompt templates, skill definitions, or agent configurations that learners can import directly into downstream AI engineering projects.
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:
curl -s "https://instagit.com/install.md" Maintain an open-source project? Get it listed too →