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

> Master AI engineering from scratch with the Build It Use It methodology. Learn by implementing AI algorithms using raw math before using production libraries.

- Repository: [Rohit Ghumare/ai-engineering-from-scratch](https://github.com/rohitg00/ai-engineering-from-scratch)
- Tags: how-to-guide
- Published: 2026-06-14

---

**The Build It / Use It methodology is a six-beat learning loop that forces learners to implement AI algorithms from scratch using raw mathematics before re-implementing them with production-grade libraries.**

The `rohitg00/ai-engineering-from-scratch` repository structures every lesson around this pedagogical spine, ensuring students understand underlying mechanics before abstracting them away. According to the repository's [README.md](https://github.com/rohitg00/ai-engineering-from-scratch/blob/main/README.md#L99-L101), this split forms the core of the curriculum, creating a repeatable pattern that transforms theoretical knowledge into concrete engineering artifacts.

## The Six-Beat Learning Loop

The curriculum organizes content into a continuous cycle defined in lines 99‑101 of the [README](https://github.com/rohitg00/ai-engineering-from-scratch/blob/main/README.md#L99-L101). This loop consists of three distinct phases:

- **Build It** – Students write algorithms using only fundamental mathematics and minimal language features, eliminating black-box abstractions.
- **Use It** – The same algorithm is reconstructed using optimized libraries like PyTorch or scikit-learn, revealing the relationship between theory and implementation.
- **Ship It** – The lesson culminates in a reusable artifact (prompts, skills, agents, or MCP servers) suitable for production pipelines.

The flow is visualized in a mermaid diagram at lines 100‑110 of the README. Every lesson follows this pattern, with explicit `## Build It` and `## Use It` section headings in the documentation, as seen in the **End-to-End Safety Gate** lesson at [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).

## Build It: Implementing From First Principles

In the **Build It** phase, learners implement algorithms using pure NumPy, plain Python loops, or handcrafted tensor operations. This approach forces deep understanding by requiring the explicit coding of every mathematical component.

Consider the **Linear Model** lesson from phase 10. The `build_it/` subfolder contains a manual least-squares regression implementation that follows the exact mathematical formula for the ordinary least-squares estimator:

```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

```

This code contains no hidden optimizations. The learner must understand matrix transposition, inversion, and the normal equation to make it work. The file resides at `phases/10-llms-from-scratch/01-linear-model/code/build_it/` (referenced in the lesson's [main.py](https://github.com/rohitg00/ai-engineering-from-scratch/blob/main/phases/10-llms-from-scratch/01-linear-model/code/main.py)).

## Use It: Production-Grade Libraries

The **Use It** phase re-implements the identical algorithm using production-grade libraries. By swapping the handcrafted version for optimized counterparts, learners can compare numerical stability, performance characteristics, and API design while verifying that the library matches their manual implementation.

Using the same linear regression example, the `use_it/` subfolder contains the PyTorch implementation:

```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()

```

The library handles weight initialization, automatic differentiation, and iterative optimization. Learners can inspect `model.weight` and compare it directly to `w_hat` from the **Build It** phase, validating that both approaches converge to similar solutions.

## Ship It: Creating Reusable Artifacts

The final phase produces tangible outputs stored in `outputs/` directories. These artifacts—ranging from saved model weights to configuration files—demonstrate how to transition from educational code to production-ready components.

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

```

This file can be loaded by other lessons or external projects, completing the transition from theoretical understanding to practical utility.

## File Structure and Lesson Organization

The repository enforces this methodology through strict directory conventions. Each lesson contains:

1. **`build_it/`** – Raw mathematical implementations (e.g., `phases/10-llms-from-scratch/01-linear-model/code/build_it/`)
2. **`use_it/`** – Library-based versions using PyTorch, TensorFlow, or scikit-learn (e.g., `phases/10-llms-from-scratch/01-linear-model/code/use_it/`)
3. **`outputs/`** – **Ship It** artifacts like `linear_model.pt` ready for downstream consumption

The [AGENTS.md](https://github.com/rohitg00/ai-engineering-from-scratch/blob/main/AGENTS.md) file reiterates these conventions for contributors, ensuring AI agents and human authors maintain consistency across the curriculum.

## Summary

- The **Build It / Use It** methodology forms the pedagogical spine of the `ai-engineering-from-scratch` repository, defined in the README's six-beat learning loop.
- **Build It** requires implementation from first principles using NumPy or pure Python, eliminating abstraction layers.
- **Use It** reconstructs the solution with production libraries like PyTorch, enabling direct comparison between manual and optimized implementations.
- **Ship It** produces reusable artifacts in `outputs/` directories, bridging the gap between learning and production engineering.
- Every lesson follows explicit directory structures (`build_it/`, `use_it/`, `outputs/`) and documentation headings (`## Build It`, `## Use It`).

## Frequently Asked Questions

### What is the Build It / Use It methodology?

The **Build It / Use It** methodology is a two-stage learning pattern where students first implement AI algorithms from scratch using raw mathematics (**Build It**), then re-implement them using production-grade libraries (**Use It**). This approach ensures deep understanding of underlying mechanics before abstraction. According to the repository's [README.md](https://github.com/rohitg00/ai-engineering-from-scratch/blob/main/README.md#L99-L101), this split forms the "spine" of every lesson.

### How does the Ship It phase work?

**Ship It** is the final phase where lessons produce reusable artifacts such as saved model weights, prompts, skills, agents, or MCP servers. These outputs are stored in `outputs/` directories (e.g., `linear_model.pt`) and can be imported into downstream projects or subsequent lessons, demonstrating the transition from educational code to production engineering.

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

Concrete examples appear in multiple locations: the **Linear Model** lesson at [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) contains both implementations, while the **End-to-End Safety Gate** capstone at [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) shows the explicit `## Build It` and `## Use It` documentation sections.

### What libraries are typically used in the Use It phase?

The **Use It** phase primarily employs **PyTorch**, **TensorFlow**, and **scikit-learn** for machine learning algorithms, though specific lessons may use additional domain-specific libraries. The methodology focuses on comparing these optimized implementations against the raw NumPy or pure Python versions created in the **Build It** phase to highlight performance differences and API design patterns.