Concept-based explanations
What Are Concept-based Explanations?
The shift:
- Feature attribution → "Pixel (x, y) contributed +0.8 to the output."
- Concept-based → "The presence of 'stripes' contributed +2.3 to classifying this as a zebra."
How It Works: Deriving TCAV (Testing with Concept Activation Vectors)
TCAV (Kim et al., 2018) is the canonical concept-based method. Let's build it from scratch.
Step 1: What is a Concept Activation Vector (CAV)?
Suppose we want to test if a model uses the concept "striped."
- Gather concept examples: Collect images with stripes (P) and random images without stripes (N).
- Extract activations: Feed both sets through the model, extract activations at layer : .
- Train a linear classifier: Learn a hyperplane separating P from N in activation space:
where for concept examples, for random. The normal vector (after normalization) is the CAV — it points in the "striped" direction in activation space.
Why this works: If the model represents "stripes" internally, striped images cluster in activation space. The CAV captures that clustering direction.
Step 2: Measuring Concept Sensitivity
Now we test: Does the model's prediction for class depend on concept ?
Define the directional derivative of the logit for class w.r.t. the concept:
Breaking it down:
- : gradient of class 's logit w.r.t. layer activations. This tells us "how to change to increase ."
- : dot product. If positive, moving toward the concept direction increases .
- : binary indicator. We count the fraction of examples where the concept positively influences the class.
Why the expectation? We test on multiple examples of class (e.g., many zebra images) to avoid noise from a single sample.
Step 3: Statistical Significance
Run TCAV with multiple random concept sets (same size as P, drawn from N). If the real CAV's score is significantly higher than random, the concept is genuinely used.
Typical threshold: .
Worked Example: "Striped" for Zebra Classification
Setup: ImageNet classifier, class = zebra, concept = "striped."
- Collect concept examples: 50 images with stripes (tigers, barcode patterns, striped shirts), 50 random ImageNet images.
- Extract activations: Use layer
mixed5c(Inception V3). Each image → . - Train CAV: Logistic regression on the 100 activations. Get .
- Test on zebras: Take 100 zebra images. For each:
- Compute via backprop.
- Check if .
- Result: 87% of zebras have positive directional derivative → .
- Compare to random: Run 20 random CAVs → mean TCAV = 0.52, std = 0.08. The score 0.87 is away → . Conclusion: The model genuinely uses "stripes" to classify zebras.
Why this step? Without statistical testing, a TCAV of 0.6 could be noise. The random baseline controls for spurious correlations in activation space.

ACE: Automated Concept Extraction
How it works:
- Segment inputs: Use image segmentation (e.g., SLIC superpixels) to extract patches.
- Cluster activations: Run k-means on layer activations of all patches. Each cluster = a discovered concept.
- Name concepts: Manually inspect cluster examples or use a captioning model.
- Run TCAV: Test each discovered concept's importance via TCAV.
Advantage: Fully data-driven. Discovers concepts you didn't think to test (e.g., "model uses background grass to classify cows").
Limitation: Cluster quality depends on segmentation. Semantic meaning isn't guaranteed.
Common Mistakes
Connections
- Feature Attribution Methods — Concept-based explanations complement pixel-level saliency by adding semantic meaning.
- Layer-wise Relevance Propagation — LRP traces importance to inputs; TCAV traces importance to concepts.
- Adversarial Examples — Concept-based methods can reveal spurious concepts the model exploits (e.g., "watermark" in medical images).
- Model Editing — Once you identify harmful concepts (via TCAV), you can ablate the corresponding CAV directions.
- Probing Classifiers — Both probe representation spaces, but probing asks "is concept X encoded?" while TCAV asks "is X used for decision Y?"
Key Takeaways
- Concept-based explanations translate model internals into human semantics.
- TCAV measures concept importance via directional derivatives of class logits.
- Statistical testing (random CAVs) is mandatory to avoid false positives.
- ACE automates concept discovery via clustering, but trades control for coverage.
- Concepts must be atomic (single semantic) and causally tested (not just present).
Recall Explain to a 12-year-old
Imagine you're teaching a robot to recognize animals. You show it pictures, and it learns on its own. Later, you ask: "When you see a zebra, what do you look for? Stripes? The shape? The background?"
But the robot doesn't speak English! Its brain is just a bunch of numbers. So we use a trick:
- Show the robot lots of striped things (flags, tigers, barcodes).
- Look at its brain's numbers when it sees stripes.
- Find the "direction" in its brain that means "stripy."
- Test: When the robot sees a zebra, does changing its brain toward "stripy" make it more confident it's a zebra? If yes → the robot uses stripes! If no → maybe it's looking at something else (like grass). This is like giving the robot a vocabulary test for concepts we understand.
Flashcards
#flashcards/ai-ml
What is the key difference between feature attribution and concept-based explanations?
What is a Concept Activation Vector (CAV)?
What does the TCAV score measure?
Why must TCAV be compared against random CAVs?
What is ACE and how does it differ from TCAV?
Why should concepts be atomic in concept-based explanations?
What does mean in TCAV?
What is the typical TCAV score range and interpretation?
How does ACE discover concepts automatically?
Why might a model classify zebras without using "stripes"?
Concept Map
Hinglish (regional understanding)
Intuition Hinglish mein samjho
Concept-based explanations ka main idea yeh hai ki model ko samajhne ke liye hum pixels ya numbers ki jagah insaan ke samajhne wale concepts use karein. Jaise agar ek model zebra ko classify kar raha hai, toh simple question hai: kya woh "stripes" dekh raha hai ya background ka grass dekh raha hai? TCAV (Testing with Concept Activation Vectors) ek method hai jisme hum pehle concept ki examples collect karte hain—jaise striped images—aur phir model ke andar ek "direction" nikalte hain jo us concept ko represent kare. Yeh direction CAV kehlati hai. Phir hum test karte hain: agar model ke activations ko us direction mein move karein, toh kya zebra ka prediction strong hota hai? Agar haan, toh model genuinely "stripes" use kar raha hai.
Iska practical fayda yeh hai ki doctors, engineers, ya regulators model ke decisions ko human terms mein samajh sakte hain. Agar ek medical model "tumor" detect karne ke liye galat concept (jaise image ka watermark) use kar raha ho, toh TCAV se yeh pata chal jayega aur hum fix kar sakte hain. Lekin important hai ki random baseline ke sath compare karein, warna coincidence ko signal samajh lenge. ACE method yeh kaam automatic kar deta hai—clustering se khud concepts discover karta hai—lekin phir bhi human ko check karna padta hai ki discovered concepts meaningful hain ya nahi.