Can I rebuild the system faithfully?
Implement the architecture and training pipeline from scratch, reproduce the 124M configuration, and verify every stage with parity tests and logged metrics.
Output: a trained, reproducible checkpoint.Inside the prediction
From-scratch reproduction and causal explanation of GPT-2 124M next-token predictions.
Reproducing GPT-2 teaches how the model is built and optimized. It does not, by itself, make the project Explainable AI. The second phase freezes the trained checkpoint and tests explanations against controlled interventions.
Implement the architecture and training pipeline from scratch, reproduce the 124M configuration, and verify every stage with parity tests and logged metrics.
Output: a trained, reproducible checkpoint.Compare attribution, attention, and causal interventions on matched prompts, then quantify when each explanation succeeds or fails.
Output: an explanation benchmark, not just a visualization.Implement token and position embeddings, causal multi-head attention, MLP blocks, residual streams, layer normalization, weight tying, and next-token loss directly in PyTorch.
Build sharded data loading, gradient accumulation, mixed precision, learning-rate scheduling, checkpointing, reproducible evaluation, and GPU-memory monitoring.
Read loss curves, gradient norms, token throughput, validation gaps, and failure signals instead of treating training as a black-box command.
Separate an attractive visualization from evidence by testing whether highlighted tokens and internal states actually control a prediction.
Define baselines, matched counterfactuals, quantitative metrics, uncertainty, and negative-result reporting before inspecting the final explanations.
Turn one reproducible model checkpoint into a documented experiment suite, an interactive inspection tool, and a defensible final report.
The implementation follows the public build-nanogpt reference repository. I will pin its commit SHA before starting so “reproduction” refers to one exact code state.
12 Transformer blocks · 12 attention heads · 768-dimensional residual stream · 1,024-token context · 50,257-token GPT-2 vocabulary.
Tokenize the sample-10BT subset with the GPT-2 tokenizer and store deterministic uint16 train/validation shards.
Overfit one batch, run a short training smoke test, save and reload a checkpoint, and resume without changing the loss trajectory.
Use BF16, Flash Attention, fused AdamW, gradient accumulation, gradient clipping, warmup, cosine decay, and periodic validation.
Track validation loss and HellaSwag accuracy, then inspect fixed-seed text samples as a qualitative diagnostic.
This interactive preview shows the questions the final tool will answer. It is an experiment design, not a display of completed results.
Establish the model's next-token prediction and collect token, head, and residual-stream signals.
Record the target logit before any intervention.
No causal claim yet: this is the measurement baseline.
Remove or replace one token or phrase, rerun the model, and measure the change in the target token's logit.
Integrate gradients from a defined baseline embedding to the real embedding and attribute the target logit across tokens.
Inspect head-level attention patterns and test whether apparently relevant heads are consistent across prompt variants.
Patch a source prompt's residual or head activation into a matched counterfactual and measure recovery of the source prediction.
Change one semantic variable, such as France to Germany, while holding syntax and task structure constant.
I will call a method causally informative only when its highlighted features predict held-out intervention effects better than random, position-matched, and magnitude-matched baselines.
40 GB VRAM · 64 GB RAM minimum, 128 GB preferred · 120 GB disk
Planning estimates, not guarantees. The run stops if loss, throughput, or memory fails a pre-set health check.
Token shards require roughly 20–22 GB. The environment, checkpoints, logs, and XAI artifacts add approximately 20–35 GB. Raw dataset caches are cleared only after shard hashes and decoded samples are verified, keeping the run below the disk ceiling.
Pin the reference commit, recreate the architecture, and write parity tests.
Build deterministic shards and validate training, checkpointing, and resume behavior.
Run the 10B-token job, monitor it, and preserve all metrics and checkpoints.
Implement attribution, ablation, counterfactual, attention, and activation-patching pipelines.
Run matched examples, baselines, controls, uncertainty estimates, and error analysis.
Build the prediction microscope, write the dissertation, and package reproducible artifacts.
Readable PyTorch code, architecture tests, pinned dependencies, data manifest, and reproducible commands.
Checkpoint, configuration, train/validation curves, HellaSwag scores, throughput, and run-cost report.
Matched prompts, interventions, attribution outputs, activation patches, baselines, uncertainty, and failure taxonomy.
An interactive dashboard for tracing one next-token prediction across inputs, layers, heads, and counterfactuals.
A precise account of what replicated, which explanations survived causal tests, and which negative results changed the conclusion.