Interactive playground

Poke the Black Box

Type a sentence. Watch a model decide whether it sounds positive or negative, see exactly which words tipped it, test whether that explanation actually holds, and then try to break it. This is explainable AI (XAI) in five minutes, live.

By Hadi Mohammadi · a companion to the book Hands-On Explainable AI and the free course Opening the Black Box · no signup, no tracking.

Everything runs in your browser. Nothing you type leaves this page.
Part 1

Watch it decide

The model below reads movie-review sentences and predicts positive or negative. It is deliberately simple: a logistic regression over single words, trained on 67,349 sentences from the SST-2 dataset (81.8% validation accuracy, seed 42). Simple is the point. For this model the explanation is exact: every word carries a learned weight, the weights add up, and that sum is the decision. Type anything, or start from an example.

POSITIVE · 77%
negativepositive
Which words did it? pushes positive pushes negative neutral or unknown

Show the arithmetic (the whole model, no hand-waving)

Weights add to a score, the score goes through a sigmoid, and that is the probability above. This table is the complete computation, which is why this model is called a glass box.

Now try the third example, The film is not good. The model calls it positive. It sees a bag of words: good pushes up harder than not pushes down, and word order does not exist here. Hold that thought for Part 4. Deeper: chapter 4 of the book covers attribution for models where nothing is exact anymore.

Part 2

Test the explanation

An explanation is a claim: these words carried the decision. Claims get tested. The standard check is a deletion test: remove the words the explanation says matter most, strongest first, and watch the model’s confidence. If the explanation is honest, confidence should collapse quickly, much faster than deleting random words. Evaluating explanations like this is what chapter 8 of the book, and my own research, is about.

For this glass-box model the test looks almost rigged: the explanation and the model are the same object, so it cannot fail. Keep that as your baseline. For deep models, Part 4, the explanation is a separate estimate, and this same test is the main honesty check we have.

Part 3

Flip it

The sharpest question you can ask a model is: what is the smallest change that would change your mind? That change is called a counterfactual explanation. Edit the sentence above and try to flip the verdict in as few word changes as you can. The counter tracks how far you have drifted from your starting point.

One more experiment: starting from a positive sentence, try flipping it by only adding not in front of the nicest word. On this model it usually fails, because a bag of words has no idea what the not is attached to. Counterfactuals are chapter 6 of the book; using them to attack models is chapter 7.

Part 4

Now the real thing

Real systems are not glass boxes. DistilBERT is a transformer with 66 million parameters, fine-tuned on the same task (its reported validation accuracy is 91%, against our 81.8%). Load it and it runs locally in your browser through WebAssembly; your text still goes nowhere. But there is no weight table to show you now. To explain it we have to probe from outside: remove each word, rerun the model, and measure what moved. That is occlusion, one of the attribution methods from chapter 4.

Where this goes

How it all fits together

This page is the two-minute version of a larger body of work on explaining language models.

You are here · 2 minutes · free

The playground

See, test, and break an explanation, live in your browser.

Self-paced · free

The course

Opening the Black Box: a guided five-day path through thirteen hands-on labs on a free GPU.

The code · MIT

The labs

Thirteen open-source notebooks: the evidence base, runnable and citable.

The reference

The book

Hands-On Explainable AI: the full treatment, written lab-first.

For institutions

The school

The instructor-led five-day summer school, hosted at your university or company.

Model card, honest limitations, and provenance