Hadi Mohammadi
Free · self-paced · runs in your browser

Opening the Black Box

A hands-on course in explainable AI for large language models

Five days, thirteen labs. Learn to interpret, evaluate, and trust language models: feature attribution, attention analysis, probing, chain-of-thought faithfulness, and mechanistic interpretability. Every lab runs on a free Colab GPU in twenty minutes or less. No installs, no cost, no cluster. Just a browser and a Google account.

13 hands-on labs €0 to take <20 min per lab on a free GPU version-pinned, CI-tested weekly

How the free version works

This is the self-paced edition of a five-day summer school. The lectures point you at the ideas; the labs are where you do the work. All thirteen notebooks are public and open in one click.

01

Open a lab

Each day below links its notebooks straight into Google Colab. Click, then choose Runtime, Run all.

02

Read the outputs

The interesting part is not running the cell, it is reading what it prints. Each lab tells you the number to look for and why it matters.

03

Do the exercise

Every notebook ends with a scaffolded exercise. That is where the method becomes yours.

The five days

Work through them in order, one per sitting, or jump to the instrument you need. The labs build on a shared example, but each one stands alone.

Day 1

Why models need explaining

Shortcut learning and the Clever Hans problem, then a working map of every explanation method family. Where the field is, and why accuracy is not understanding.

ch01 · no GPU · < 1 min

Two classifiers at 95% accuracy. One collapses to a coin flip after deployment. Watch the ten-line explanation that would have caught it.

Open in Colab →
ch02 · ~5 min

One prediction, explained five different ways (LIME, SHAP, Integrated Gradients, attention, a self-explanation). See how little they agree.

Open in Colab →
Day 2

The instruments

Feature attribution done right (LIME, SHAP, Integrated Gradients), then attention analysis and its limits. The two most popular instruments, and where each one lies.

ch04 · 5 to 10 min

LIME, SHAP, and Integrated Gradients on the same ten inputs. They rank the evidence differently. Which do you trust?

Open in Colab →
ch05 · ~5 min

Attention maps on trial: aggregation traps, rollout, corroboration with gradients, head ablation. Attention and attribution rank tokens almost independently.

Open in Colab →
Day 3

Build it, break it

What a model knows versus what it uses: probing, counterfactuals, concept directions. Then explanation-guided attacks: how a faithful explanation becomes a weapon.

ch06 · 5 to 10 min

Layer-wise probes, greedy counterfactual edits, and a concept direction. Three ways to read what a model represents.

Open in Colab →
ch07 · no GPU · ~2 min

Build a transparent AI-text detector, then attack it through its own explanations. Guided edits flip its verdict far more often than random ones.

Open in Colab →
Day 4

Trust and evaluation

How to score an explanation: random floors, deletion tests, confidence intervals, and auditing an LLM judge. Then whether chain-of-thought reasoning is actually faithful.

ch08 · 5 to 10 min

A deletion and insertion faithfulness harness with bootstrap intervals, plus an LLM-judge audit that follows the answer's position instead of its content.

Open in Colab →
ch09 · 5 to 10 min

A test bench for chain-of-thought: truncation, mistake injection, planted hints. Catch a model that changes its answer for a hint it never mentions.

Open in Colab →
Day 5

Inside the model, into the world

Mechanistic interpretability: logit lens, activation patching, sparse autoencoders, steering. Then explainability in production and the EU AI Act, and a plan for Monday.

ch10 · 6 to 9 min · plus optional advanced labs

Induction heads, activation patching, SAE features, and steering on GPT-2 small. When the top rung of the ladder is worth the climb. The repository also carries labs on behavioral auditing (ch11), training for explainability (ch12), and a fully instrumented production RAG assistant (ch13) for when you want more.

Open in Colab →

A note on content. The labs on days 2 to 4 study a hate-speech classifier using a public research dataset of real tweets, shown as they are. The examples appear as data under analysis, not as speech anyone endorses; sanitizing them would change what the model sees. If you would rather not work with that material, the day-5 sentiment lab teaches the same methods on gentler text.

How it all fits together

This free course is one rung of a larger ladder. Each rung stands alone; together they take you from the idea, to the code, to running it at work.

The taste · 2 minutes

The playground

Poke the Black Box: type a sentence, watch a model decide, and see which words did it. Live, in your browser.

The reference

The book

Hands-On Explainable AI. The full treatment, written lab-first: every number in it was produced by the notebooks in the next rung.

The code · free, MIT

The labs

Thirteen open-source notebooks you can fork, cite, and build on. The book's evidence, runnable.

You are here · free

This self-paced course

A guided five-day path through the labs, with the result to look for in each. Free, in your browser.

For institutions

The instructor-led school

The full five-day experience: lectures, a red-team challenge, and a capstone. Hosted at your university or company.

Bring the full school to your institution

The instructor-led version is a five-day school: morning lectures, afternoon labs, a red-team challenge, and a capstone in which teams audit a model of their own and present the findings. It exists as a complete package (ten lecture decks, a syllabus, run sheets, a university proposal, and organizer documents) and can be hosted at a university or company.

Email me about hosting it →