The factory, end to end

Build the ruler.
Then build the model.

A small specialist earns its place one artifact at a time. This is the shortest path through the system—from choosing a capability to deciding whether the result should ship, redirect, retry, or stop.

  1. 01target
  2. 02data
  3. 03post-train
  4. 04evaluate
  5. 05package
  6. 06report

Field guides

nine stages / thirteen things you can make

Learn by leaving artifacts behind.

Theory becomes useful when you can change a real system and prove what the change did. Each stage ends in something inspectable: a model, adapter, benchmark, agent, package, runtime decision, or causal probe.

runnable lab

A bounded local or browser exercise with an existing implementation.

guided replay

A source-linked reconstruction of retained evidence; it does not claim a fresh run.

recipe contract

A complete procedure whose expensive execution begins only as a fresh, budgeted experiment.

01

How does text become a prediction and a gradient?

Make a language model

Trace the complete transformer learning loop, then change it without losing track of tensor shapes.

Open the learning path →

02

Is the learner correct before it is large?

Make training trustworthy

Use tiny-overfit, held-out loss, numerical checks, and bounded comparisons to separate implementation bugs from optimization problems.

Open the learning path →

03

Which intervention teaches the missing behavior with the least collateral damage?

Change model behavior

Turn data and an adaptation method into an adapter whose target gain and regressions are explicit.

Open the learning path →

adapter

LoRA specialist adapter

recipe contract

A narrow adapter built from a frozen base, traceable data, explicit LoRA geometry, and a held-out task gate.

workloadfresh training requires an explicit budget

routed specialist

Distilled tool-calling specialist

guided replay

A real lineage where narrow file-operation depth reached 100% while breadth regressed, proving why routing is part of the artifact.

workloadreplay is read-only; reproduction is a budgeted experiment

04

Does the benchmark measure the capability it claims to measure?

Build the ruler

Freeze a baseline, validate the frontier ceiling, inspect slices, and end with a reproducible decision rather than a score screenshot.

Open the learning path →

benchmark case file

Needle 2 selection ruler

guided replay

A complete tiny-model journey from catalog ablation through a 2x2 distractor-and-safety training factorial, ending at a measured 45M capacity boundary.

workloadpublic evidence replay; rerunning model evaluation requires approval

decision artifact

Specialist factory report card

runnable lab

A run directory that binds target, data, candidate, frozen evaluation, packaging evidence, resource measurements, and a terminal ship/retry/reject decision.

workloadmetadata lifecycle is light; model evaluation may require approval

05

What turns model output into a safe, useful local agent?

Make the model act

Separate model capability, constrained output, validation, tool policy, state, and serving performance in one trace.

Open the learning path →

06

Where do the time, memory traffic, and numerical drift actually come from?

Understand the machine

Use the readable implementation as an oracle while comparing kernels and architectures with end-to-end measurements.

Open the learning path →

07

Did the artifact become cheaper to store, load, and run without losing its job?

Make it smaller and portable

Distinguish file compression, RAM reduction, fewer operations, runtime kernel support, and retained capability.

Open the learning path →

08

Which parts belong in Python, Swift and MLX, Core ML, WASM, or WebGPU?

Cross runtime boundaries

Choose a runtime from capability, ownership, memory, latency, energy, distribution, and browser constraints—not platform novelty.

Open the learning path →

browser inference artifact

Parakeet browser ASR receipt

guided replay

A paired browser/native ASR lab: Parakeet wins bounded WER and latency while a frozen 50x short-clip throughput gate catches fixed dispatch cost.

workloadeight reference-scored LibriSpeech clips against native WhisperKit

architecture decision record

Mac runtime boundary map

guided replay

A comparison of owned MLX weights, Core ML deployment, Apple Foundation Models, and browser runtimes grounded in measured capability limits.

workloadread-only evidence synthesis

09

Which internal representation causally contributes to a measured behavior?

Look inside without fooling yourself

Turn a behavioral failure into a probe, control, intervention, and decision-changing prediction.

Open the learning path →

learning lab / nine ready paths

Learn it, inspect it, then run it.

Each path has prerequisites, a repository lab, and a mastery gate. Start with foundations; use the others when their prerequisites are earned.

01

start here

Foundations to transformer

  1. Functions, data, and parameters
  2. Loss and gradient descent
  3. Vectors, matrices, and tensors
  4. Non-linear networks and backpropagation
  5. Tokenization and embeddings
  6. Attention and transformer blocks
Lab
Complete the toy calculation or implementation in Modules 1-7 and explain its tensor shapes aloud.
Mastery gate
Trace text from tokens through embeddings, attention, MLP, logits, loss, and one gradient update without skipping a transformation.
Open the path →Foundation prerequisite; applied recipes begin in later paths.
7 evidence anchors
02

after foundations

Training mechanics and stability

  1. Batches and masking
  2. Optimizers and schedules
  3. Precision and numerical checks
  4. Tiny-overfit correctness gate
  5. Memory and convergence diagnosis
Lab
Inspect one successful tiny-overfit and one failed ordinary run, then diagnose data, optimization, capacity, and evaluation separately.
Mastery gate
Given a loss curve and held-out result, identify what is proven and choose the smallest discriminating next test.
5 evidence anchors
03

after training-mechanics

SFT, adapters, preference tuning, and distillation

  1. SFT behavior learning
  2. LoRA geometry
  3. DPO and reference anchoring
  4. Distillation
  5. Routing and breadth retention
Lab
Reconstruct the SQL and file-ops lineages, including the variable changed, target gain, regression, and decision at each step.
Mastery gate
Design a recipe with data, target, reward or labels, regression slices, resource budget, stop rule, and ship/retry/reject threshold.
6 evidence anchors
04

