How the 'Build It / Use It' Methodology Works for Learning Deep Learning Algorithms from Scratch
The "Build It / Use It" methodology teaches deep learning by first implementing algorithms from scratch using only standard libraries, then validating them against production frameworks like PyTorch to internalize the underlying mathematics while understanding production abstractions.
The ai-engineering-from-scratch curriculum by rohitg00 employs a unique "Build It / Use It" split to teach deep learning algorithms from first principles. This approach ensures learners understand the mathematical foundations before relying on high-level frameworks, creating a tight feedback loop that reinforces comprehension through implementation and comparison.
The Build It Phase: First Principles Implementation
Under this methodology, every lesson begins with Build It—writing algorithms using nothing but the language's standard library. In phases/01-math-foundations/01-linear-algebra-intuition/code/vectors.py, learners implement a Vector class that handles addition, dot products, and magnitude calculations without importing NumPy or PyTorch.
The implementation follows the lesson's "Problem → Concept → Build It" flow, requiring you to mirror the mathematics exactly as introduced. For example, the dot product isn't a function call—it is a manual sum(a * b for a, b in zip(...)) operation that makes the computational cost and algebraic properties explicit.
Key constraints during Build It include:
- No external ML frameworks allowed
- Must implement the mathematical operations manually
- Code must pass sanity checks defined in
if __name__ == "__main__":blocks
The Use It Phase: Production Framework Validation
Immediately following Build It comes Use It, where the same algorithm runs through a production-grade library. As documented in phases/03-deep-learning-core/05-loss-functions/code/pytorch_demo.py, learners rewrite their vector operations using torch.tensor objects and torch.dot functions.
The critical requirement is maintaining an identical API surface between your hand-crafted code and the library version. If your Vector class supports + and dot(), the PyTorch implementation must use the same operations. This direct comparability lets you verify that your from-scratch mathematics produces identical results to optimized CUDA kernels.
The Use It phase answers three specific questions:
- What exactly does the framework abstract away?
- Which hyper-parameters affect performance and why?
- Where do production optimizations gain their speed?
Why the Methodology Works: The Learning Spine
According to the curriculum's README.md at line 99, this split forms the spine of the learning experience. By first wrestling with low-level code, you internalize concepts like matrix multiplication mechanics, back-propagation chain rules, and attention score calculations before they become opaque framework calls.
When you subsequently swap in PyTorch or scikit-learn, you don't see magic—you see familiar patterns running faster. You understand that torch.nn.Linear is matrix multiplication plus bias, not a black box, because you've already implemented the equivalent Vector transformation manually.
This pattern repeats across all 20 curriculum phases, from raw vector arithmetic through full-scale transformer training. Each lesson concludes with a Ship It step that produces reusable artifacts—prompts, skills, or MCP servers—derived from the validated code.
Code Comparison: Build It vs Use It
Build It Implementation
The pure-Python approach in phases/01-math-foundations/01-linear-algebra-intuition/code/vectors.py defines operations explicitly:
class Vector:
def __init__(self, components):
self.components = list(components)
def __add__(self, other):
return Vector([a + b for a, b in zip(self.components, other.components)])
def dot(self, other):
return sum(a * b for a, b in zip(self.components, other.components))
Running this file executes sanity checks for addition, dot products, angles, and linear independence without any external dependencies.
Use It Implementation
The same operations using PyTorch from phases/03-deep-learning-core/05-loss-functions/code/pytorch_demo.py:
import torch
a = torch.tensor([1., 2., 3.])
b = torch.tensor([4., 5., 6.])
# Addition and dot product with identical API semantics
c = a + b
dot = torch.dot(a, b)
# Angle calculation using cosine similarity
cos = torch.nn.functional.cosine_similarity(a.unsqueeze(0), b.unsqueeze(0))
angle = torch.acos(cos) * 180.0 / torch.pi
Because the hand-crafted Vector class already supports + and dot, transitioning to torch operations feels natural rather than arbitrary.
Bridging Both Worlds: The Mini-Framework
As lessons progress, the curriculum introduces a mini-framework that unifies both approaches. In phases/03-deep-learning-core/10-mini-framework/code/mini_framework.py, a Tensor wrapper accepts either pure-Python Vector instances or torch.Tensor objects:
class Tensor:
def __init__(self, data):
self.data = data
def __add__(self, other):
return Tensor(self.data + other.data)
def dot(self, other):
if isinstance(self.data, torch.Tensor):
return Tensor(self.data.dot(other.data))
return Tensor(self.data.dot(other.data))
This wrapper demonstrates how the curriculum moves from educational code to reusable libraries while maintaining the mathematical clarity established in the Build It phase.
Summary
- Build It requires implementing deep learning algorithms using only standard libraries, mirroring the underlying mathematics exactly as presented in the lesson's "Problem → Concept" flow.
- Use It validates these implementations against production frameworks like PyTorch while maintaining identical API surfaces for direct comparison.
- The methodology creates a learning spine that internalizes mathematical foundations before introducing abstractions, making framework behavior predictable rather than opaque.
- Source files like
vectors.pyandpytorch_demo.pyprovide concrete examples of the same operations implemented both ways across the 20-phase curriculum. - Each lesson generates reusable artifacts (skills, prompts, agents) during the Ship It phase that follows Use It validation.
Frequently Asked Questions
What specific files demonstrate the Build It / Use It methodology?
The curriculum overview in README.md at line 99 defines the six-beat lesson structure including the Build It / Use It split. Concrete implementations appear in phases/01-math-foundations/01-linear-algebra-intuition/code/vectors.py for the Build It phase, and phases/03-deep-learning-core/05-loss-functions/code/pytorch_demo.py for the Use It phase. The lesson narrative documentation at phases/01-math-foundations/01-linear-algebra-intuition/docs/en.md walks through the full flow including the Ship It step that produces reusable AI agent skills.
Why can't I use NumPy or PyTorch during the Build It phase?
The restriction against external ML frameworks during Build It ensures you internalize the computational complexity and algebraic mechanics of deep learning operations. When you manually implement a dot product as sum(a * b for a, b in zip(...)) rather than calling np.dot(), you see exactly how many multiplications and additions occur. This first-principles approach prevents treating matrix operations as black boxes and builds the mathematical intuition necessary to debug and optimize the production versions you encounter in the Use It phase.
How does the methodology handle the transition from vectors to complex architectures like transformers?
The Build It / Use It pattern scales across all 20 curriculum phases, maintaining the same rigorous "Problem → Concept → Build It → Use It → Ship It" structure. Early phases focus on linear algebra and calculus foundations using pure Python classes, while later phases apply identical principles to back-propagation, attention mechanisms, and full transformer training. The consistency means that by the time you reach complex architectures, you've already practiced the pattern on simpler components, making the transition from manual gradient computation to torch.autograd a straightforward validation step rather than a conceptual leap.
What makes the Ship It phase different from Use It?
While Use It focuses on validating your implementation against production libraries, Ship It produces deliverable artifacts derived from that validated code. According to the repository structure, this phase generates reusable components like prompts, skills, agents, or MCP servers stored in outputs/skills/ directories. These aren't just learning exercises—they're production-ready tools that can be immediately deployed into Claude, Cursor, or other AI engineering workflows, ensuring the curriculum bridges educational knowledge and practical application.
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 →