# Understanding the Build It / Use It Lesson Split in AI Engineering From Scratch

> Explore the Build It Use It lesson split in AI Engineering From Scratch. Learn AI from first principles then master production frameworks.

- Repository: [Rohit Ghumare/ai-engineering-from-scratch](https://github.com/rohitg00/ai-engineering-from-scratch)
- Tags: internals
- Published: 2026-09-01

---

**The "Build It / Use It" split divides every lesson into two distinct phases: first implementing core AI algorithms from first principles without external libraries, then replacing that handcrafted code with production-grade frameworks to reveal the exact interface contract between theory and practice.**

The *AI Engineering From Scratch* curriculum by `rohitg00` employs a unique dual-phase pedagogical structure that ensures learners understand both the mathematical foundations of artificial intelligence and the practical realities of shipping production code. This **Build It / Use It lesson split** runs through every module, from linear algebra foundations to complex agent loops, demanding that learners write algorithms by hand before touching modern ML libraries.

## What Is the Build It / Use It Lesson Split?

The curriculum organizes every lesson around two complementary halves that share a single public API. This structure is explicitly defined as the "spine" of the teaching methodology in the repository's documentation.

The split works as follows:

- **Build It**: Write the core algorithm from scratch in pure Python, TypeScript, Rust, or Julia. You implement back-propagation, tokenizers, attention mechanisms, or agent loops **without importing external libraries** until the final verification step.

- **Use It**: Replace the low-level implementation with a call to a standard, battle-tested library such as `torch`, `numpy`, or a TypeScript framework. This phase demonstrates how the handcrafted logic maps to real-world APIs, turning the black-box library into a transparent tool.

According to the [`AGENTS.md`](https://github.com/rohitg00/ai-engineering-from-scratch/blob/main/AGENTS.md) file in the repository root, "Every lesson follows six beats. The *Build It / Use It* split is the spine — you implement the…" algorithmic core before integrating external dependencies. This phrasing appears consistently across the multilingual README files in `i18n/*/README.md`, confirming the split as a language-agnostic, global curriculum standard.

## The Two Phases in Detail

### Build It: First-Principles Implementation

In the **Build** phase, learners work in a constrained environment. You write classes and functions using only the standard library of your chosen language—no `import torch`, no `import numpy`. This constraint forces engagement with algorithmic details that are typically hidden.

For example, when learning linear regression, you calculate gradients manually and update weights using list comprehensions and basic arithmetic rather than matrix operations. This approach reveals how loss functions actually flow backward through computational graphs and why specific initialization strategies matter.

### Use It: Production Library Integration

The **Use** phase immediately follows successful verification of the hand-coded solution. You refactor the working code to leverage optimized libraries, but you maintain the **exact same public interface**—same method names, same signatures, same return shapes.

This continuity demonstrates the contract between algorithmic intent and library implementation. You learn precisely which hyperparameters map to which internal functions, and you understand the data shapes required to integrate the algorithm into existing pipelines. The transformation turns theoretical knowledge into reusable production skills.

## Three Educational Goals of the Split

The Build It / Use It lesson split achieves specific pedagogical outcomes that bridge the gap between academic understanding and engineering practice:

1. **Deep Insight**: Building algorithms by hand uncovers mathematical and architectural details hidden behind library abstractions. You see why backpropagation requires specific derivative chains or how attention scores normalize before the softmax.

2. **Practical Transfer**: Using the library version teaches the **interface contract**—the exact function signatures, tensor shapes, and hyperparameter names required to integrate the algorithm into real projects. You learn both *how it works* and *how to call it*.

3. **Reusable Artifacts**: Each lesson produces a self-contained script, module, or CLI tool stored in the `outputs/` directory. These artifacts can be imported directly into learner workflows, reinforcing both the handmade and library-backed implementations.

## Canonical Example: Linear Regression

The linear regression lesson in `phases/01-foundations/01-linear-algebra/code/` demonstrates this pattern perfectly. Both implementations expose identical `fit()` and `predict()` methods, allowing drop-in replacement between phases.

First, the **Build It** implementation uses pure Python:

```python

# Build It: Hand-crafted implementation (pure Python, no imports)

class LinearRegression:
    def __init__(self):
        self.w = 0.0
        self.b = 0.0

    def fit(self, xs, ys, lr=0.01, epochs=1000):
        for _ in range(epochs):
            # Compute predictions

            preds = [self.w * x + self.b for x in xs]
            # Compute gradients (mean-squared error)

            dw = sum(2 * (p - y) * x for x, p, y in zip(xs, preds, ys)) / len(xs)
            db = sum(2 * (p - y) for p, y in zip(preds, ys)) / len(xs)
            # Gradient step

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

    def predict(self, x):
        return self.w * x + self.b

```

Then, the **Use It** phase swaps in NumPy while preserving the API:

```python

# Use It: Production library implementation

import numpy as np

class LinearRegressionNP:
    def __init__(self):
        self.w = None
        self.b = None

    def fit(self, xs, ys):
        X = np.vstack([xs, np.ones_like(xs)]).T
        # Closed-form solution: (XᵀX)⁻¹Xᵀy

        self.w, self.b = np.linalg.lstsq(X, ys, rcond=None)[0]

    def predict(self, x):
        return self.w * x + self.b

```

The surrounding training scripts and test suites in `code/tests/` validate that both classes produce identical predictions within numerical precision, proving that the library version performs the same mathematical operations as the handcrafted one—just with optimized linear algebra.

## Key Source Files

The Build It / Use It split is documented and enforced through specific files in the repository:

- **[`AGENTS.md`](https://github.com/rohitg00/ai-engineering-from-scratch/blob/main/AGENTS.md)**: Defines the curriculum philosophy and explicitly names the split as the organizing principle for all lessons.
- **[`README.md`](https://github.com/rohitg00/ai-engineering-from-scratch/blob/main/README.md)**: Repeats the split description for quick onboarding of new learners.
- **`i18n/*/README.md`**: Multilingual versions confirming the global, language-agnostic nature of the pedagogical approach.
- **`phases/*/code/main.<lang>`**: Contains the Build It implementations for each topic (e.g., attention mechanisms, tokenizers, agent loops).
- **`outputs/`**: Stores the final artifacts produced after completing the Use It phase, ready for integration into production workflows.

## Summary

- The **Build It / Use It lesson split** is the central pedagogical structure of the *AI Engineering From Scratch* curriculum, dividing every lesson into implementation and integration phases.
- The **Build** phase requires writing algorithms from scratch in pure Python, TypeScript, Rust, or Julia without external libraries to expose mathematical fundamentals.
- The **Use** phase replaces hand-coded logic with production frameworks like PyTorch or NumPy while maintaining identical public APIs to teach interface contracts.
- This approach produces **reusable artifacts** stored in `outputs/` that bridge theoretical understanding and production engineering skills.
- The split is documented in [`AGENTS.md`](https://github.com/rohitg00/ai-engineering-from-scratch/blob/main/AGENTS.md) and enforced across all multilingual curriculum versions in the `rohitg00/ai-engineering-from-scratch` repository.

## Frequently Asked Questions

### Why implement algorithms from scratch if libraries already exist?

Implementing from scratch removes the abstraction layer that hides mathematical operations. When you manually calculate gradients for back-propagation or construct attention masks with nested loops, you understand *why* the algorithm works, not just *how to call it*. This knowledge becomes critical when debugging model failures or optimizing custom architectures that standard libraries do not support.

### What programming languages are supported in the Build It phase?

The curriculum supports **Python, TypeScript, Rust, and Julia** for the Build It phase. Each lesson provides parallel implementations in these languages, allowing learners to choose based on their production environment. The constraint remains constant regardless of language: no external ML libraries may be imported until the Use It phase begins.

### How does the Use It phase help with production engineering?

The Use It phase teaches the **interface contract**—the specific tensor shapes, hyperparameter names, and function signatures required to integrate the algorithm into existing codebases. By swapping your working implementation with `torch.nn` or `numpy.linalg`, you learn exactly how the high-level API maps to the low-level logic you wrote. This prevents the "API guesswork" that slows down ML engineering teams when integrating new models.

### Where can I find the lesson artifacts mentioned in the split?

Each lesson generates artifacts in the **`outputs/`** directory at the repository root. These files contain the final, tested implementations from both the Build and Use phases, formatted as importable modules or CLI tools. Additionally, the `code/` directories within each phase (e.g., `phases/01-foundations/01-linear-algebra/code/`) house the iterative implementations and test suites that verify functional parity between the handcrafted and library versions.