How the Build It / Use It Lesson Methodology Works in AI Engineering
The Build It / Use It lesson methodology alternates between implementing algorithms from first principles using only standard libraries and reproducing the same functionality with production‑grade frameworks to ensure deep conceptual understanding alongside practical engineering skills.
The rohitg00/ai-engineering-from-scratch repository structures every lesson around a six‑beat curriculum where the third beat—Build It / Use It—serves as the pedagogical spine. This approach forces learners to construct core AI primitives by hand before touching high‑level abstractions, bridging the gap between mathematical theory and production code.
The Six‑Beat Structure and the Build It / Use It Split
According to the repository's README.md at line 99, the curriculum is organized into a six‑beat lesson structure, with the Build It / Use It split forming the central pillar of every module. This bifurcation ensures that students never encounter a black‑box library without first witnessing the underlying mechanics.
Build It – Implementing From First Principles
The Build It phase requires learners to implement core algorithms using only the language’s standard library or a minimal set of approved dependencies. This constraint eliminates abstraction leakage and forces engagement with every mathematical detail.
Constraints and Goals
Learners write algorithms such as vector‑matrix multiplication or the softmax function in pure Python without NumPy. This hands‑on construction reveals tensor operations, numerical stability concerns, and algorithmic complexity that libraries normally hide.
Concrete Example – Hand‑Crafted Linear Layer
Below is the canonical Build It implementation of a linear layer, using only Python built‑ins:
# hand‑crafted linear layer (no external deps)
def linear(x, w, b):
# x: (batch, in_dim), w: (in_dim, out_dim), b: (out_dim,)
return [sum(xi * wi for xi, wi in zip(row, col)) + bi
for row, col, bi in zip(x, zip(*w), b)]
This implementation manually handles the batch dimension, matrix multiplication via nested list comprehensions, and bias addition—demonstrating exactly how y = xW + b executes at the scalar level.
Use It – Validating Against Production Libraries
Once the hand‑coded version passes basic tests, the Use It phase introduces the production‑grade equivalent. The learner replaces their custom code with mature frameworks like PyTorch or NumPy, verifying behavioral parity to ensure the manual implementation is mathematically correct.
Verification and Integration
The following code swaps the custom linear function for torch.nn.Linear and asserts numerical equivalence:
import torch
linear_lib = torch.nn.Linear(in_features=3, out_features=2, bias=True)
# verify that both behave identically on a sample input
x = torch.randn(5, 3)
assert torch.allclose(
torch.tensor(linear(x.tolist(), linear_lib.weight.detach().numpy().T,
linear_lib.bias.detach().numpy())),
linear_lib(x)
)
This assertion confirms that the hand‑rolled matrix multiplication matches PyTorch’s optimized C++ kernels, validating the learner's understanding while teaching the library’s API.
Why This Methodology Works
Alternating between building and using achieves two distinct educational outcomes:
- Deep Understanding – Students witness every floating‑point operation and gradient flow before a framework abstracts them away.
- Practical Skill – They gain confidence integrating production tools because they have already debugged the underlying mechanics themselves.
By proving the concept manually first, learners can mentally map high‑level API calls to low‑level tensor manipulations, making them more effective at debugging and optimizing production models.
Where This Pattern Appears in the Curriculum
The AGENTS.md file at line 11 reinforces that the Build It / Use It split is the spine of the curriculum, appearing in every lesson's documentation. Each module's docs/en.md file contains explicit ## Build It and ## Use It sections—for example, in phases/14-agent-engineering/35-initialization-scripts/docs/en.md—detailing the hand‑coded implementation followed by the library integration.
This pattern repeats across complex components including tokenizers, attention mechanisms, and back‑propagation loops. Sample code files under phases/*/*/code/ directories contain the corresponding main.py implementations that embody this dual‑phase approach.
Summary
- The Build It / Use It methodology is the third beat of a six‑beat lesson structure defined in
README.md. - Build It phases restrict learners to standard libraries to teach first‑principles implementation.
- Use It phases introduce production frameworks like PyTorch and verify equivalence against hand‑coded versions.
- Every lesson's
docs/en.mdexplicitly separates these phases, creating a consistent pedagogical rhythm throughout the repository. - This approach ensures learners understand the mathematics behind AI primitives before relying on optimized black‑box libraries.
Frequently Asked Questions
What is the Build It / Use It lesson methodology?
The Build It / Use It lesson methodology is a pedagogical pattern where learners first implement an algorithm manually using only basic language features (Build It), then reproduce the functionality using production libraries like PyTorch or NumPy (Use It). This dual‑phase approach is the central spine of the rohitg00/ai-engineering-from-scratch curriculum, appearing as the third beat in every lesson's six‑beat structure.
Why does the curriculum prohibit external libraries in the Build It phase?
Restricting the Build It phase to standard libraries forces students to engage with the underlying mathematics, data structures, and numerical stability concerns that high‑level frameworks abstract away. By writing vector operations as nested list comprehensions or manual loops, learners internalize tensor shapes, broadcasting rules, and algorithmic complexity before these details are hidden behind APIs like torch.nn.Linear.
How does the Use It phase verify the hand‑coded implementation?
The Use It phase employs numerical assertions—typically using torch.allclose() or equivalent methods—to compare the outputs of the hand‑coded function against the production library's implementation. As shown in the linear layer example, the learner feeds identical inputs to both versions and asserts that the results match within floating‑point tolerance, confirming the manual implementation is mathematically correct.
Where can I find examples of this methodology in the repository?
Concrete examples appear in every lesson's docs/en.md file—such as phases/14-agent-engineering/35-initialization-scripts/docs/en.md—which contains explicit ## Build It and ## Use It sections. Additionally, the AGENTS.md file documents the overarching philosophy, while executable sample code resides in phases/*/*/code/ directories, typically in files named main.py that demonstrate both the pure‑Python and library‑based implementations for topics like tokenizers and attention mechanisms.
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 →