Project P11

Mechanistic interpretability of my own GPT

Can we open a transformer we trained ourselves and explain, with causal rather than merely correlational evidence, which algorithms it has learned and what its activations represent?

stages
8
duration
14 h 20 min
concepts
20
available in English
8 / 8
completed by you
0 of 8

Where it fits

Leads to

This completes the path.

Overview

An interpretability project that starts with toy models implementing known algorithms and ends with your own 124M-parameter GPT. Build hooks and residual-stream decomposition infrastructure, observe induction-head formation and grokking with progress measures, apply logit lenses, tuned lenses and probes with control tasks, and discover circuits using activation, path and attribution patching. Train sparse autoencoders on the residual stream, interpret features automatically with a local LLM, and intervene with steering vectors. The project closes with a paper-style report with explicit fidelity criteria and a discussion of interpretability illusions.

Why it matters

Understanding why a model produces its outputs is an active research area where an individual with a GPU can contribute. Investigating your own trained model connects what you have learned about transformers with rigorous causal methods, and provides tools to debug, audit and steer models, increasingly relevant to the safety of AI systems.

Stages 8

  1. 01Infrastructure: hooks and residual stream decompositionInstrument your GPT with named hooks in each component and verify equivalent logits after importing it into TransformerLens. Implement direct logit attribution by freezing the final normalization so embeddings, heads and MLP contributions sum exactly to the logits. Visualize and classify attention patterns across heads. GPUAdvanced100 min
  2. 02Induction heads and phase changesTrain one- and two-layer attention-only transformers on text and investigate the emergence of induction heads, changes in loss, and in-context learning. Detect candidate heads with scores on random repeated sequences, analyze their composition with previous-token heads, and search for them in your own GPT. GPUAdvanced100 min
  3. 03Grokking and the Fourier algorithmReproduce grokking in modular addition with a one-layer transformer and weight decay, then reverse engineer the learned algorithm in full, including sparse embeddings in the Fourier basis, trigonometric products in the MLP and constructive-interference readout. Mechanism-derived progress measures reveal continuous learning beneath an apparently abrupt transition. GPUResearch110 min
  4. 04Logit lens, tuned lens and controlled probesRead the residual stream layer by layer, using your own GPT or the public fallback model specified by the project. The documented run uses GPT-2 small and applies first a logit lens, then a tuned lens trained per layer, to see how the prediction forms. Train linear probes with control tasks that separate what the model represents from what the probe learns on its own. GPUAdvanced100 min
  5. 05Activation patching and circuit discoveryUse pairs of clean and corrupted inputs to study indirect-object identification in GPT-2 small and modular addition in the causal transformer trained in Lesson 3. Use activation patching to locate components, trace paths between GPT-2 heads with path patching, and compare exact search with attribution patching. Track which results apply to each architecture. GPUResearch120 min
  6. 06Sparse autoencoders on the residual streamTrain overcomplete sparse autoencoders on the residual stream, using the instrumented model or GPT-2 small as the public fallback from Lesson 1. Process tens of millions of tokens with L1 and TopK sparsity, measure standard metrics and revive inactive latents. Use a local language model to explain a hundred features and score its ability to predict activations. GPUResearch120 min
  7. 07Steering the model: steering vectors and interventionsUse discovered directions to change the behavior of the instrumented model, with GPT-2 small as the recorded fallback. Compare differences of means from contrastive sets, addition of SAE latents and feature ablation. For each intervention, use an independent classifier to measure the change in the target property and measure its cost in loss and unrelated behaviors. GPUResearch100 min
  8. 08Faithfulness, illusions and research reportWrite a short research report on a reference case in GPT-2 small and a result from the causal modular-addition transformer trained in Lesson 3. Apply explicit faithfulness, completeness and minimality criteria, reproduce known interpretability illusions, and document the limits across architectures, tasks and generalization. GPUResearch110 min

Final deliverable

An interpretability finding of your own

A paper-style report on a mechanism in your own GPT, with causal evidence, locally published SAEs with their feature browser, and code reproducing every figure.

Check what you already know

  • Decompose logits into the direct contributions of each head and MLP through the residual stream.
  • Detect induction heads using prefix-matching scores and relate them to a phase change in the loss.
  • Explain the Fourier algorithm that a transformer learns for modular addition.
  • Design a linear probe with a control task and measure its selectivity.
  • Apply activation patching and path patching to locate a circuit.
  • Train a sparse autoencoder and evaluate it by recovered loss, L0 and dead latents.

References