after post-training

Evaluation, evidence, and the specialist factory

  1. Frontier-ceiling validation
  2. Frozen baselines and heldouts
  3. Slice and safety gates
  4. Trace review
  5. Packaging and report cards
  6. Ship, route, retry, or reject
Lab
Audit Needle, Chess, and 2048 and explain how the ruler or safety gate changed the decision before integration or training.
Mastery gate
Reject a superficially good score when its frontier ruler, safety slice, breadth gate, or provenance is invalid.
6 evidence anchors
05

after foundations + evaluation-and-factory

Inference, serving, tools, and long context

  1. Autoregressive decoding
  2. KV cache and prompt reuse
  3. Constrained generation
  4. Tool dispatch and routing
  5. Speculative decoding
  6. Long-context cache policies
Lab
Calculate KV memory, compare cold versus reused-prefill latency, and trace one tool request through model output, validation, and execution policy.
Mastery gate
Separate model capability, serving optimization, validation, and agent policy in one end-to-end trace.
7 evidence anchors
06

after foundations + training-mechanics

Architecture and kernel execution

  1. Reference transformer math
  2. Attention memory traffic
  3. Precision and tiling
  4. Sparse versus dense MoE
  5. Correctness before performance
Lab
Match one optimized attention or matmul path against the readable reference and identify the real bottleneck with a measured curve.
Mastery gate
Explain the numerical contract, memory traffic, and why a microbenchmark may not improve end-to-end training.
6 evidence anchors
07

after training-mechanics + evaluation-and-factory

Quantization, pruning, and artifact packaging

  1. Calibration and numeric formats
  2. Storage versus runtime kernels
  3. Pruning and physical topology
  4. Load and serve parity
  5. Model cards and public evidence
Lab
Audit one int4 or pruned artifact from source weights through file size, load parity, quality, RAM, and runtime measurement.
Mastery gate
Distinguish a smaller file, lower RAM, fewer physical operations, and faster wall-clock execution.
5 evidence anchors
08

after architecture-and-kernels + runtime-and-agents

Browser, WASM, WebGPU, MLX, and Apple runtime

  1. WASM memory and SIMD
  2. WebGPU device and kernel model
  3. Browser caching and distribution
  4. MLX unified memory
  5. Apple Foundation Models and Core ML boundaries
  6. Browser ASR case study
Lab
Compare the historical unqualified WebGPU curve and its missing receipt, Memory64 limit, Apple action-grounding result, and Parakeet browser receipt as four different capability and evidence boundaries.
Mastery gate
Choose the correct Mac or browser runtime from capability, memory, latency, energy, download, and ownership constraints.
6 evidence anchors
09

after foundations + evaluation-and-factory

Interpretability with causal discipline

  1. Attention and logit inspection
  2. Linear probes
  3. Activation patching and causal tracing
  4. Sparse autoencoders
  5. Controls and intervention claims
Lab
Take one behavioral failure and write a probe hypothesis, negative control, intervention, and decision-changing prediction.
Mastery gate
Refuse to turn an attractive visualization into a causal model claim without an intervention.
3 evidence anchors

00 / admission rule

Frontier is the calibration anchor, not the opponent.

If a strong frontier model cannot nearly ace a benchmark, that benchmark cannot grade the Mac model. Fix or drop the ruler first. The objective is frontier capability retained per unit of model size, RAM, latency, and cost.

01–06 / the retained lab loop

Six questions. Six durable artifacts.

The narrative is the index. The linked docs and code remain the source of truth.

Did capability rise on the frozen target without unacceptable regressions?

Make the candidate earn the claim.

The same evaluator scores baseline and candidate. Slice metrics, legality, raw outputs, latency, RAM, throughput, and uncertainty stay visible; a benchmark whose frontier ceiling fails is rejected.

case files / decisions, not demos

What the loop has actually taught us.

An improvement, a regression, and a failed ruler are all useful when they force a clear next decision.

improved

Tool calling: training helps a weak base

The 1.7B arc moved from stock to SFT to GRPO. SFT did most of the work; GRPO added two points, then the approach plateaued below the stronger 4B.

Read the full arc →

56 → 76 → 78

routed

File ops: depth won, breadth regressed

The distilled 4B aced the narrow hard gate while losing out-of-domain breadth. That is a routed specialist result, not a general model upgrade.

Inspect the package →

58 → 100 / 59.6 → 42.3

rejected ruler

Character 2048: no intelligence gradient

The strongest completed frontier attempt did not clear the frozen 1.10× bar over paired random legal play. Training was stopped and the replay was retained.

Watch the failed attempt →

1.058× best frontier ratio

candidate

Character Chess: promising, not frozen

The first suite showed a real gradient, but the frontier did not approach the required ceiling. The expanded candidate pool remains for human review—not small-model grading.

Inspect candidate evidence →

65% frontier development score

annotated source / where to begin

Read the system in the same order it runs.

Qwen Chess made its implementation approachable by naming the modules behind each lesson. These are the equivalent entrypoints here; the repository contains the complete implementation and history.

  1. 01
    FactoryRunCommand.swift ↗

    CLI composition and the top-level run boundary.

  2. 02
    FactoryRunLifecycle.swift ↗

    State transitions, locks, manifests, and durable run identity.

  3. 03
    SFT.swift ↗

    The readable Mac-local supervised fine-tuning path.

  4. 04
    EvalCompare.swift ↗

    Baseline-versus-candidate comparison under one contract.

  5. 05
    build_fine_tune_report_card.py ↗

    Offline compiler from validated evidence to the public before/after report.

  6. 06
    attempt-ledger.md →

    The durable memory of shipped, retried, rejected, and incomplete attempts.