Keep exploration honest
The default method="none" returns effects and robust outlier scores without inventing p-values from the observed map.
Statistical audits for mechanistic interpretability
TransformerLens-FDR adds an explicit, assumption-aware path from activation-patching effects to multiple-testing results—without pretending a convenient null is automatically valid.
Activation patching asks whether restoring a clean activation recovers a metric in a particular context. When you inspect many components, the analysis needs a declared search family, a defensible no-effect comparison, and a validation split.
The default method="none" returns effects and robust outlier scores without inventing p-values from the observed map.
Use sign-flips only when prompt effects are independent and symmetric around zero, or provide task-specific controls that remove the tested relation.
Read the guardrails ↗BH is less conservative under its dependence conditions; BY is more conservative and allows arbitrary dependence when input p-values are valid.
See the correction ↗The package keeps the intervention, metric, null, correction family, and validation split connected. That makes a result easier to reproduce—and easier to challenge.
Align clean and corrupted prompts, target labels, a metric function, and the component family you intend to search.
Check prompt count, clean–corrupted metric gap, hook capture, family size, and attainable p-value resolution before expensive patching.
Measure per-prompt effects, normalized recovery, robust outlier scores, p-values when justified, and the Circuit Localization Index.
Select components on one prompt group, then evaluate the joint effect on disjoint groups with held-out templates.
Click a path to see what the add-on computes, what it assumes, and what the result does not establish.
Use this path when you are exploring or cannot explain what “no effect” should look like. You get normalized effects, robust outlier scores, and descriptive localization—no inferential p-values.
Use sign-flips only when prompt-level effects are independent and each effect is symmetric around zero under the null. Exchangeability alone is not enough, and the package cannot verify these assumptions.
Supply control mean effects with the same metric, normalization, component mapping, and prompt count. The library checks shapes and provenance; you must defend the scientific design.
Every result is conditional on the metric, prompts, null, correction family, and model configuration you chose. The formulas make those choices inspectable.
Near 0 means little recovery; 1 means the clean-to-corrupted gap is fully recovered. The ratio is undefined when the clean and corrupted metrics are equal.
FDR is a long-run expectation, not a guarantee about the false-result share in one audit.
A descriptive concentration score: high values indicate effects concentrated in fewer components. It is not a significance test or proof of causality.
Results keep the effect map, inferential fields, search family, p-value resolution, hook names, and methods statement together.
from transformerlens_fdr import PatchingAuditor, logit_difference
auditor = PatchingAuditor(
model,
metric_fn=logit_difference,
fdr_method="fdr_by"
)
preflight = auditor.check_setup(
clean, corrupt, correct, incorrect,
method="signflip"
)
result = auditor.run_patching_audit(
clean, corrupt, correct, incorrect,
method="signflip"
)
print(result.format_summary())CopiedThese are not decorative warnings. They define the boundary of what the output can support.
Check the clean–corrupted gap and p-value resolution before a long audit. A discrete p-value floor can make a target threshold unattainable.
If attention heads and MLP layers are one scientific search, combine their valid p-values before interpreting significance.
Choose components on one group of prompts, then evaluate the joint effect on disjoint groups. This reduces reuse of the same evidence.
attn_head, mlp_out, resid_mid, and mlp_in intervene at different computational locations.
Deep Search surfaced methodological support for the add-on’s design. Direct literature explicitly naming TransformerLens-FDR is limited, so these references are background and validation context—not independent validation of this package.
Zhang & Nanda emphasize that metrics and corruption choices affect interpretation—directly motivating explicit inputs and methods statements.
Read paper ↗ FAITHFULNESSHanna, Pezzelle & Belinkov argue that circuit overlap alone is not enough; a selected mask needs a behavioral faithfulness check.
Read paper ↗ SCALING DISCOVERYAttribution-based approaches frame the speed–faithfulness trade-off that motivates separating candidate discovery from held-out evaluation.
Read paper ↗ CIRCUITSThis line of work supplies the circuit-discovery context for component-level interventions and localization summaries.
Read paper ↗ SELECTIVE INFERENCESelection-aware inference highlights why using the same prompts for discovery and evaluation can overstate evidence.
Read paper ↗ FDR FOUNDATIONSBenjamini & Hochberg provide the published reference benchmark used by the repository’s regression test.
Read paper ↗Bring your existing TransformerLens workflow. Add a metric, declare the null, and keep the methods statement close to the result.
pip install transformerlens-fdrpip install git+https://github.com/anaykatiyar-lang/transformerlens-fdr.git