small·model·lab

A walk-through in three parts  · part of the AI Knowledge Hub

Build a small language model, and actually understand it.

A hands-on, no-black-box lab. Build a tiny language model from scratch, then fine-tune a real open model into a useful expert — with an optional, code-free concepts primer if you'd like the ideas first. Explained for the curious.

0
Concepts
How a language model works

The plain-English ideas behind it all, no code: what a model is, how text becomes numbers, and what “learning” really means, with diagrams. Read it first if you like theory; dip back in as Parts 1 and 2 link to it.

optional primer
Read Part 0 →
1
Pre-training
A GPT from scratch

Build and train a tiny GPT one piece at a time: tokens, attention, the training loop, y = Wx + b, sampling. The output is throwaway by design; the point is to see how it works.

start here
Read Part 1 →
2
Post-training
TrialScout: a useful expert

Take a pretrained open model and fine-tune it into a measurably useful tool that turns a clinical-trial record into a structured readout. Same concepts, now doing a real job.

the payoff
Read Part 2 →

Why this exists

i.

The learning tools I wish I'd had.

When I started, explanations were either hand-wavy analogies or dense papers. This is the middle I wanted: real, runnable code with every step narrated in plain English.

ii.

To make AI's concepts accessible to non-specialists.

You shouldn't need to be an ML engineer to build intuition for how these models actually work, and what they can and can't do. No prior Python required to read along.

iii.

To leave reusable patterns, not just a demo.

Each chapter is a template you can lift: pre-training a model from scratch (Part 1), and the post-training playbook (Part 2) — distilling a big model's judgement into a small, cheap one.

John E. Milad

About me

I'm John E. Milad. I run a biotech company and have spent the last few years deep in modern AI, using it daily, building with it, and working out what's worth knowing. small-model-lab is one hands-on piece of that.

It's also a working example of the method: this whole lab (the code, the site, the diagrams) was built in close, mutually-challenging collaboration with Claude, both of us drafting, with me directing, editing, and deciding throughout.

The bigger picture. small-model-lab is one project from my AI Knowledge Hub, a curated, regularly-updated library for the AI era: the tools, the practices, and a zero-to-shipping learning path.
Explore the AI Knowledge Hub →

© 2026 John E. Milad · MIT-licensed, open source: github.com/JEM-Fizbit/small-model-lab · builds on nanoGPT, Apple MLX, and TinyStories.
Built in collaboration with Claude (via Claude Code) · Spotted an error or have a comment? Open a GitHub issue.
Part of the AI Knowledge Hub.