agentleFS
zjunlpzjunlp/Mechanist/skills/mechanism-skills/causal-attribution/SKILL.md

causal-attribution

Skill75 starsChanged 4 months agoMITView on GitHub

Causal Attribution methods constitute the gold standard for localization in Mechanism Interpretability. Unlike correlation-based analyses, these techniques identify which internal objects are causally responsible for a specific model behavior by systematically measuring the effect of controlled interventions

The file

Files
SKILL.md

Advantage

Unlike Magnitude Analysis, which only establish correlation, Causal Attribution provides definitive evidence that a component is a functional driver of the model’s output. This allows researchers to distinguish essential mechanisms from features that are highly activated but causally irrelevant to the specific behavior.

Limitation

This rigor incurs a significant computational overhead. Verifying causality typically requires intervening on objects individually and performing a separate forward pass for each intervention. Consequently, the cost scales linearly with the number of objects analyzed, making it prohibitively expensive for dense, sweeping searches over large models. This inefficiency often necessitates the use of Gradient Detection, which utilizes gradients to rapidly approximate these causal effects, enabling efficient screening before performing expensive, fine-grained interventions.

Submethods

The intervention typically takes three forms: Patching, Ablation, or Attribution Patching.

  • Patching: This approach replaces an object computed from the original input with one computed from a counterfactual input to isolate specific information pathways. By systematically patching across layers and positions, one can localize exactly where task-specific information (e.g., factual knowledge) is introduced or transformed. You can find a demo for this method in ./patching. This demo illustrates the way to edit factual knowledge in large language models like GPT-2 or GPT-J, perform causal tracing to understand model behavior, or implement Rank-One Model Editing (ROME) to modify specific factual associations without retraining.
  • Ablation: Alternatively, ablation-based attribution explicitly “zeros out” or removes objects, and measures the resulting performance drop to determine their causal necessity. You can find a demo for this method in ./ablation. This demo shows dissecting-factual-predictions: Analyze and dissect factual recall in auto-regressive language models using attention knockout, hidden state analysis, and intervention techniques on GPT-2 and GPT-J models
  • Attribution Patching: Attribution Patching is an efficient first-order approximation of full Patching: instead of swapping an activation $x$ with a counterfactual $x'$ and re-running the model to measure the change in output $F(x)$, it uses a single backward pass to estimate that change via the inner product $\nabla_x F(x)^\top (x' - x)$. This Taylor expansion preserves the causal-attribution interpretation — each score predicts the effect of intervening on a specific component — while reducing the cost from $O(n)$ forward passes to a few backward passes, enabling fast, sweeping circuit discovery and edge-attribution analyses across attention heads, MLP layers, and individual edges that would be prohibitively expensive under exact patching. You can find a demo for this method in ./attribution-patching. This demo shows how to analyze neural network circuits, performing attribution patching, automated circuit discovery, or investigating model interpretability through edge attribution methods in transformer models.

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.