# How the Build It / Use It Pedagogical Approach Works in AI Engineering From Scratch

> Discover how the Build It Use It approach in AI Engineering From Scratch teaches you to implement algorithms from scratch, use libraries like PyTorch, and ship reusable artifacts. Master AI development step by step.

- Repository: [Rohit Ghumare/ai-engineering-from-scratch](https://github.com/rohitg00/ai-engineering-from-scratch)
- Tags: pedagogy
- Published: 2026-06-20

---

**The Build It / Use It pedagogical approach is a six-beat learning loop where students first implement algorithms from scratch using raw mathematics, then replicate the solution with production-grade libraries like PyTorch, and finally ship a reusable artifact.**

The rohitg00/ai-engineering-from-scratch repository employs a unique **Build It / Use It pedagogical approach** that transforms theoretical AI concepts into production-ready engineering skills. This methodology, defined in the repository's [README.md](https://github.com/rohitg00/ai-engineering-from-scratch/blob/main/README.md#L99-L101), structures every lesson around a six-beat learning loop that forces deep understanding before introducing abstraction. Each lesson follows this pattern explicitly, with dedicated sections appearing as `## Build It` and `## Use It` headings in the documentation.

## The Six-Beat Learning Loop

According to the source code, the curriculum is organized around a six-beat learning loop that centers on the **Build It / Use It** split—the "spine" of every lesson (see lines 99-101 of the [README](https://github.com/rohitg00/ai-engineering-from-scratch/blob/main/README.md#L99-L101)). This flow is visualized in the repository's mermaid diagram (lines 100-110) and consists of three core phases:

- **Build It** – Students implement an algorithm from first principles using only raw mathematics and minimal language features (e.g., pure NumPy, plain Python loops, or handcrafted tensor operations). This forces a deep understanding of underlying mechanics because the learner writes every component themselves.

- **Use It** – The same algorithm is then re-implemented with a production-grade library (such as PyTorch, TensorFlow, or scikit-learn). By swapping the hand-crafted version for the library's optimized counterpart, learners see exactly what the library is doing under the hood and can compare performance, numerical stability, and API design.

- **Ship It** – Finally, the lesson produces a reusable artifact (prompt, skill, agent, or MCP server) that can be plugged into downstream projects.

## From First Principles to Production Code

The methodology is demonstrated throughout the repository, particularly in lessons like the **End-to-End Safety Gate** (see [phases/19-capstone-projects/87-end-to-end-safety-gate/docs/en.md](https://github.com/rohitg00/ai-engineering-from-scratch/blob/main/phases/19-capstone-projects/87-end-to-end-safety-gate/docs/en.md)) and the **Linear Model** lesson (phase 10). Below is a distilled example from the Linear Model implementation showing the complete workflow.

### Build It – Manual Implementation With NumPy

In the **Build It** phase, learners implement the closed-form solution for ordinary least-squares regression using only NumPy operations. This follows the exact mathematical formula for the estimator with no hidden optimizations.

```python
import numpy as np

# raw data

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

# closed-form solution (XᵀX)⁻¹Xᵀy

w_hat = np.linalg.inv(X.T @ X) @ X.T @ y

```

*Why it works:* The code explicitly implements the mathematical formula for the ordinary least-squares estimator, forcing the student to understand matrix operations and numerical computation.

### Use It – Production Implementation With PyTorch

The **Use It** phase replaces the manual implementation with PyTorch's `nn.Linear` module, revealing how production libraries handle weight initialization, gradient computation, and optimization.

```python
import torch
import torch.nn as nn
import torch.optim as optim

model = nn.Linear(3, 1, bias=False)          # library implementation

criterion = nn.MSELoss()
optimizer = optim.SGD(model.parameters(), lr=0.01)

X_t = torch.from_numpy(X).float()
y_t = torch.from_numpy(y).float().unsqueeze(1)

for _ in range(500):
    optimizer.zero_grad()
    preds = model(X_t)
    loss = criterion(preds, y_t)
    loss.backward()
    optimizer.step()

```

*What changes:* The library takes care of weight initialization, gradient computation, and an iterative optimizer. The learner can inspect `model.weight` and compare it to `w_hat` from the hand-crafted solution, directly observing how the optimized implementation converges to the same mathematical solution.

### Ship It – Exporting Reusable Artifacts

The final phase converts the trained model into a portable artifact that other lessons or production systems can import.

```python
torch.save(model.state_dict(), "linear_model.pt")   # artifact for downstream pipelines

```

This artifact is written to the `outputs/` directory, creating a tangible product that demonstrates the transition from educational exercise to production asset.

## Repository Structure and Organization

The **Build It / Use It pedagogical approach** is woven into the physical file structure of the repository. According to the [AGENTS.md](https://github.com/rohitg00/ai-engineering-from-scratch/blob/main/AGENTS.md) contributor guidance, authors and AI agents must follow this methodology when creating new lessons.

Key organizational patterns include:

- **Documentation**: Each lesson documentation contains explicit `## Build It` and `## Use It` sections (e.g., [phases/19-capstone-projects/87-end-to-end-safety-gate/docs/en.md](https://github.com/rohitg00/ai-engineering-from-scratch/blob/main/phases/19-capstone-projects/87-end-to-end-safety-gate/docs/en.md)).

- **Source Code**: Implementation files in lesson directories (e.g., [phases/10-llms-from-scratch/01-linear-model/code/main.py](https://github.com/rohitg00/ai-engineering-from-scratch/blob/main/phases/10-llms-from-scratch/01-linear-model/code/main.py)) separate concerns into `build_it/` and `use_it/` sub-folders.

- **Artifacts**: The `outputs/` directory contains final products like `linear_model.pt`, implementing the "Ship It" phase.

## Summary

- The **Build It / Use It** approach is a six-beat learning loop that forms the pedagogical spine of rohitg00/ai-engineering-from-scratch.
- **Build It** requires implementation from first principles using raw mathematics and minimal libraries like NumPy.
- **Use It** involves re-implementing the same algorithm with production frameworks (PyTorch, TensorFlow) to understand library internals.
- **Ship It** produces reusable artifacts (models, prompts, agents) stored in `outputs/` directories.
- The methodology is enforced through explicit documentation headings and directory structures (`build_it/`, `use_it/`, `outputs/`).

## Frequently Asked Questions

### What is the Build It / Use It pedagogical approach?

The **Build It / Use It pedagogical approach** is a structured learning methodology where students first implement algorithms manually using raw mathematical operations (Build It), then re-implement them using production libraries (Use It), and finally export the result as a reusable artifact (Ship It). This approach is defined in the repository's README.md (lines 99-101) and ensures learners understand underlying mechanics before relying on abstraction.

### How does the Ship It phase differ from Use It?

While **Use It** focuses on implementing solutions with existing libraries like PyTorch, **Ship It** converts those implementations into portable, reusable artifacts. These artifacts—which include saved model weights, prompt templates, or MCP servers—are written to `outputs/` directories and designed for integration into downstream production pipelines or other lessons in the curriculum.

### Where can I find examples of this methodology in the repository?

Concrete examples appear in the **Linear Model** lesson ([phases/10-llms-from-scratch/01-linear-model/code/main.py](https://github.com/rohitg00/ai-engineering-from-scratch/blob/main/phases/10-llms-from-scratch/01-linear-model/code/main.py)) and the **End-to-End Safety Gate** capstone ([phases/19-capstone-projects/87-end-to-end-safety-gate/docs/en.md](https://github.com/rohitg00/ai-engineering-from-scratch/blob/main/phases/19-capstone-projects/87-end-to-end-safety-gate/docs/en.md)). Each contains explicit `## Build It` and `## Use It` sections with working code examples following the six-beat loop.

### Why implement algorithms from scratch before using libraries?

Implementing algorithms from scratch in the **Build It** phase forces deep understanding of the underlying mathematics and computational mechanics. When students later transition to the **Use It** phase, they can compare their manual implementation against the library's optimized version, understanding exactly what the library abstracts away—including gradient computation, numerical stability techniques, and memory optimization strategies.