Skip to content

Interpretability, attribution, and explanation audits · Interpretability, explanations, and model-mechanism analysis · EXP013 · Architecture

Concept bottleneck model

Predict explicit concepts before predicting the final task target, enabling controlled edits to intermediate concept values inside the model.

Runs as a notebook Complete calculation CodeSplash's run and the reference's record

In CodeSplash

No method yet, but the reference's example runs here as a notebook.

Do it in CodeSplash Open the reference's example as a Python or R notebook.

Availability
Runs as a notebook
Code example
Complete calculation
Who ran it
CodeSplash's run and the reference's record
CodeSplash's run
The reference's example ran in Python and R here, and they agree.
The reference's record
Python: Ran in the reference's review, on this exact code. R: Reviewed but not run: R wasn't available to the reference's authors.

Purpose

Predict explicit concepts before predicting the final task target, enabling controlled edits to intermediate concept values inside the model.

Question / hypotheses

Does the task prediction depend on intended concepts, and how does it change when a specified predicted concept is corrected?

Architecture / computational structure

A concept predictor g maps inputs to a vector c; a task predictor f uses this bottleneck. Training can be independent, sequential or joint. The design and any bypass/residual path determine whether all task information truly passes through the stated concepts.

Assumptions

Concepts must be defined, annotated and sufficiently informative for the task. Concept supervision can be noisy or incomplete. A model-level concept intervention is not by itself a causal intervention on the real world.

Formula / computational definition

c^=gθ(x),y^=fψ(c^),L=Ly(fψ(gθ(x)),y)+λ∑jLcj(gθ,j(x),cj).\widehat c=g_\theta(x),\quad\widehat y=f_\psi(\widehat c),\qquad\mathcal L=\mathcal L_y(f_\psi(g_\theta(x)),y)+\lambda\sum_j\mathcal L_{c_j}(g_{\theta,j}(x),c_j).

Parameters and notation

Learned: concept encoder θ and task head ψ. Choices include concept set, hard/soft bottleneck, training regime, concept-task loss weight λ, class balancing, intervention policy and any residual channel. Continuous concept scores can encode information beyond their nominal labels. Here x is the input, c the labeled concept vector, c-hat its predicted version, y the target, y-hat the task output, g_theta the concept encoder, f_psi the task head, and L_y and L_cj the task and concept losses. The displayed objective describes joint training; independent and sequential regimes differ.

Fitting, fine-tuning, and adaptation

Fine-tune concept and task modules under a declared regime. Check concept calibration, leakage and distribution shift after adaptation. Human correction policies require their own evaluation, including how many concepts are inspected and how correction errors are handled.

How to use and calibrate

Report task accuracy, per-concept performance and intervention curves. Compare oracle concept replacement with realistic noisy human corrections. Audit whether soft bottlenecks leak task information that is not semantically represented by the concept labels.

Example application

Predict a controlled image attribute vector and compare task outputs before and after correcting one known attribute error.

Interpretation / pitfalls

Watch out

A named bottleneck does not guarantee semantic faithfulness. Strong task prediction may coexist with weak concept interpretation. Joint training can trade concept fidelity against predictive loss; missing concepts can force the model to exploit proxies.

Python and R code examples

Scope: Exact task-head propagation before and after one supplied concept correction; no concept-encoder training. Python: NumPy; R: base R.

Validation: Python executed successfully on the supplied fixture; R reviewed but unexecuted. Full implementations and supported operation details are provided in the linked primary/official sources.

Python and R

The reference's own programs, shown as written. A component demo shows one central piece of the method; it doesn't train a full model.

Python

Complete calculation — Exact task-head propagation before and after one supplied concept correction; no concept-encoder training. Python: NumPy; R: base R. · needs numpy

import numpy as np
c=np.array([.2,.8,.4]);w=np.array([2.,-1.,.5]);bias=-.2
prob=lambda z:1/(1+np.exp(-(w@z+bias)))
fixed=c.copy();fixed[0]=1.;print(prob(c),prob(fixed))
assert prob(fixed)>prob(c)
R

Complete calculation — Exact task-head propagation before and after one supplied concept correction; no concept-encoder training. Python: NumPy; R: base R.

c<-c(.2,.8,.4);w<-c(2,-1,.5);bias<--.2
prob<-function(z) plogis(sum(w*z)+bias);fixed<-c;fixed[1]<-1
print(c(before=prob(c),after=prob(fixed)));stopifnot(prob(fixed)>prob(c))

Sources

From the CodeSplash reference, entry EXP013.